Dynamic Id's in JSF/Seam

后端 未结 3 1863
一个人的身影
一个人的身影 2020-12-10 18:21

Got a little problem with a Seam application I\'m working on and I was wondering if anyone knows a way round it. I\'ve got a form in my application that uses AJAX to show c

3条回答
  •  长情又很酷
    2020-12-10 18:58

    I'm assuming you want to control the ID of your input component so you can reference it later in Javascript?

    Since you can't set the ID via an expression, I do this:

    
    

    Then later in the code:

    
    

    In the pagecode:

    protected HtmlInputText getWhatever() {
        if (whatever == null) {
            whatever = (HtmlInputText) findComponentInRoot("whatever");
        }
    }
    
    public String getWhateverClientId() {
        return getWhatever().getClientId(getFacesContext());
    }
    

    Hope that helps.

提交回复
热议问题