Tree Node and Ampersand
Hi,
I need to place ampersands in tree node text property. To get the text
rendered right I need to provide the text as, for example, Bed '&+amp+;'
Breakfast.
This tree node is rendering well in the browser as "Bed & Breakfast".
But if an action is associated with the tree node and I run the app
the tree node is rendering to "Bed '&+amp+;' Breakfast".
"&+amp+;" means the well formed XHTML for ampersand, if I had written this as it should be it would render in this post as &.
Is there any workaround?
Thanks.
Stephan
# 3
The Tree Node is now rendering right, but I run into another problem. After selection I need to display the Tree Node text in a static text component. which worked with this code:
public String node_action() {
String fullId = tree1.getCookieSelectedTreeNode();
String id = fullId.substring(fullId.lastIndexOf(":")+1);
TreeNode selectedNode = (TreeNode) this.getForm1().findComponentById(id);
String category = selectedNode.getParentTreeNode((TreeNode) selectedNode).getText();
if ( category.indexOf("&") != -1 ) {
getSessionBean1().getClassified().setCategory(category.replace("&", "&"));
}
else {
getSessionBean1().getClassified().setCategory(category);
}
String subCategory = selectedNode.getText();
if ( subCategory.indexOf("&") != -1 ) {
getSessionBean1().getClassified().setSubCategory(subCategory.replace("&", "&"));
}
else {
getSessionBean1().getClassified().setSubCategory(subCategory);
}
categoryTextfield.setText(getSessionBean1().getClassified().getSubCategory());
categoryTextfield.setVisible(true);
return null;
}
}
(some & in the code section are original meant to be the XHTML for ampersand.)
but for the few Tree Nodes which are prerendered now, the call
String subCategory = selectedNode.getText();
returns null.
How can I get the text of for those prerendered Tree Node?
Thanks.
Stephan
# 4
It depends on when you invoke selectedNode.getText(). If it is before prerender() is called, it may returns null. I'd suggest to bind the tree node's text property with a bean property which has the string "Bed & Breakfast"
<ui:treeNode action="#{Page1.treeNode1_action}"
binding="#{Page1.treeNode1}" id="treeNode1"
text="#{SessionBean1.treeNode1Test}">
<f:facet name="image">
<ui:image binding="#{Page1.image1}"
icon="TREE_DOCUMENT" id="image1"/>
</f:facet>
</ui:treeNode>
Sherry