Hi all,

I have a profile structure editor, where I can choose different Values
and add them to a list. Each property of such a profile can have
different datatypes like String, Address(contains street, city, zip
code), CreditCard (owner, number ...)  and so on.

After this profile structure is saved I want to display the profile in
the normal known way with

<label>: <InputFields>

Inputfields would be in case of a String simply an inputText, in case of
an address several new label with their inputFields.

street: <inputText>
zip code: <inputText>
city: <inutText>

So  tried something like that


<ui:repeat value="#{controller.profileStructure}" var="prop">
  <c:choose>
    <c:when test="prop.isString">
      DISPLAY STRING STUFF
    </c:when>
    <c:when test="prop.isAddress">
      DISPLAY ADDRESS STUFF
    </c:when>
    <c:otherwise>
      UNKNOWN TYPE!
    </c:otherwise>
</ui:repeat>

After a long time of trying I just realised, that this will never work,
because the test of the jstl stuff is calculated ONCE before rendered.
But in this case, prop is null and so it cannot be used. (I chosed this
was first, because you have an otherwise and can see, if a type
implementation is missing.

But next try, using the jsf rendered attribute:

<tr jsfc="ui:repeat" value="#{controller.profileStructure}" var="prop">

  <h:panelGroup rendered="#{prop.isString}">
    <!-- display label -->
    <td>
      <span jsfc="h:outputLabel" value="#{prop.name}" />
    </td>
    <td>
      <span jsfc="h:inputText" value="#{prop.value}" />
    </td>       
  </h:panelGroup>

  <h:panelGroup rendered="#{prop.isAddress}">
    <!-- display label -->
    <td>
      <span jsfc="h:outputLabel" value="#{prop.name}" />
    </td>
    <td>
      <!-- Display Address as a block -->
      <table>
        <tr>
          <td>
            Street:
          </td>
          <td>
            <span jsfc="h:inputText"
value="#{prop.value.street}" />                           </td> 
        </tr>
        [.. Display other fields of address ..]
      </table>
    </td>
  </h:panelGroup>
</tr>

BUT,.... (argh!!)

I had already read in this list, but have not remembered, also the parts
are not rendered the are also interpreted, so also I want to display a
String value, the template tries to <string-value>.street and that
throws an exception.


Back to my question: How can I do just a functionality? I cannot have a
conditional statement and I am not able to not render stuff. What else
can I do?


Thanks in advance for your help,

Stefan

Attachment: pgp5NwHAjzuIC.pgp
Description: PGP signature

Reply via email to