7 Replies Latest reply on Feb 22, 2011 11:25 PM by Nick Belaevski

    form and "rendered" problem

    Jiri Chaloupka Newbie

      Hello,

      i have following code:

       

        <a4j:form>

                          <h:inputHidden id="id" value="#{workerProfileBean.id}"/>

                          <h:inputHidden id="workerId" value="#{workerProfileBean.workerId}"/>

                          <h:panelGrid id="progform" columns="7" width="100%" rendered="#{workerProfileBean.displayProgKnowledgeForm}">

       

      .....

       

         <h:panelGroup>

          <rich:spacer width="10"/>

          <a4j:commandButton value="#{messages.saveworker_submit}" action="#{workerProfileBean.saveProgKnowledge}" styleClass="submitButton" />

         </h:panelGroup>

                          </h:panelGrid>

                          </a4j:form>

       

      panelGrid is displayed, because #{workerProfileBean.displayProgKnowledgeForm} contains true.

      But, whet I press commandButton, method #{workerProfileBean.saveProgKnowledge} is not called.

       

      But, if I will "hardcode"

      <h:panelGrid id="progform" columns="7" width="100%" rendered="true">

      ...

      then everything works good.

      If I will use h:form instead of a4j:form, it is the same.

      Using RF 3.3.3, jdk 1.6_23, JBoss 5.1

       

      Where is my mistake, what I understand wrong?

       

      Thank you

      Jiri

        • 1. form and "rendered" problem
          Vinicius Carvalho Newbie

          What is the scope of your bean?

          If request scope, you need to save the state of the bean using <a4j:keepAlive/> or save the state of the Boolean attribute using <t:saveState/> or extend the scope of your bean.

          • 2. form and "rendered" problem
            Jiri Chaloupka Newbie

            extending the scope causes much more problems...

             

            The mbean is request scope. Some data are stored in session and mbean manage these data (save, erase from session, change data etc.)

             

            If I change the scope to session, then:

            - pressing button causes

            22:59:48,756 ERROR [STDERR] java.lang.IllegalStateException

            22:59:48,756 ERROR [STDERR]           at com.sun.faces.context.FacesContextImpl.assertNotReleased(FacesContextImpl.java:395)

            22:59:48,756 ERROR [STDERR]           at com.sun.faces.context.FacesContextImpl.getExternalContext(FacesContextImpl.java:147)

            22:59:48,756 ERROR [STDERR]           at cz.chalu.hrp.faces.BaseServlet.getResponse(BaseServlet.java:32)

            where cointains code:

            (HttpServletRequest)getContext().getExternalContext().getRequest();

             

            next,

            Caused by: java.lang.NullPointerException

                      at org.apache.catalina.connector.Request.setAttribute(Request.java:1443)

                      at org.apache.catalina.connector.RequestFacade.setAttribute(RequestFacade.java:503)

                      at cz.chalu.hrp.faces.BaseServlet.storeErrorMessage(BaseServlet.java:72)

            where

            protected void storeErrorMessage(String messageKey){

                                errorMessage = mf.getMessage(messageKey);

                                getRequest().setAttribute("errorMessage", errorMessage);

                      }

            code is.

             

            And  next problem is, that when I want to load another profile with another data, data from the first profile is displayed.

             

            So generally, I dont like this way very much, looks that extracting this form from this page is better. But, is there what I understand wrong, eg. if I use something by wrong way?

            • 3. form and "rendered" problem
              Vinicius Carvalho Newbie

              What versions are you using?

               

              Rich 3.x and JSF1.2, rich 3.3 and JSF2 or rich4 and JSF2?

              • 4. form and "rendered" problem
                Jiri Chaloupka Newbie

                Rich 3.3.3 and JSF 1.2:

                2011-02-21 19:54:03,386 INFO  [org.jboss.web.tomcat.service.deployers.TomcatDeployment] (main) deploy, ctxPath=/

                2011-02-21 19:54:03,612 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (main) Initializing Mojarra (1.2_12-b01-FCS) for context ''

                2011-02-21 19:54:10,071 WARN  [org.ajax4jsf.webapp.BaseXMLFilter] (main) This version of RichFaces implementation compatible for JSF2.0, but running under JSF1.2

                 

                I tried to switch to JSF2.0, but didn't find the way, still have this log message.

                • 5. form and "rendered" problem
                  Ilya Shaikovsky Master

                  1) rendered should be kept between requests so you have to deal with the other problems. Maybe just expose the view properties to separate session scoped controller and remain the data in request.

                   

                  2)

                  2011-02-21 19:54:10,071 WARN  [org.ajax4jsf.webapp.BaseXMLFilter] (main) This version of RichFaces implementation compatible for JSF2.0, but running under JSF1.2

                  which richfaces-impl you added? for JSF 2 you should add the only richfaces-impl-jsf2.jar and not the richfaces-impl. (Both also should not be added.)

                  • 6. form and "rendered" problem
                    Jiri Chaloupka Newbie

                    hmmm

                    ok. I switched application to JSF 2.0, but for this, I had to use JBoss 6.

                    JBoss 5.1 server with my application started at 1 minute, JBoss 6 with my app needs 10 minutes. I do not understand what happens with small light application server ... but it is not for this phorum, sorry.

                     

                    So I will return to JSF 1.2, even some things are not working, eg. navigation. Maybe when RF4 will be done, maybe with some new version of JBoss...

                     

                    OK, thank you

                    Jiri

                    • 7. form and "rendered" problem
                      Nick Belaevski Master

                      Hi Jiri,

                       

                      You are calling FacesContext methods after it has been released from inside your servlet. Why use FacesContext? Call Servlet API directly.