0

This Question is a follow up to JSF Primefaces Radio Button show/hide/enable a textarea One of the two problems were solved from that Post by wrapping the inputTextArea in a panelGroup, however I still need to figure out how to not show the inputTextArea on form load when the status is a 2 (=No), but only show when the radio under column 2 is being toggled.


enter image description here

    <p:column ...>
        <p:selectOneRadio ...>
        ...
            <p:ajax update="reason" />
        </p:selectOneRadio>
    </p:column>
    <p:column headerText="Reason For Attribute Failure">
      <h:panelGroup id="reason">
        <h:inputTextarea value="#{qAndA.fail_reason}" rendered="#{qAndA.toggle_value == '2'}" />
      </h:panelGroup>

        <h:outputText value="" rendered="#{qAndA.toggle_value == '1' or qAndA.toggle_value == '3'}" />
     <h:outputText value="#{qAndA.fail_reason}" rendered="#{qAndA.toggle_value == '2' or qAndA.toggle_value == '4'}" />

    </p:column>

perhaps the status codes are flawed:

  • 0 = no input yet
  • 1 = yes
  • 2 = no, with a reason
  • 3 = Not Applicable
  • 4 = the No was eventually resolved

I'd rather not have to modify the status codes but adding another intermediate code, something like this would probably work:

  • 2 = show reason box
  • 2.5 means no with a reason

Any other options besides modifying status code?

Community
  • 1
  • 1
jeff
  • 3,618
  • 9
  • 48
  • 101
  • I read your profile. Since when are you learning jsf / java ? I'm also relying on internet/SO to learn (I think every developper does learn on his own actually). Anyway I'm kinda alone on this path. Maybe it would be cool to start a skype group or something with some SO users. – Ced Sep 13 '15 at 00:53

1 Answers1

0

Well the real answer is to not have the value at 2 when the bean is loaded if you want to not display it. But you already know that. What you are asking is subjective to you and how you wanna do things. You have no issue and this is more a design question. Having said that here is one:

Maybe you'd like to have 2 conditions :

<h:inputTextarea value="#{qAndA.fail_reason}" rendered="#{qAndA.toggle_value == '2' and bean.AnotherCondition}" />

If you wanna get fancy make a @ViewScoped bean that listen for the click you were talking about in your post ( not sure what the click does). Listen for the click and have a boolean property you can set to true once the click has been registered (maybe with an action listener). This way the textarea will only show when clicked.

Ced
  • 15,847
  • 14
  • 87
  • 146