Skip navigation.
Home

null value returned from jsf component

salam 3alekom,

i have a page that have some components its count is known only in runtime, i'm trying to get the title of each component (<h:selectOneListbox title="#{mcqVar[11]}">) from my back bean but it always gets null (null value is returned)

here is the jsf code

**the if conditions is a check on null values

<h:panelGrid  binding="#{Answers.pnlGrid1}">
<c:forEach  var="mcqVar" items="#{QuestionnaireBean.mcq}" >
                        <h:outputText value="#{mcqVar[0]}" />                        
                        <h:selectOneListbox title="#{mcqVar[11]}">
                            <c:if test="${ not empty mcqVar[1]}" var="test">                                
                                <f:selectItem itemValue="1" itemLabel="#{mcqVar[1]}"/>
                            </c:if> 
                            <c:if test="${ not empty mcqVar[2]}" var="test">                  
                                <f:selectItem  itemValue="2" itemLabel="#{mcqVar[2]}"/>
                            </c:if>
                            
                            <c:if test="${ not empty mcqVar[3]}" var="test">                  
                                <f:selectItem itemValue="3" itemLabel="#{mcqVar[3]}"/>
                            </c:if>
                            
                            <c:if test="${ not empty mcqVar[4]}" var="test">                  
                                <f:selectItem itemValue="4" itemLabel="#{mcqVar[4]}"/>
                            </c:if>
                            
                            <c:if test="${ not empty mcqVar[5]}" var="test">                  
                                <f:selectItem itemValue="5" itemLabel="#{mcqVar[5]}"/>
                            </c:if>
                            
                        </h:selectOneListbox>
 </c:forEach> 
</h:panelGrid>

and this is my action method code

List list = pnlGrid1.getChildren();
for (int i = 0; i < list.size(); i++) {
            UIComponent comp = (UIComponent) list.get(i);
            System.out.println("family is " + comp.getFamily());
            if (comp.getFamily().equals("javax.faces.SelectMany")) {
                listbox = (HtmlSelectManyListbox) comp;
String title=listbox.getTitle();// always gets null
System.out.println(title); // nothong printed
 
            } else if (comp.getFamily().equals("javax.faces.SelectOne")) {
                oneMenu = (HtmlSelectOneListbox) comp;
String title=oneMenu.getTitle();// always gets null
System.out.println(title); // nothong printed
 
            } else if (comp.getFamily().equals("javax.faces.Input")) {
                txtarea = (HtmlInputTextarea) comp;
String title=txtarea.getTitle();// always gets null
System.out.println(title); // nothong printed
            }
        }
 

thanks in advance

we 3alikom assalam i think

we 3alikom assalam

i think that link may be helpful:

https://bpcatalog.dev.java.net/webtier/accessing-uicomponents/index.html