myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tomek Chojnacki <tchojna...@actano.de>
Subject Re: disabling tree node checkbox for tree2
Date Tue, 04 Sep 2007 12:54:58 GMT

Hi,

I tried to solve the problem and to disable a checkbox with the following
code:

TreeNodeChecked treeNode;
...
    UIComponent nodeTypeFacet = getHtmlTree().getFacet(treeNode.getType());
    HtmlSelectBooleanCheckbox checkBox = (HtmlSelectBooleanCheckbox)
nodeTypeFacet.getChildren().get(0);
    checkBox.setReadonly(true);
...

private HtmlTree getHtmlTree() {
    FacesContext context = FacesContext.getCurrentInstance();
    UIComponent htmlTree =
context.getViewRoot().findComponent("myForm:idAvailable");
    return (HtmlTree) htmlTree;
}


But what happens now is, that ALL nodes of type "treeNode.getType()" in the
tree get read only (disabled).
I expected, that only selected node (treeNode) would get "read only"
rendering.

Has anybody some idea what I do wrong here?

Regards,
Tomek


Tomek Chojnacki wrote:
> 
> Hi,
> 
> I am newbie to MyFaces and have a slight problem with the tree2 component.
> 
> In my JSP I have tree2 component with checkboxes (selectBooleanCheckbox).
> It looks like this:
> 
> <t:tree2 id="htmlTree" ...
>   <f:facet name="project">
>     <h:panelGroup>
>       <t:selectBooleanCheckbox id="man" value="#{node.checked}"/>
>       <t:graphicImage value="/images/project.gif"
> rendered="#{t.nodeExpanded}" border="0"/> ...
> 
> Now I want to disable dynamically a checkbox for a tree node.
> I can do it in a static way - adding an attribute 'disabled="true"' to
> <t:selectBooleanCheckbox/> in the JSP.
> But I don't know how to do it on the server in the Java code.
> I get tree component with this code:
> 
> 	private HtmlTree getHtmlTree() {
> 		FacesContext context = FacesContext.getCurrentInstance();
> 		UIComponent htmlTree =
> context.getViewRoot().findComponent("myForm:htmlTree");
> 		return (HtmlTree) htmlTree;
> 	}
> 
> With this I can get any node with getHtmlTree().getNode()
> However TreeNode class has no property "setDisabled" or something like
> this.
> 
> How do I get UIComponent for selectBooleanCheckbox and change it to
> disabled, so that it renders then in the same way as "disabled" attribute
> in JSP?
> 
> Thank you in advance.
> Tomek
> 
> 

-- 
View this message in context: http://www.nabble.com/disabling-tree-node-checkbox-for-tree2-tf4354647.html#a12477689
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Mime
View raw message