java - Primefaces dynamic columns, programatically -
i'm in process of rewriting (very) big , old richfaces application using primefaces. have situation 2 lists, 1 column names , 1 objects should represented rows.
the object looks this:
public class averygenericthingthatidonotlike { object[] values; //other parameters dont care }
when should display want map values[0] first column, values[1] second , forth.
i have looked @ primefaces showcase , there example of dynamic columns have tried , can not work when not know columns can exist. reason not know columns decided database holds row saying columns should exist , can change, can not build class have columns available in showcase example.
can give me pointers here? i've been stuck on few days , need help.
edit: kinda working solution laabidi raissi. problem columns want have buttons being rendered , command links. approach able strings , if try return objects commandbuttons print java object hash.
any ideas on this?
if using jsf2, think solution may work you. first, in managed bean, build list of columns (dynamically) db, , then:
<p:columns value="#{yourmanagedbean.listofcolumnsfromdb}" var="column" columnindexvar="colindex"> <f:facet name="header"> #{column}</f:facet> <h:outputtext value="#{yourmanagedbean.values[colindex]}" /> </p:columns>
edit: base on comment, think adding commandbutton
or outputlink
obvious (instead of outputtext
):
<h:commandbutton value="#{yourmanagedbean.values[colindex]}" action="#{yourmanagedbean.someactionthattakesaparam(colindex)}" rendered="#{colindex == 4}"/>
supposing want commandbutton in column 5.
is looking ?
hope helps
Comments
Post a Comment