aspose file tools*
The moose likes JSF and the fly likes jsf:datatable with selectManyCheckbox problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "jsf:datatable with selectManyCheckbox problem" Watch "jsf:datatable with selectManyCheckbox problem" New topic
Author

jsf:datatable with selectManyCheckbox problem

baabs
Greenhorn

Joined: Jun 10, 2006
Posts: 5
hi,

i am using datatable with selectManycheckbox,i searched two days,but i didn't get the Exact answer,

please help me..............

myjsp code

<t:dataTable id="list" value="#{assetgroupindex.list}" var="list" rows="10">

<h:column>
<h:selectManyCheckbox id="checkedItems" value="#{assetgroupindex.checkedItems}" title="#{bondsproperty.assetgroupadd_approvebk_hint}">
<f:selectItem itemValue="#{list.assetGroupCode}"/>
</h:selectManyCheckbox>
</h:column>

<t:dataTable

<h:commandButton id="approve" actionListener="#{assetgroupindex.approve}" value="Approve"/>

My bean code

public class AssetGroupIndex {

private ArrayList checkedItems = new ArrayList();


public Object[] getCheckedItems() {
return checkedItems.toArray();
}

public void setCheckedItems(Object[] newcheckedItems) {

int len=0;
if (null == newcheckedItems || ( len = newcheckedItems.length)==0 ) {
return;
}
checkedItems.clear();
checkedItems = new ArrayList(len);
for ( int i=0;i<len;i++) {
checkedItems.add(newcheckedItems[i]);
}
}




public String approve(ActionEvent event){

UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
logger.info("viewRoot"+viewRoot.getFamily());

UIComponent formComponent=(UIComponent)viewRoot.getChildren().get(0);

UIComponent tableComponent=formComponent.findComponent("list");
UISelectMany selectManyComponent=(UISelectMany)tableComponent.findComponent("checkedItems");

Object[] objectArray=selectManyComponent.getSelectedValues();
logger.info("getting selectedArray Object");

//checkedItems=(ArrayList) Arrays.asList(objectArray);
for(int j=0;j<objectArray.length;j++){
logger.info("objectArray ["+j+"] = "+(String)objectArray[j]);
checkedItems.add((String)objectArray[j]);
}


}


}


here i got only one selected value.


give me solution

regards
Babu
Nimchi Yung
Ranch Hand

Joined: Jan 27, 2004
Posts: 71
Should that be



--Nimchi
baabs
Greenhorn

Joined: Jun 10, 2006
Posts: 5
hi,

Thanks for ur reply,but i got the following error

*****************************************************

[Jun 12 06:13:45] ERROR (LogUtil.java:154) - org.apache.jasper.JasperException: /modules/mod_assetgroup/assetgroupindex.jsp(53,1) Attribute itemValue invalid for tag selectItems according to TLD
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:234)
at org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:989)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:710)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1441)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:730)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1441)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:730)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1441)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:730)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1441)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)

******************************
Nimchi Yung
Ranch Hand

Joined: Jan 27, 2004
Posts: 71
Oops, it should be something like:



Assuming your list.assetGroupCode returns a collection.

--Nimchi
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: jsf:datatable with selectManyCheckbox problem