Java implementation of the next piece of content finishing __java

Source: Internet
Author: User

1, set up to receive the next article on the entity object

/**
* The next article on the entity receive
* @author SL
* @since 2018-01-05
*/
public class Preandnextentity {
/**
* The ID of the previous article or the next one
*/
Private String ID;
/**
* The title of a previous or next article
*/
Private String title;
Public String getId () {
return ID;
}
public void SetId (String id) {
This.id = ID;
}
Public String GetTitle () {
return title;
}
public void Settitle (String title) {
This.title = title;
}

}

2, according to a click of the content of the ID and article type query, the type of article on the previous and next preandnextentity entity content

/** * Get the details of the previous article
* @return
* @throws businessmsgexception
*/
Public preandnextentity getpreentity (String middleid,string type) throws businessmsgexception{
Log.info (show start on "Detail Page");
preandnextentity pre = new preandnextentity ();
Pinpaizixundata PD = new Pinpaizixundata ();
String Preid = "";
list<pinpaizixundata> list = new arraylist<pinpaizixundata> ();
List = Pinpaizixunservice.finddatabytype (type);
int count = List.size ();
All IDs of that type hold an array
string [] Strid = new String [Count];
for (int i=0; i<count; i++) {
Strid[i] = List.get (i). GetId ();
}

for (int j=0; j<count; j) {
if (Strid[j].equals (Middleid)) {
if (J!= 0) Preid = strid[j-1];
}
}
if ("". Equals (Preid)) {
Pre.setid ("");
Pre.settitle ("no");
}else{
PD = Pinpaizixunservice.finddatabyid (Preid);
Pre.setid (Preid);
Pre.settitle (PD.GETTITLECN ());
}
Log.info (show end on "Detail Page");
return pre;
}

/**
* Get the next article details
* @return
* @throws businessmsgexception
*/
Public preandnextentity getnextentity (String middleid,string type) throws businessmsgexception{
Log.info ("Next Show start in detail Page");
Preandnextentity next = new Preandnextentity ();
Pinpaizixundata PD = new Pinpaizixundata ();
String NextID = "";
list<pinpaizixundata> list = new arraylist<pinpaizixundata> ();
List = Pinpaizixunservice.finddatabytype (type);
int count = List.size ();
All IDs of that type hold an array
string [] Strid = new String [Count];
for (int i=0; i<count; i++) {
Strid[i] = List.get (i). GetId ();
}

for (int j=0; j<count; j) {
if (Strid[j].equals (Middleid)) {
if (J!= count-1) NextID = strid[j+1];
}
}
if ("". Equals (NextID)) {
Next.setid ("");
Next.settitle ("no");
}else{
PD = Pinpaizixunservice.finddatabyid (NextID);
Next.setid (NextID);
Next.settitle (PD.GETTITLECN ());
}
Log.info ("Next show End in detail Page");
return to Next;

}

3, the previous and the next article ID and title passed to the front page, successful return to the front page

Public String ShowDetail () throws businessmsgexception{
data = Pinpaizixunservice.finddatabyid (ID);
preandnextentity pre = getpreentity (ID, Data.gettype ());//previous content
Preandnextentity next = getnextentity (ID, Data.gettype ());//Next content
return SUCCESS;
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.