• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Tomahawk (myfaces) tree table not able to identify the checkbox component inside valuechangelistener

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I'm trying to use tomahawk(myfaces) tree table component to render a tree column of items along with checkboxes in other columns. Note that all the other columns except tree column are generated dynamically inside backing bean and checkboxes too added to the column dynamically.
All works fine until it comes to the valuechangelistener.Inside valuechangelistener if try to fetch the component id from the event, it doesn't return the correct id and instead always return the id that corresponds to the last node of tree.

Has anyone successfully used tree table to display input components? or any workaround my problem would be much appreciated.

The code where I'm adding my dynamic columns as well as checkboxes is as below.

for (int i = 0; i < roleNames.size(); i++) {

HtmlSimpleColumn column = new HtmlSimpleColumn();
htmlTree.getChildren().add(column);

// Create header
HtmlOutputText header = new HtmlOutputText();
header.setValue(roleNames.get(i));
column.setHeader(header);


ValueExpression valueExpression = FacesContext
.getCurrentInstance().getApplication()
.getExpressionFactory()
.createValueExpression(
FacesContext.getCurrentInstance().getELContext(),
"#{treeItem.name}",
Object.class);


// Create check box
HtmlSelectBooleanCheckbox checkbox = new HtmlSelectBooleanCheckbox();

// add the hidden input elements
HtmlInputHidden input = new HtmlInputHidden();
HtmlInputHidden input1 = new HtmlInputHidden();


// Bind changeRolePresent method in to listen to the
// role permission change
checkbox.setImmediate(true);

Class<?>[] parms = new Class[] { ValueChangeEvent.class };
System.out.println("Adding value change listener to permission grid");
MethodExpression valueChangeListener = FacesContext
.getCurrentInstance().getApplication()
.getExpressionFactory().createMethodExpression(
FacesContext.getCurrentInstance()
.getELContext(),
"#{customTreeBean.changeRolePermission}",
String.class, parms);
checkbox
.addValueChangeListener(new MethodExpressionValueChangeListener(
valueChangeListener));

input.setValueExpression("value", valueExpression);
input1.setValue(roleNames.get(i));


valueExpression = app
.getExpressionFactory()
.createValueExpression(
FacesContext.getCurrentInstance().getELContext(),
"#{treeItem.roleDetailsList["i"].selectedRole}",
Object.class);

checkbox.setValueExpression("value", valueExpression);

//checkbox.setOnclick("selectAll(this)");
checkbox.getChildren().add(input);
checkbox.getChildren().add(input1);
column.getChildren().add(checkbox);
}

In above code there will be four columns added dynamically and for each column a checkbox component is being added here. Rest JSF takes care to create checkboxes for each row of tree. But one thing that I noticed while viewing source that JSF is creating duplicate names for checkboxes in a batch of four (So for say if I had 3 rows, every row of checkboxes had same set of four ID's assigned, like ID1, ID2, ID3, ID4)

Thanks,
Umesh
 
He puts the "turd" in "saturday". Speaking of which, have you smelled this tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic