1

When the dropdown element is selected, I want to make the inputtext enable in JSF.

<h:selectOneMenu value="#{country.val}" valueChangeListener="#{country.comboChange}">

    <f:selectItems id="musti" value="#{country.authenticationAlgoritms}"/>
    <a4j:support event="onchange" ajaxSingle="true" reRender="musti3"/>
</h:selectOneMenu>

<h:inputText id="musti3" disabled="#{not(country.val == 'SHA256')}"/>

@ManagedBean(name="country")
@SessionScoped
public class UserBean implements Serializable{

    private static final long serialVersionUID = 1L;
    private String val;
    private boolean booleanValue;


    public void setVal(String val) {
        this.val = val;
    }
    public String getVal(){
        return val;
    }
    public boolean isBooleanValue() {
        return booleanValue;
    }

    public void setBooleanValue(boolean booleanValue) {
        this.booleanValue = booleanValue;
    }
    public void comboChange(ValueChangeEvent e){

        String s = e.getNewValue().toString();
        if(s.equals("SHA256")){
            setVal("SHA256");
        }
        FacesContext.getCurrentInstance().renderResponse();
    }
    public ArrayList<String> getAuthenticationAlgoritms() {

        ArrayList<String> arr = new ArrayList();
        arr.add("NONE");
        arr.add("SHA256");
        return arr;
    }
}
Kukeltje
  • 12,223
  • 4
  • 24
  • 47
  • Ola, there were two mistakes in your question which I have corrected: 1) this is not a combobox, this is a dropdown and 2) this is not PrimeFaces, this is RichFaces. Thanks. – BalusC Jun 13 '19 at 11:02
  • And the actual problem and/or behaviour is? ('it does not work like I want to' is not the right answer ;-)) – Kukeltje Jun 13 '19 at 12:13
  • Wrap your `inputText` in `h:panelGroup` with some id (or move "musti3" on that level) and re-render this `h:panelGroup`. – Vasil Lukach Jun 13 '19 at 15:20
  • @VasilLukach: why is this needed? It is not about https://stackoverflow.com/questions/14790014/ajax-update-render-does-not-work-on-a-component-which-has-rendered-attribute – Kukeltje Jun 13 '19 at 15:33
  • I did not downvote yet, but please read http://idownvotedbecau.se/beingunresponsive (I've seen you've been online the last hour). Responding to comments shortly afer asking a good question is good practice. – Kukeltje Jun 13 '19 at 15:36
  • @Kukeltje You are right. It is not needed for disabling field. It needed in case when field should be hidden/displayed. I didn't pay attention on current version of code. – Vasil Lukach Jun 13 '19 at 17:15

0 Answers0