• Post Reply Bookmark Topic Watch Topic
  • New Topic

Inputs in datatable  RSS feed

 
Spintheglob
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Here is a problem on which i've been struggling till now:

I have a datatable filled up with users and their properties (name, address...). At the end of each row I need to put either an InputText or a SelectOneMenu, in order to associate some new properties to each of my users.
So I've put an actionListener behind the UInput, and each time this input is updated and validated, the id of the user and the new value are stored in a Map. This works.

The thing is that the displayed values in each if the inputText are not kept in the UInput, and each time resetted to the value of the UInput of the last row... making this visually useless...

Does anyone know the trick?

Thanks a lot in advance,
++
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make it a property of the row object in question.
 
Spintheglob
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your answer but I don't see what you mean... :S

Here is my page content:

<ice:dataTable id="ListTable" value="#{circuitManager.usagersCircuitRowModel}"
rows="#{circuitManager.maxRowsPerPage}"
var="item">
<ice:columns value="#{circuitManager.usagersCircuitColumnModel}" var="col">
<f:facet name="header">
<div class="table_headers">
<ice:commandSortHeader
columnName="#{col.columnName}"
arrow="true">
<iceutputText value="#{col}"/>
</ice:commandSortHeader>
</div>
</f:facet>
<iceutputText value="#{circuitManager.cellValueUsagerCircuit}"/>
</ice:columns>
<ice:column >
<f:facet name="header">
<hutputText value="#{msg.circuits_col_destination}" />
</f:facet>
<ice:selectOneMenu required="true" partialSubmit="true" immediate="true" id="sltDestination"
value="#{circuitManager.destination_id}"
valueChangeListener="#{circuitManager.setUsagersDestinations}" rendered="true" >
<f:selectItems value="#{circuitManager.destinations}" />
</ice:selectOneMenu>
</ice:column>
</ice:dataTable>


And the associated actionListener method:

public void setUsagersDestinations(ValueChangeEvent event) {
UIInput selectMenu = (UIInput) event.getComponent();
logger.debug("IDDDDDDDDDDDDDDDDDDD>>>>><>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"+ event.getComponent().getId());

this.usager = (Usager) usagersCircuitRowModel.getRowData();
selectMenu.setSubmittedValue(event.getNewValue());
try{
int idUsager = this.usager.getIdClient();
String dest = (String) event.getNewValue();
if (!usagersDestinationsMap.containsValue(dest) && dest != "")
{
selectMenu.setValid(true);
if (usagersDestinationsMap.containsKey(idUsager)) usagersDestinationsMap.remove(idUsager);
usagersDestinationsMap.put(idUsager, dest);
}
if (usagersDestinationsMap.containsValue(dest) && dest != "")
{
selectMenu.setValid(false);
return;
}

} catch (Exception e) {
e.printStackTrace();
}
}


How can I make the selectonemenu a property of my destinations object?

Thank you,
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make it a property of the object behind #{col}.

A valueChangeListener is not an actionListener by the way.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!