Two Laptop Bag*
The moose likes JSF and the fly likes Can�t manage to select a row in a t:dataTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Can�t manage to select a row in a t:dataTable " Watch "Can�t manage to select a row in a t:dataTable " New topic
Author

Can�t manage to select a row in a t:dataTable

Laurent Salse
Greenhorn

Joined: Nov 07, 2004
Posts: 14
I use a tomahawk dataTable to list a collection of objects called �dmex� in dmexTable.jsp

When I select one row to edit details in the next page �dmexDetails.jsp� I systematically get the last entries of my table.

In debug mode I could find out that JSF/MyFaces iterates through the whole list instead of selecting only the entry I clicked on.

Here is my code of dmexTable.jsp where #{dmexTable} is a backingBean of dmexTable.jsp and #{dmexBean} the backingBean of dmexDetails.jsp

<h:form id="formDmexTable">

<t:dataTable id="dmexTable"
cellspacing="3"
cellpadding="3"
styleClass="orders"
headerClass="ordersHeader"
rowClasses="evenRow,oddrow"
var="rowDmex"
value="#{dmexTable.dmexList}"
preserveDataModel="true" >


<h:column>
<f:facet name="header">
<hutputText value="Id" id="columnDmexId" />
</f:facet>
<hutputText value="#{rowDmex.dmexId}" id="rowDmexId" />
</h:column>


<h:column>
<f:facet name="header">
<hutputText value="#{msgsDmex.application}" id="columnApps" />
</f:facet>
<t:commandLink id="selectDmexApps" action="go_to_dmexDetails" immediate="true">

<hutputText value="#{rowDmex.application}"
id="rowApplication" />

<t:updateActionListener property="#{dmexBean.dmexId}"
value="#{rowDmex.dmexId}" />


</t:commandLink>

</h:column>

� some others properties in other columns �

</t:dataTable>
</h:form>


Herebelow the code of my RequestScope ManagedBean #{dmexTable} containing a property dmexList and a hibernate Class called �dmexManager� that gives access to the dataBase :

public class DmexTable{

private ArrayList dmexList ;
private bsa.integration.service.DmexManager dmexManager;

public ArrayList getDmexList() {

dmexList = (ArrayList) dmexManager.findPoolList(new Dmex())
return dmexList;
}


public void setDmexList(ArrayList dmexList) {
this.dmexList = dmexList;
}

SOFAR EVRYTHING WORKS FINE ; I can list my dmex in the dataTable dmexTable !


Here below is the code of my JSP view called �dmexDetails.jsp� where #{dmexBean}is still the backingBean of the view :

<h:form id="formDmexIdentification">

<t:saveState value="#{dmexBean.dmexId}" />

<h:panelGrid columns="2">
<hutputText value="id" styleClass="sorti" />
<hutputText value="#{dmexBean.dmex.dmexId}"styleClass="sorti"/>

<hutputText value="#{msgsDmex.application}" styleClass="sorti" />

<h:inputText value="#{dmexBean.dmex.application}"
size="6" styleClass="ent" required="true" id="inputApplication" />

<h:message for="inputApplication" styleClass="mess" />


Herebelow the code of my RequestScope ManagedBean #{dmexDetails} containing the �t:saveState� property dmexId and the hibernate Class �dmexManager� that gives access to the dataBase :

public class DmexBean {


private int dmexId ;

public int getDmexId() {
return dmexId;
}



// this is the method that JSF/MyFaces iterates through when clicking on one commandLink of the Table !!!

public void setDmexId(int _rowDmexId) {

if (_rowDmexId > 0)
{
dmex = getSimpleDmex(_rowDmexId);

if (dmex == null) {
return;
}
}

}

private Dmex getSimpleDmex(int _id) {

dmex = (Dmex)dmexManager.findOneId(new Dmex(),_id);

return dmex;
}
}

I can�t figure out why clicking on the command Link JSF/MyFaces does not simply send back the selected dmexId !

May someone give a hint ? I have nomore Idea since my implementation seems exactly similar to the MyFace example I used ..
 
Don't get me started about those stupid light bulbs.
 
subject: Can�t manage to select a row in a t:dataTable