9 Replies Latest reply on Jul 5, 2010 11:52 AM by Jurij Lender

    Problem with h:commandButton and rendered attribute

    giuseppe naddeo Newbie

      Hi


      I have a very simple page with a form:


      <h:form id="test">          
        <h:commandButton id="btn1" action="#{advManager.insert}" rendered="#{empty param.mode or param.mode == 'ins'}" image="images/ins.jpg"/>
        <h:commandButton id="btn2" action="#{advManager.update}" rendered="#{param.mode == 'edit'}" image="images/mod.jpg"/>
      </h:form>
      


      the associated pageflow is:



      <navigation from-action="#{advManager.insert}">
        <rule if-outcome="inserted">
          <redirect view-id="/upload.xhtml"/>
        </rule>
      </navigation>
      <navigation from-action="#{advManager.update}">
        <rule if-outcome="updated">
          <redirect view-id="/confirm.xhtml"/>
        </rule>
      </navigation>
      



      First time I reach this page (/edit.jsf or /edit.jsf?mode=ins), only the first button (btn1) is showed and everything goes ok: insert method is activated and upload page is showed.


      When I reach this page a second time for update (/edit.jsf?mode=edit), only the second button (btn2) is showed but if I clik it the page is reloaded and nothing else happens.


      It seams that param in rendered attribute causes some problem. In fact if I write explicitly


      rendered="true"



      everything works. (I always see 2 buttons of course)
      This let me think advManager component, methods and pageflow are right.


      I'm also supposing something very similar happens the first time on insert. but seams can however evaluate


      empty param.mode



      and goes on in activating insert method.


      I'd like to know your opinion.
      thanks


      env:

      richfaces 3.2.2.SR1

      jboss-seam-2.1.1.GA

      jboss-4.2.3.GA