-1

I have an existing form that has a radio select button. What I wanted is, whenever the user makes a choice of selecting any one value, either an input text box or a hyperlink should be displayed on the same form.

I think I am on the right track of using ajax to do this. However, I came up with the below code, but it is not updating the form on selecting any of the radio value:

Note: I am showing only what should happen on selecting only one of the value in the radio to keep things little clean.

<tr>
  <td><ice:outputLabel value="Agenda Type" styleClass="mandatory"/></td>
  <td>                
      <h:selectOneRadio id="agenda_type" action="#{eventManagementController.radioVal}" required="true" label="Action">
        <f:selectItem itemValue="standard" itemLabel="Standard"/>
        <f:selectItem itemValue="normal" itemLabel="Normal"/>
        <f:ajax process="console" event="click" update="display" />                                            
      </h:selectOneRadio>                                                                               
  </td>
  <td>
    <ice:message for="agenda_type" errorClass="error"/>
  </td>
</tr>

<tr>
  <td>
       <ice:outputLabel value="Standard Agenda" rendered="#{eventManagementController.radioVal eq 'standard'}"/>
  </td>
  <td>                       
     <h:commandLink id="display" immediate="true" rendered="#{eventManagementController.radioVal eq 'standard'}"
     action="#{eventManagementController.goToAgendaDetailsPage}" value="Enter Details">
     </h:commandLink>      
     <br/>
  </td>               
</tr>

There are controllers defined to store the value of the radioVal as:

public String getRadioVal() {
    return radioVal;
}

public void setRadioVal(String radioVal) {
    this.radioVal = radioVal;
}
Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Pankaj
  • 346
  • 1
  • 3
  • 14
  • Which tag in your xhtml has id="agendafileupload" and which one has id="console"? – Raztyck Nov 21 '19 at 16:54
  • @Raztyck edited the question. – Pankaj Nov 21 '19 at 17:06
  • When you try to process component with id "console", then JSF will send data from that component. Are you doing it on purpose? If no, then you should change that 'console' to '@this' to send data from selectOneRadio to bean. That propably will help you, but if no, please tell: what version of jsf are you using? – Raztyck Nov 21 '19 at 17:19
  • Does this answer your question? [Understanding PrimeFaces process/update and JSF f:ajax execute/render attributes](https://stackoverflow.com/questions/25339056/understanding-primefaces-process-update-and-jsf-fajax-execute-render-attributes) – Kukeltje Nov 22 '19 at 00:20

1 Answers1

0

Try adding render in the f:ajax, like this:

process="console" event="click" update="display" render="display"

This will force to render the command link on client side, hope it helps.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
  • Please read the link in my comment above carefully. Your answer contains multiple errors. Effectively this question a duplicate of that – Kukeltje Nov 22 '19 at 07:39