Datatable with static/dynamic editable columns not working

UI Components for JSF
Post Reply
dragon4109
Posts: 6
Joined: 02 Dec 2011, 15:23

05 Dec 2011, 23:32

I am trying to build an editable data table with dynamic columns in PrimeFaces 3.0. The column names and its choice list comes from the database. I also have few static columns in this table in the following order.

1. Selector (Checkbox)
2. Row no. (Plain Text)
3. Static column. (Read only)
4. Status column (Editable)
5. Dynamic columns. Editable
6. Static column (Editable)
7. Edit option

Here is the markup:

<p:dataTable id="blocksTable" var="block"
value="#{blockAttributesBean.blockDataModel}"
rowIndexVar="rowIdx" resizableColumns="true"
selection="#{blockAttributesBean.selectedBlocks}">
<p:column selectionMode="multiple" />
<p:column headerText="No.">
#{rowIdx}
</p:column>
<p:column headerText="Address">
#{block.ipAddress}/#{block.cidrSize}
</p:column>
<p:column headerText="Dms Managed?">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{block.isDmsManaged}"/>
</f:facet>
<f:facet name="input">
<p:selectBooleanCheckbox value="#{block.isDmsManaged}" label="DMS Managed"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:columns value="#{blockAttributesBean.columnNames}"
var="columnName"
columnIndexVar="colIndex">
<f:facet name="header">
#{columnName}
</f:facet>
<p:cellEditor id="dynEditorId#{block.columns[colIndex].name}">
<f:facet name="output">
<h:outputText value="#{block.columns[colIndex].value}"
rendered="#{block.columns[colIndex].isEditable == false}"/>
</f:facet>
<f:facet name="input">
<p:selectOneMenu id="dynSelectId#{block.columns[colIndex].name}"
value="#{block.columns[colIndex].value}" effect="fade"
label="#{block.columns[colIndex].name}">
<f:selectItem itemLabel="Select_One" itemValue=""/>
<f:selectItems value="#{block.columns[colIndex].choices}"
var="choice"
itemLabel="#{choice}"
itemValue="#{choice}"/>
</p:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:columns>
<p:column headerText="Sharing">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{block.sharing}"/>
</f:facet>
<f:facet name="input">
<p:selectOneMenu required="true"
value="#{block.sharing}" effect="fade" label="Sharing">
<f:selectItems value="#{blockAttributesBean.sharings}"
var="choice"
itemLabel="#{choice.label}"
itemValue="#{choice.value}"/>
</p:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Edit" style="width:50px">
<p:rowEditor >
</p:rowEditor>
</p:column>
<p:ajax event="rowEdit" listener="#{blockAttributesBean.cellEdited}"
update="blocksTable" />
</p:dataTable>

Problem is that everything works except dynamic columns in `<p:columns>`. Dynamic columns header shows up with correct text. Neither the column cell output value nor input component shows upon rowEdit button click.

Here's the `Column` class:

public class Column {
private String name;
private String value;
private boolean isEditable;
private List<String> choices;
........
}

`columnNames` is just a `List<String>` with names. For some reason, dynamic columns iterator works only with `List<String>` and not `List<Object>`. For e.g. If I try to generate dynamic columns with `List<Column>`, I get `NullPointerException`.

The main issue here I am trying to get past is the fact that output text and input component are not getting displayed.

Any help would be appreciated. Or perhaps if there is other way of implementing it.


dragon4109
Posts: 6
Joined: 02 Dec 2011, 15:23

06 Dec 2011, 00:26

Thanks you. So far, I am very impressed with the work that you all have put together. Its a really good framework with lot of very useful components. I am going to wait patiently for a fix for this issue as being able to edit columns dynamically is the core function of our product. Again, thanks for all your hard work.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

06 Dec 2011, 00:32

If it is urgent, your company may consider sponsoring the development of this feature because it currently has low priority among other 118 feature requests from community.

dragon4109
Posts: 6
Joined: 02 Dec 2011, 15:23

06 Dec 2011, 00:37

Thank you. What is the cost to implement this feature so that I can run this by them.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

06 Dec 2011, 00:46

Please send a private email to contact at prime.com.tr to get a quote.

naveenbhumandla
Posts: 21
Joined: 02 Jul 2012, 13:46

17 Jul 2012, 11:33

we are also facing same issue.could you please help on this.hey have you found any solution?



Thanks
Naveen.B

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 30 guests