• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

jsf:datatable with selectManyCheckbox problem

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Should that be



--Nimchi
 
baabs
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops, it should be something like:



Assuming your list.assetGroupCode returns a collection.

--Nimchi
 
Why am I so drawn to cherry pie? I can't seem to stop. Save me tiny ad!
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic