-
15. Re: datascoller on page number click data disappears
richface_number1 May 20, 2009 11:17 PM (in response to m.shinde)Thanks for your help. I will try your solution then.
I have other solution to solve the problem that is hit twice to database . I will remove constructor , but when i remove it i cant catch action click page number of datascoller and paramaters are submited. How to catch action when click page number ? The page seems no submission to server
JSP code :<rich:datascroller align="center" for="tableContent_id" onclick="onsubmit();" action="#{myBean.actionSearch}" />
I used it but no success. -
16. Re: datascoller on page number click data disappears
richface_number1 May 24, 2009 11:05 PM (in response to m.shinde)Hi nbelaevski, i try to implement datatable live demo with SerializableDataModel . It runs well. You use DataProvice that is AuctionDataProvider support data but it's scope is session. This is the risk when data is very large.
When i change dataprovide's scope to request the demo does not run with datascoller and every action is not active.
Can I do how to process my bean with request scope and no constructor function? Many thanks -
17. Re: datascoller on page number click data disappears
nbelaevski May 25, 2009 6:55 AM (in response to m.shinde)Have you tried using application scope to store DataProvider?
-
18. Re: datascoller on page number click data disappears
richface_number1 May 25, 2009 9:43 AM (in response to m.shinde)No, i only use session scope for my bean. But i want to use request scope for dataprovide cause the request bean needs small memory to store.
<!-- auctionDataModel --> <managed-bean> <managed-bean-name>auctionDataModel</managed-bean-name> <managed-bean-class>test.AuctionDataModel</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> <managed-property> <property-name>dataProvider</property-name> <property-class>test.AuctionDataProvider</property-class> <value>#{auctionDataProvider}</value> </managed-property> </managed-bean> <!-- auctionDataProvider --> <managed-bean> <managed-bean-name>auctionDataProvider</managed-bean-name> <managed-bean-class>test.AuctionDataProvider</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean>
Can you show me a way to solve this problem? Thanks -
19. Re: datascoller on page number click data disappears
nbelaevski May 25, 2009 10:30 AM (in response to m.shinde)I've changed scope for auctionDataProvider to request and it's working ok: rich:datascroller and actions work as expected.
-
20. Re: datascoller on page number click data disappears
richface_number1 May 25, 2009 10:31 AM (in response to m.shinde)i'm using richfaces 3.3.1.
-
21. Re: datascoller on page number click data disappears
richface_number1 May 25, 2009 10:50 AM (in response to m.shinde)I've changed scope for auctionDataProvider to request and it's working ok: rich:datascroller and actions work as expected.
Are you sure?? when i change scope to request the datatable still runs but it not wrong and place a bird action is not active. Because AuctionDataProvider has allItems property and it need to be constructed. if bean scope is request then allItems will be contructed many times and like that result of datatable is different result of datatable with session scope. -
22. Re: datascoller on page number click data disappears
nbelaevski May 25, 2009 10:53 AM (in response to m.shinde)Enter very high bid and you'll see it's working well. That's because data is generated randomly for each request, so you have to enter high value in order to exceed randomly generated value.
-
23. Re: datascoller on page number click data disappears
richface_number1 May 25, 2009 11:19 AM (in response to m.shinde)I know about random items. But i must enter bid twice then it runs.
I added my jsp search panel and action to search into my bean, you can add and check again. It does not run as expected
Jsp file<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt"%> <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%> <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%> <style type="text/css"> .rich-message-label { color:red; } .col1 { width:240px; } .col2 { width:80px; } .col4 { width:80px; } </style> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"> <f:view> <h:form> <fieldset style="position: relative;left:35%;margin:0px;width: 25%"> <legend >Search</legend> <h:panelGrid columns="2" > <h:column> <h:outputText value="Max Items" styleClass="textBoldClass"/> </h:column> <h:column> <h:inputText value="#{auctionDataProvider.maxId}"/> </h:column> <h:column> </h:column> <h:column> <rich:spacer width = "50"></rich:spacer> <h:commandButton value = "Search" styleClass="textBoldClass" action = "#{auctionDataProvider.actionData}" /> </h:column> </h:panelGrid> </fieldset> <rich:datascroller for="auction" maxPages="5"/> <rich:spacer height="30" /> <rich:messages style="color:red"></rich:messages> <rich:dataTable id="auction" value="#{auctionDataModel}" columnClasses="col1,col2,col3,col4" var="item" rows="10" width="100%"> <rich:column> <f:facet name="header"> <h:outputText value="Description"/> </f:facet> <h:outputText value="#{item.description}"/> </rich:column> <rich:column> <f:facet name="header"> <h:outputText value="Highest Bid"/> </f:facet> <h:outputText id="highestBid" value="#{item.highestBid}"> <f:convertNumber pattern="$#,##0.00"/> </h:outputText> </rich:column> <rich:column> <f:facet name="header"> <h:outputText value="Your Bid"/> </f:facet> <rich:message for="bid" /><br/> <h:inputText id="bid" value="#{item.bid}" label="Bid"> <f:validateDoubleRange minimum="0" maximum="1000000"/> </h:inputText> <a4j:commandLink id="bid_link" actionListener="#{item.placeBid}" value="Place a bid!" reRender="bid,amount,highestBid" /> </rich:column> <rich:column> <f:facet name="header"> <h:outputText value="Amount"/> </f:facet> <h:outputText id="amount" value="#{item.amount}" > <f:convertNumber pattern="$#,##0.00"/> </h:outputText> </rich:column> </rich:dataTable> <rich:messages style="color:red"></rich:messages> </h:form> </f:view> </ui:composition>
and add this function into AuctionDataProvicepublic synchronized void actionData() { List<AuctionItem> data = new ArrayList<AuctionItem>(); int max = Integer.parseInt(this.getMaxId()); for (int counter=0; counter<max; counter++) { AuctionItem item = new AuctionItem(new Integer(counter)); item.setDescription((String)RandomDataHelper.random(allDescriptions)); item.setHighestBid(new Double(RandomDataHelper.random(10, 100))); item.setQtyAvialable(new Integer(RandomDataHelper.random(1, 20))); /*AuctionItem item = new AuctionItem(new Integer(counter)); item.setDescription(allDescriptions[counter % 30]); item.setHighestBid((double)counter / 2); item.setQtyAvialable(counter);*/ data.add(item); } allItems = data; }
I do like that to change data of allItems and datascoller runs incorrectly.Please check it again, many thanks to help me. -
24. Re: datascoller on page number click data disappears
nbelaevski May 25, 2009 1:58 PM (in response to m.shinde)Yes, sorry, I didn't noticed that. In fact, that is the right behavior, because SerializableDataModel is used for processing of submitted data, but not for rendering. So, when "request" scope is used, there are two different sets of AuctionItem objects: one restored from SerializableDataModel, another one comes from newly created (when rendering happens) AuctionDataProvider. This means that AuctionDataProvider should be persistent storage (session-scoped bean in the simplest case, or DB access object).
And you can use a4j:keepAlive/@KeepAlive to work around this. -
25. Re: datascoller on page number click data disappears
richface_number1 May 26, 2009 9:42 AM (in response to m.shinde)Oh like that i can not use request bean for datascroll . This is not as my expected . Anyway thank you very much. I will use session bean or KeepAlive tag although it will take more memory.