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;
}