Rare pagination problem
juan_uy Sep 13, 2006 12:08 AMHi all,
I'm facing a rare problem using the Pagination code from the Code Generated by the JBoss Eclipse IDE CRUD reverse eng. (I have manualy hardcoded to understand the code too). Here is the explaination of the code, when I load the page for the first time, the page load the first ten rows, but when I click the next button, the page shows the same rows, and I press N times the next button again until the last page show, and in this case the page show the rows correctly. Similar problem I face when I do previous, in the last page when I press previous button, the page load the N-1 page rows correctly, but when I click previous button again the page shown the same rows of the N-1 page forever.
I have debuged the code, and I have noticed that the Code loads the corrects rows for the list, but when the results is rendered show the firsts rows.
I have used:
- Seam 1.0.1 GA with Sun JSF 1.2 RI and Facelets 1.1.14 (FaceletViewHandler)
- Seam 1.0.1 GA with MyFaces and Facelets 1.1.14 (FaceletViewHandler)
- Seam 20060912 Build with MyFaces and Facelets 1.1.14. (With the SeamFaceletViewHandler and FaceletViewHandler)
The code is the same as the Code of the Code Generator (Plus DRY principles using generics)
@Name("groupFinder") @Stateful @Scope(ScopeType.SESSION) @Interceptors(SeamInterceptor.class) public class GroupFinderBean extends GenericFinderBean<Group> implements GroupFinder { public GroupFinderBean() { super(new Group()); } @DataModel private List<Group> groupList; @DataModelSelection private Group selectedGroup; @SuppressWarnings("unchecked") protected StringBuffer buildQuery(Map<String, Object> parameters) { StringBuffer queryString = new StringBuffer(); if (example != null && example.getName() != null && example.getName().length() > 0) { Integer number = null; // Verify if I can convert te name to a number try { number = new Integer(example.getName()); } catch (NumberFormatException ex) { } // Build the query if (number == null) { queryString.append(" or group.name like :name"); parameters.put("name", '%' + example.getName() + '%'); queryString.append(" or group.description like :description"); parameters.put("description", '%' + example.getName() + '%'); } else { queryString.append(" or group.id = :id"); parameters.put("id", number); } } if (queryString.length() == 0) { queryString.append("select group from Group group"); } else { queryString.delete(0, 3).insert(0, "select group from Group group where"); } if (order != null) { queryString.append(" order by group.").append(order); if (descending) queryString.append(" desc"); } return queryString; } @Override protected List<Group> getList() { return groupList; } @Override protected Group getSelectedItem() { return selectedGroup; } @Override protected Group newInstance() { return new Group(); } @Override protected void setList(List<Group> list) { this.groupList = list; } }
The facelet-config for the navigation (I have used with and without redirect)
<navigation-rule> <navigation-case> <from-outcome>editGroup</from-outcome> <to-view-id>/modules/system/groups/editGroup.seam</to-view-id> <redirect/> </navigation-case> <navigation-case> <from-outcome>selectGroup</from-outcome> <to-view-id>/modules/system/groups/findGroup.seam</to-view-id> <redirect/> </navigation-case> <navigation-case> <from-outcome>viewGroup</from-outcome> <to-view-id>/modules/system/groups/viewGroup.seam</to-view-id> <redirect/> </navigation-case> <navigation-case> <from-outcome>findGroup</from-outcome> <to-view-id>/modules/system/groups/findGroup.seam</to-view-id> <redirect/> </navigation-case> </navigation-rule>
I'm sure that I forgot a stupid thing, but I really in trouble for days...and I don't have found the solution. :S
Any Ideas? ;)
Thx in adv.
juan.