aspose file tools
The moose likes JSF and the fly likes how to set the value of the primary key to the check box in data table Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "how to set the value of the primary key to the check box in data table" Watch "how to set the value of the primary key to the check box in data table" New topic
Author

how to set the value of the primary key to the check box in data table

sumi aces
Greenhorn

Joined: Oct 20, 2008
Posts: 1
Hai,

Any one please help me to solve this out.. A Data Table with first column has checkboxes and second column with the primary key (ex: empno) of the database in the server. I need to set the value of the checkbox as the corresponding primary key, so that when the particular row checkbox is checked and when i click the delete button, the corresponding primary key and its records has to get deleted from the database.
I've created my jsf page for checkbox as,

<h:column id="col1">
<f:facet name="header">
<hutputLabel id="lblchange" value="Select" />
</f:facet>
<h:selectBooleanCheckbox id="chkid" value="#{planGroup.chkValue}">
</h:selectBooleanCheckbox>
</h:column>
<h:column id="column1">
<f:facet name="header">
<hutputText value="Plan Group ID"></hutputText>
</f:facet>
<hutputText value="#{result.planGroupId}"></hutputText>
<h:inputHidden id="planGroupList" value="#{result.planGroupId}" />
</h:column>

bean :
public class PlanGroupBean {
private String planGroupID;
private boolean chkValue;
public boolean isChkValue() {
//System.out.println("CHECKED--CHK-value:"+chkValue);
return chkValue;
}

public void setChkValue(boolean chkValue) {

this.chkValue = chkValue;
}

public void setPlanGroupID(String planGroupID) {
this.planGroupID = planGroupID;
}

public String getPlanGroupID() {
return this.planGroupID;
}
}
I don't know how to set the value of primary key to the check box...
please help me out...
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

You can do one thing to do it.

Use <f:param> so that whenever you will get request you can take the id from it.

<h:column id="col1">
<f:facet name="header">
<hutputLabel id="lblchange" value="Select" />
</f:facet>
<h:selectBooleanCheckbox id="chkid" value="#{planGroup.chkValue}">
</h:selectBooleanCheckbox>
<f:param name="id" value="#{result.planGroupId}" />
</h:column>

Hope it works.


My Blog SCJP 5 SCWCD 5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to set the value of the primary key to the check box in data table
 
Similar Threads
how to set and get h:selectBooleanCheckbox value in h:datatabel
Add value if checkbox selected
Changing application ststus in a datatable
Input row select on data table does not get called
How to get selected records from Data Table in JSF