3 Replies Latest reply on Sep 17, 2008 5:52 PM by guy bashan

    Evaluate facelets parameter in java

    guy bashan Apprentice


      I am having a problem evaluating facelets parameter in Java code.
      I have this simple component:

      <span xmlns="http://www.w3.org/1999/xhtml"

      I am calling it:

      <s:testcomp test="4" />

      The output in the page is: 4.

      the function test in the bean looks like:

      Object value = Expressions.instance().createValueExpression("#{test}").getValue();

      The value in the java code is always null.
      How can I evaluate facelets parameter?

        • 1. Re: Evaluate facelets parameter in java
          guy bashan Apprentice

          Does anyone know about this problem? Any idea for a workaround?

          • 2. Re: Evaluate facelets parameter in java
            Samuel Mendenhall Apprentice

            The test variable will live in a different VariableMapper (in the FaceletContext) than what you are evaluating which occurs in the FacesContext.  So you have 2 options:

            1. Access #{test} inside of a Facelet TagHandler

            2. Create a TagHandler which sets the test variable in the FacesContext

            I don't quite understand what:


            does consider it would evaluate for example to personBean.get4() ? since your test="4".  You could always do something like:


            which would pass that value to someMethod.

            • 3. Re: Evaluate facelets parameter in java
              guy bashan Apprentice

              I used this:


              just as a dummy to activate the test method and being able to examine the EL expression in Java code.
              Actually I am trying to get the facelets parameter in a getter of a value passed to a dataTable, therefore, I won't be able to send a parameter (your suggestion).

              The truth is, I took the time to get rid of all the java code and did all the work in XHTML file in order to workaround this problem.

              But question still remains and is very simple:
              How can a facelets parameter can be extracted in Java code (using EL)?