3 Replies Latest reply on Feb 17, 2012 3:52 AM by giant2

    Passing parameters between xhtml and beans

    giant2

      Hi! I have a problem passing parameter between xhtml file and beans.

      An xhtml file has a component declared (for simplicity we call it "PIPPO") and in another xhtml file I use PIPPO:

      ...

      <mytag:PIPPO>

           <ui:param name="pluto" value="main" />

      </mytag:PIPPO>

      ...

       

      PIPPO component is like this:

      ...

      <h:outputText value="Here we are: #{pluto}" />

      ...

      <... rendered="myBean.render('#{pluto}')"...>

      ...

       

      and the method is:

      public boolean render(String whoAreYou){

           System.out.println("calling render by:"+whoAreYou);

           return true;

      }

       

      I see in the debug console all the traces are like:

      calling render by:#{pluto}

      but I was waiting there'll be: calling render by:main

       

      I believe the problem was the calling of method, so I tryed to use myBean.render(#{pluto})

      but it doesn't go and have a compilation error.

       

      HELP please! How can I passing the parameter value?!?!?!?!?!?

        • 1. Re: Passing parameters between xhtml and beans
          zeeman

          First call your back-end bean with a hard-coded string myBean.render('#{'pluto'}')" to assure the back-end works. Once that works, try to use the page param so you can isolate the problem.

           

          I pass params among pages using <ui:param name="someName" value="#{value}" />

           

          That works for me. Seems like your PIPPO component is culprit.

          • 2. Re: Passing parameters between xhtml and beans
            giant2

            Thanks for the answer, but I did it and see the back-end is called with the string #{pluto} and not, as I expecting, the string main.

            It seems the translation from #{pluto} to its value isn't done in calling method because I try to outputText this #{pluto} and see correctly the string "main".

            It could be a bug or a different behaviour of the engine?

            I hope in the engine so maybe there is some pattern/regular expression to use doing what I need, isn't it?

            • 3. Re: Passing parameters between xhtml and beans
              giant2

              I solved!

              Using a parameter retrieved like the mine #{pluto} in a method call, it's not necessary to specify the syntax #{pluto}.

              I explain me better:

              my #{pluto} and the calling method <... rendered="myBean.render('#{pluto}')"...>

              in this scenario it must be:

              <... rendered="myBean.render(pluto)"...>

              because the context in witch pluto is called is a method and not the page.

               

              Thanks to zeeman. Your suggestion myBean.render('#{'pluto'}')" with too many ' put me in the correct way.