3 Replies Latest reply on Mar 22, 2012 7:48 AM by giant2

    if and choose unusable in rich:dataTable

    giant2 Newbie

      Hi all!

      Another strange thing for today!

      I must create a table formed by 3 columns:

      The first one is a label, the second one is a label, the third in a "special one". In this column I want to display a label following a rule on the bean.

      To do this last feature I try to use a choose/when/otherwise construct like the following:


           <c:when test="#{bean.theTest=='ONE'}">

                <h:outputText value="This is well covered" />


           <c:when test="#{bean.theTest=='TWO'}">

                <h:outputText value="This is covered" />



                <h:outpuText value="This is uncoveder" />




      So the xhtml is about:

      <rich:dataTable value="#{beanContainer.getBeans()}" var="bean">


                <f:facet name="header">Surname</f:facet>

                <h:outpuText value="#{bean.surname}" />



                <f:facet name="header">Name</f:facet>

                <h:outpuText value="#{bean.name}" />



                <f:facet name="header">Status</f:facet>





      The strange thing is that everytime the third column is "This is uncovered", so the otherwise option (but following data used in the where-test tell different thing. I tryed to display the value I test in the otherwise option and (as told before) I see the bean.theTest has a value of "ONE" or "TWO", so no otherwise whould follows! I do not understand!!!


      I use the same piece of code in another xhtml of my project and all goes ok.

      I even tryed to put an outputText with the result of the test and see it is correctly true or false following the data. But when it is used in the when-clause it goes KO!


      The only difference between these two is that when is ok the choose is used in a s:div, but it doesn't function when it is used in a rich:dataTable and rich:extendedDataTable.

      So I suspect it is a richfaces behavior.


      P.S. The same thing is for "if" constructor. Seems test-clause is ignored!!! WHY!??!?!?!??

        • 1. Re: if and choose unusable in rich:dataTable
          Christian Peter Expert

          Just use the rendered attribute of your h:outputText components!

          <h:outputText value="blah" rendered="#{myTestValue eq 'hello'}"/>


          or ui:fragment rendered=...

          1 of 1 people found this helpful
          • 2. Re: if and choose unusable in rich:dataTable
            giant2 Newbie

            Thanks Christian, but your solution is applicable only for "simple" layouts. If I must test many things before create the outoutText or inputText or comboBox or... it's very hard to apply. (I post a simple example of the problem for simplify the comprehension)

            But my doubt is that I use THE SAME code in another piece of my xhtml project and goes ok, why in this situation (with <rich:... and not with <s:div...) it doesn't work?


            Be or not to be, that's the question!


            • 3. Re: if and choose unusable in rich:dataTable
              giant2 Newbie

              find the problem.

              richtable execute and create a table structure, the table is populated with data only in another time. In the moment table create the structure c:if/choose/when are executed, but in my case they doesn't meet any data because is present only the table structure.

              So I cannot test the data in the cell for making a particular choice.


              Intead of using the richtable now I use a simple table and all goes even if there are some problem on the foreach I use to ciclyng over the data visualized.


              So if you mixes richfaces and jstl pay attention about this thing. Data where jstl can use are only "simple" and not linked to richfaces manipulated.