Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
sumi aces
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 598
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!