2 Replies Latest reply on Oct 26, 2007 3:48 PM by bludkiewicz

    Passing dynamic values to enhanced el expression

    bludkiewicz

      Hi all,

      I have a button whose value I'm trying to pass to my bean using Seam's enhanced EL. Below is a snippet from my xhtml page:

      <h:form>
       <c:forEach var="answer" items='#{ testing.test.currentQuestion.answers }'>
       <h:commandButton value='#{ answer.name }' action='#{ testing.scoreQuestion( answer.name ) }' />
       </c:forEach>
      </h:form>
      


      This will always pass a null reference to the testing.scoreQuestion( String ) method. I have also tried #{ testing.scoreQuestion( ${answer.name} ) } and #{ testing.scoreQuestion( #{answer.name} ) } but I get errors as it tries to evaluate #{${answer.name}} and #{#{answer.name}}, respectively. So, if that's the case then why is #{ answer.name } evaluating to null for the action yet the button renders with the proper value of #{ answer.name }? Is there another way of accomplishing this or am I just missing something obvious? Any help would be appreciated.

      Thanks,
      -=B=-

        • 1. Re: Passing dynamic values to enhanced el expression
          pmuir

          The only way to use el enhancements inside an iterator is to use a datatable - and even that functionality is under debate. Better to use page parameters.

          • 2. Re: Passing dynamic values to enhanced el expression
            bludkiewicz

            Yeah, I eventually stumbled upon the dataTable. Using it, I was able to pass the correct value to my backing bean. The only problem is I need to have a new column for every entry in my Collection instead of a new row.

            Then I found <ui:repeat>. It passed the correct value to my backing bean as well _and_ I was able to align my buttons horizontally with it! Joy!

            One question (or clarification) though, you mentioned "even that functionality is under debate." Can you elaborate?

            Thanks,
            -=B=-