开发者

How to Assign id dynamically in JSf to Datatable column

Hi please check below code for your reference.

                                    <%
                                        System.out.println("Here???????? 111111 :::::::::::::: "+request.getAttribute("COLUMNSIZE"));

                                        if(request.getAttribute("COLUMNSIZE") != null){

                                            int columnSize = 0;
                                            columnSize = Integer.parseInt(request.getAttribute("COLUMNSIZE").toString());
        开发者_StackOverflow社区                                    System.out.println("Here 111111 :::::::::::::: "+columnSize);

                                            for(int loop=0 ; loop < columnSize ; loop++){
                                    %>

                                    <h:column>
                                        <f:facet name="header" >
                                            <h:outputText value="Field <%=loop%>">
                                            </h:outputText>
                                        </f:facet>
                                        <h:outputText value="Password" />
                                    </h:column>

                                    <%
                                        }
                                        }
                                    %>

                                </h:dataTable>

Now what i want to is that I want to assign id to column dynamically using loop variable ... but scriplets is not allowed and I cant found any other way for it.

So if any of you have idea about it then please reply me quickly.


If I read your question right you want to change the number of columns of your dataTable dynamically (I may be wrong).

If you're on icefaces or richfaces why don't you make use of ice:columns or rich:columns?


Scriplets shouldn't be mixed up with JSF expressions. Below code can be used to achieve what you already trying, placing logic in backing bean & looks more readable.

<ui:repeat value="#{backingBean.headerNames}" var="header">
                 <li> 
                      <h:outputText value="#{header.field}" />
                 </li> 
</ui:repeat>

For further details, go through JSF EL Documentation


May be its work.

HtmlOutputText test = new HtmlOutputText();
test.setValue("test");

HtmlDataTable dataTable = new HtmlDataTable();
dataTable.getChildren().add(test);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜