簡體   English   中英

從輔助bean訪問JSF組件標記屬性值

[英]Accessing JSF components tag attribute values from a backing bean

我需要訪問組件標記屬性,如:

<h:inputtext id="input_age"/>

來自支持bean,如:

public class UserInfo {
    String inputAgeId;
    public UserInfo() {
        inputAgeId = { /*code to access component tag attribute*/ }.getStyleClass();
    }
}
UIViewRoot view = FacesContext.getCurrentInstance().getViewRoot();

然后,您可以使用view.find(“component_id”)來獲取正確的組件。 獲得組件后,可以使用getAttributes()獲取具有組件所有屬性的Map<String, Object>

如果您總是訪問相同的競爭對手,則可以將其綁定到支持bean

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM