-
15. Re: Ordering bean values using rich:orderingList
rubenrjorge May 22, 2009 11:06 AM (in response to rubenrjorge)Yes, I'm using 3.3.1.GA.
I don't know what custom filters are, I'm new to JSF and RichFaces. The only time I changed web.xml was when I installed RichFaces.
I have found a full code and I used it to build my example. I must be doing something wrong because it doesn't work.
Here's my web.xml:<?xml version = '1.0' encoding = 'windows-1252'?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"> <description>Empty web.xml file for Web Application</description> <!-- rich --> <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>server</param-value> </context-param> <context-param> <param-name>org.richfaces.SKIN</param-name> <param-value>blueSky</param-value> </context-param> <context-param> <param-name>org.richfaces.CONTROL_SKINNING</param-name> <param-value>enable</param-value> </context-param> <filter> <display-name>RichFaces Filter</display-name> <filter-name>richfaces</filter-name> <filter-class>org.ajax4jsf.Filter</filter-class> </filter> <filter-mapping> <filter-name>richfaces</filter-name> <servlet-name>Faces Servlet</servlet-name> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher> </filter-mapping> <listener> <listener-class>com.sun.faces.config.ConfigureListener</listener-class> </listener> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> <session-config> <session-timeout>35</session-timeout> </session-config> <mime-mapping> <extension>html</extension> <mime-type>text/html</mime-type> </mime-mapping> <mime-mapping> <extension>txt</extension> <mime-type>text/plain</mime-type> </mime-mapping> </web-app>
-
16. Re: Ordering bean values using rich:orderingList
scott.farley May 22, 2009 1:39 PM (in response to rubenrjorge)I have been having this same problem and I am the one who logged the earlier referenced jira (https://jira.jboss.org/jira/browse/RF-6620). I am using WebLogic 10.0 with JDK 1.5, Facelets and JSF 1.2. I have recreated this issue with RichFaces 3.3.1, 3.3.0 and 3.2.1. This does not seem to happen with version 3.1.3. The issue I see is unpredictable results when submitting a form with an "orderingList". At first I thought it was just not passing back the reordered list but after multiple resubmits I see that there is even more strange behavior (the order starts to change in unpredictable ways.) I have reproduced this issue using the "orderingList" demo that comes bundled in with the source in the "samples" directory. I have slimmed down the code (for ease of communication) and it still happens. Here is the code:
web.xml<?xml version="1.0" encoding="UTF-8" standalone="no"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <!-- JSF Start --> <!-- Use documents saved as *.xhtml for Facelets--> <context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name> <param-value>.xhtml</param-value> </context-param> <!-- Rich Faces Start --> <context-param> <param-name>org.richfaces.SKIN</param-name> <param-value>blueSky</param-value> </context-param> <!-- Rich Faces End --> <!-- Facelets Start --> <context-param> <param-name>org.apache.myfaces.trinidad.ALTERNATE_VIEW_HANDLER</param-name> <param-value>com.sun.facelets.FaceletViewHandler</param-value> </context-param> <context-param> <param-name>facelets.SKIP_COMMENTS</param-name> <param-value>true</param-value> </context-param> <!-- Change for development --> <context-param> <param-name>facelets.DEVELOPMENT</param-name> <param-value>true</param-value> </context-param> <!-- Facelets End --> <!-- Use client-side state saving. In Trinidad, it is an optimized, token-based mechanism that is almost always a better choice than the standard JSF server-side state saving. --> <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>client</param-value> </context-param> <context-param> <param-name>org.apache.myfaces.trinidad.USE_APPLICATION_VIEW_CACHE</param-name> <param-value>false</param-value> </context-param> <!-- Change for development --> <context-param> <param-name>org.apache.myfaces.trinidad.CHECK_FILE_MODIFICATION</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>org.apache.myfaces.trinidad.resource.DEBUG</param-name> <param-value>false</param-value> </context-param> <!-- Change for development --> <context-param> <!--<param-name>org.apache.myfaces.trinidadinternal.DISABLE_CONTENT_COMPRESSION</param-name>--> <param-name>org.apache.myfaces.trinidad.DISABLE_CONTENT_COMPRESSION</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>org.apache.myfaces.trinidad.DEBUG_JAVASCRIPT</param-name> <param-value>false</param-value> </context-param> <!-- Rich Faces Start --> <filter> <display-name>RichFaces Filter</display-name> <filter-name>richfaces</filter-name> <filter-class>org.ajax4jsf.Filter</filter-class> <init-param> <param-name>forceparser</param-name> <param-value>false</param-value> </init-param> </filter> <filter-mapping> <filter-name>richfaces</filter-name> <servlet-name>faces</servlet-name> <!--<url-pattern>*.jsf</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher>--> </filter-mapping> <!-- Rich Faces End --> <filter> <filter-name>trinidad</filter-name> <filter-class>org.apache.myfaces.trinidad.webapp.TrinidadFilter</filter-class> </filter> <filter-mapping> <filter-name>trinidad</filter-name> <servlet-name>faces</servlet-name> </filter-mapping> <!-- JSF End --> <servlet> <servlet-name>faces</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>resources</servlet-name> <servlet-class>org.apache.myfaces.trinidad.webapp.ResourceServlet</servlet-class> </servlet> <!-- Servlet Mapping --> <!-- JSF mapping start --> <servlet-mapping> <servlet-name>faces</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>resources</servlet-name> <url-pattern>/adf/*</url-pattern> </servlet-mapping> <!-- JSF mapping end --> <!-- Servlet Mapping --> </web-app>
faces-config.xml<?xml version='1.0' encoding='UTF-8'?> <faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd" version="1.2"> <application> <locale-config> <default-locale>en</default-locale> </locale-config> <default-render-kit-id> org.apache.myfaces.trinidad.core </default-render-kit-id> </application> <managed-bean> <managed-bean-name>bean</managed-bean-name> <managed-bean-class>org.richfaces.Bean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> </faces-config>
org.richfaces.Bean.javapackage org.richfaces; public class Bean { private String [] simpleItems = new String [] { "First", "Second", "Third", "Fourth" }; public Bean() { } public String[] getSimpleItems() { return simpleItems; } public void setSimpleItems(String[] simpleItems) { this.simpleItems = simpleItems; System.out.println("org.richfaces.Bean.setSimpleItems():"); for (String simpleItem : simpleItems) { System.out.println(simpleItem); } } }
orderingList.xhtml<html xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ol="http://richfaces.org/rich" xmlns:a4j="http://richfaces.org/a4j" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Ordering List Demo.</title> </head> <body> <f:view> <a4j:loadScript src="resource:///org/richfaces/renderkit/html/scripts/scriptaculous/effects.js" /> <a4j:outputPanel ajaxRendered="true"> <h:messages /> </a4j:outputPanel> <h:form id="form" > <a4j:status startText="START" startStyle="color: red;" stopText="STOP" stopStyle="color: green;" /> <br /> <h:panelGrid columns="2" columnClasses="columnClass"> <h:panelGroup> <ol:orderingList value="#{bean.simpleItems}" var="item" controlsType="link"> <h:column> <f:facet name="header"> <h:outputText value="Name" /> </f:facet> <h:outputText value="#{item}" /> </h:column> </ol:orderingList> </h:panelGroup> </h:panelGrid> <h:commandButton value="Submit" /> </h:form> </f:view> </body> </html>
-
17. Re: Ordering bean values using rich:orderingList
nbelaevski May 22, 2009 5:25 PM (in response to rubenrjorge)Scott,
Can you please try this example without Trinidad filter? -
18. Re: Ordering bean values using rich:orderingList
rubenrjorge May 24, 2009 11:49 AM (in response to rubenrjorge)Any ideas on this please? I can't get this to work and apparently I'm not the only one having problems.
Thanks in advance,
~Ruben -
19. Re: Ordering bean values using rich:orderingList
nbelaevski May 25, 2009 6:51 AM (in response to rubenrjorge)"rubenrjorge" wrote:
Any ideas on this please? I can't get this to work and apparently I'm not the only one having problems.
Thanks in advance,
~Ruben
Hi Ruben,
Can you please create small demo project showing the issue and post it somewhere (e.g. on sendspace.com)? -
20. Re: Ordering bean values using rich:orderingList
rubenrjorge May 25, 2009 7:45 AM (in response to rubenrjorge)Thank you for your time nbelaevski.
I compiled the files and you can get them here: http://dl.getdropbox.com/u/772871/lists.zip
It contains the JSP, bean, object class, converter, web.xml and faces-config.xml
Please let me know if you find anything. Thanks in advance. -
21. Re: Ordering bean values using rich:orderingList
nbelaevski May 25, 2009 10:10 AM (in response to rubenrjorge)Ruben,
rich:orderingList doesn't modify original list, but creates new one. Created list is incompatible with Vector type. All is working good after I've replaced Vector with List/ArrayList:package solap.bean; import java.util.ArrayList; import java.util.List; import javax.annotation.PostConstruct; import solap.entities.SOLAPAttribute; public class MatrixBean { private List<SOLAPAttribute> attributes; public List<SOLAPAttribute> getAttributes() { return attributes; } public void setAttributes(List<SOLAPAttribute> attributes) { this.attributes = attributes; } @PostConstruct public void init() { attributes = new ArrayList<SOLAPAttribute>(); attributes.add(new SOLAPAttribute("1", "AAA", "3", "1")); attributes.add(new SOLAPAttribute("2", "BBB", "2", "1")); attributes.add(new SOLAPAttribute("3", "CCC", "2", "1")); attributes.add(new SOLAPAttribute("4", "DDD", "2", "1")); } }
-
22. Re: Ordering bean values using rich:orderingList
rubenrjorge May 25, 2009 10:24 AM (in response to rubenrjorge)Thank you again nbelaevski!
I changed the type as you said and it works. There is a bug somewhere however:
If I set an order and click the submit button, the list is rendered correctly. But if click the submit button a second time (re-ordering or not), an error is displayed:java.lang.IllegalStateException: solap.entities.SOLAPAttribute at javax.faces.component.StateHolderSaver.restore(StateHolderSaver.java:109) at javax.faces.component.UIComponentBase.restoreAttachedState(UIComponentBase.java:1430) at org.richfaces.component.UIOrderingList$ValueHolder.restoreState(UIOrderingList.java:196) at org.richfaces.component.UIOrderingList.restoreState(UIOrderingList.java:730) at org.richfaces.component.html.HtmlOrderingList.restoreState(HtmlOrderingList.java:1397) at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1155) at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1171) at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1171) at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1171) at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1171) at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1171) at org.ajax4jsf.application.AjaxStateManager.restoreView(AjaxStateManager.java:439) at com.sun.faces.application.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:318) at org.ajax4jsf.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:107) at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:176) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100) at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:104) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178) at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290) at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368) at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(Unknown Source) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Any idea why this happens? -
23. Re: Ordering bean values using rich:orderingList
nbelaevski May 25, 2009 11:02 AM (in response to rubenrjorge)That happens because items representing selection could not be restored. Add default no-arg constructor to SOLAPAttribute and make it Serializable.
-
24. Re: Ordering bean values using rich:orderingList
rubenrjorge May 26, 2009 1:51 AM (in response to rubenrjorge)Problem solved, thank you very much once again!
-
25. Re: Ordering bean values using rich:orderingList
scott.farley May 27, 2009 6:19 PM (in response to rubenrjorge)I removed the Trinidad filters as suggested and found no change. After slimming down the configuration (web.xml) many times over I realized one difference was the "javax.faces.STATE_SAVING_METHOD" parameter. I was using client-side state saving. Even though I did not have Trinidad configured the Trinidad libraries were still in the classpath and got bootstrapped through a configuration listener. It seems that when Trinidad's token based, client-side saving is in use the list returned from the orderingList component is not correct. When I switched to either server-side state saving or the client-side state saving method (org.apache.myfaces.trinidad.CLIENT_STATE_METHOD) of "all" the orderingList component seems to act correctly.