Has anyone gotten EntityQuery to work with AJAX pagination? Right now the only
way I can get it to work is by putting the EntityQuery component in
CONVERSATION scope.
When it isn't in CONVERSATION scope it will not work properly. I can page
forward through the list and back through list. But after I leave the first
page I can't ever go back to it using repeated clicks of "Previous Page" or
clicking "First Page" Also, I can not access the last page of the list though
repeated clicking of "Next Page" or clicking "Last Page"
In both the First Page and Last Page not displaying, I can tell from the debug
statements that the query is getting executed with the correct firstResult and
returning the correct data. But the page does not update.
I don't see why I'd have to put the EntityQuery into CONVERSATION scope
non working example
components.xml
-------------------
| <framework:entity-query name="testCodeListQuery" ejbql="select c from
TestCode c" max-results="5"/>
|
view.xhtml
-------------
| <div id="register"><h:form id="testCodes"
| styleClass="register">
| <h:dataTable id="codeList" var="code"
value="#{testCodeList.resultList}">
| <h:column>
| <f:facet name="header">
| <h:outputText value="Code" />
| </f:facet>
| <h:outputText value="#{code.name}"/>
| </h:column>
| <h:column>
| <f:facet name="header">
| <h:outputText value="Desc" />
| </f:facet>
| <h:outputText value="#{code.desc}"/>
| </h:column>
| </h:dataTable>
| <a:commandButton value="First Page" reRender="testCodes"
disabled="#{!testCodeList.previousExists}">
| <a:actionparam name="firstResult" value="0"/>
| </a:commandButton>
| <a:commandButton value="Previous Page" reRender="testCodes"
disabled="#{!testCodeList.previousExists}">
| <a:actionparam name="firstResult"
value="#{testCodeList.previousFirstResult}"/>
| </a:commandButton>
| <a:commandButton value="Next Page" reRender="testCodes"
disabled="#{!testCodeList.nextExists}">
| <a:actionparam name="firstResult"
value="#{testCodeList.nextFirstResult}"/>
| </a:commandButton>
| <a:commandButton value="Last Page" reRender="testCodes"
disabled="#{!testCodeList.nextExists}">
| <a:actionparam name="firstResult"
value="#{testCodeList.lastFirstResult}"/>
| </a:commandButton>
|
| </h:form></div>
|
Paging Bean
--------------
| @Name("testCodePaginatior")
| public class TestCodePaginatior implements Serializable {
|
| @Logger
| private Log log;
|
| @In("#{testCodeListQuery}")
| private EntityQuery testCodeListQuery;
|
| @Out
| private EntityQuery testCodeList;
|
| @RequestParameter("firstResult")
| private Integer firstResult;
|
| @Factory("testCodeList")
| public void init() {
| this.testCodeList = testCodeListQuery;
| int index = 0;
| if(this.firstResult != null){
| index = firstResult;
| }
| testCodeList.setFirstResult(index);
| log.debug("paging '#0' with firstResult =
'#1'",this.testCodeList, this.firstResult);
| }
| }
|
working example, but conversation scope
Paging Bean
--------------
| @Name("testCodePaginatior")
| public class TestCodePaginatior implements Serializable {
|
| @Logger
| private Log log;
|
| @In("#{testCodeListQuery}")
| private EntityQuery testCodeListQuery;
|
| @In(required=false)@Out(scope=ScopeType.CONVERSATION)
| private EntityQuery testCodeList;
|
| @RequestParameter("firstResult")
| private Integer firstResult;
|
| public void page(){
| log.debug("paging '#0' with firstResult =
'#1'",this.testCodeList, this.firstResult);
| int index = 0;
| if(this.firstResult != null){
| index = firstResult;
| }
| testCodeList.setFirstResult(index);
| testCodeList.refresh();
| }
|
| @Factory("testCodeList")
| public void init() {
| this.testCodeList = testCodeListQuery;
| int index = 0;
| if(this.firstResult != null){
| index = firstResult;
| }
| testCodeList.setFirstResult(index);
| log.debug("initing '#0' with firstResult =
'#1'",this.testCodeList, this.firstResult);
| }
|
view.xhtml
-------------
| <div id="register"><h:form id="testCodes"
| styleClass="register">
| <h:dataTable id="codeList" var="code"
value="#{testCodeList.resultList}">
| <h:column>
| <f:facet name="header">
| <h:outputText value="Code" />
| </f:facet>
| <h:outputText value="#{code.name}"/>
| </h:column>
| <h:column>
| <f:facet name="header">
| <h:outputText value="Desc" />
| </f:facet>
| <h:outputText value="#{code.desc}"/>
| </h:column>
| </h:dataTable>
|
| <a:commandButton value="First Page" action="#{testCodePaginatior.page}"
reRender="testCodes" disabled="#{!testCodeList.previousExists}">
| <a:actionparam name="firstResult" value="0"/>
| </a:commandButton>
| <a:commandButton value="Previous Page"
action="#{testCodePaginatior.page}" reRender="testCodes"
disabled="#{!testCodeList.previousExists}">
| <a:actionparam name="firstResult"
value="#{testCodeList.previousFirstResult}"/>
| </a:commandButton>
| <a:commandButton value="Next Page" action="#{testCodePaginatior.page}"
reRender="testCodes" disabled="#{!testCodeList.nextExists}">
| <a:actionparam name="firstResult"
value="#{testCodeList.nextFirstResult}"/>
| </a:commandButton>
| <a:commandButton value="Last Page" action="#{testCodePaginatior.page}"
reRender="testCodes" disabled="#{!testCodeList.nextExists}">
| <a:actionparam name="firstResult"
value="#{testCodeList.lastFirstResult}"/>
| </a:commandButton>
|
| </h:form></div>
|
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4019024#4019024
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4019024
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user