public void decode(FacesContext facesContext, UIComponent component) {
if (ComponentUtil.isOutputOnly(component)) {
return;
}
UITreeOldNode node = (UITreeOldNode) component;
UITreeOld tree = node.findTreeRoot();
TreeState state = tree.getState();
String treeId = tree.getClientId(facesContext);
String nodeId = node.getId();
final Map requestParameterMap
= facesContext.getExternalContext().getRequestParameterMap();
// expand state
String expandState = (String) requestParameterMap.get(treeId);
String searchString = ";" + nodeId + ";";
if (StringUtils.contains(expandState, searchString)) {
state.addExpandState((DefaultMutableTreeNode) node.getValue());
}
if (TreeOldRenderer.isSelectable(tree)) { // selection
String selected = (String) requestParameterMap.get(treeId + UITreeOld.SELECT_STATE);
searchString = ";" + nodeId + ";";
if (StringUtils.contains(selected, searchString)) {
state.addSelection((DefaultMutableTreeNode) node.getValue());
}
}
// marker
String marked = (String) requestParameterMap.get(treeId + UITreeOld.MARKER);
if (marked != null) {
searchString = treeId + NamingContainer.SEPARATOR_CHAR + nodeId;
if (marked.equals(searchString)) {
state.setMarker((DefaultMutableTreeNode) node.getValue());
}
}
// link
// FIXME: this is equal to the CommandRendererBase, why not use that code?
String actionId = ComponentUtil.findPage(facesContext, component).getActionId();
if (LOG.isDebugEnabled()) {
LOG.debug("actionId = '" + actionId + "'");
LOG.debug("nodeId = '" + treeId + NamingContainer.SEPARATOR_CHAR
+ nodeId + "'");
}
if (actionId != null
&& actionId.equals(treeId + NamingContainer.SEPARATOR_CHAR + nodeId)) {
UICommand treeNodeCommand
= (UICommand) tree.getFacet(UITreeOld.FACET_TREE_NODE_COMMAND);
if (treeNodeCommand != null) {
UIParameter parameter = ensureTreeNodeParameter(treeNodeCommand);
parameter.setValue(node.getId());
// LOG.error("no longer supported: treeNodeCommand.fireActionEvent(facesContext));");
// treeNodeCommand.fireActionEvent(facesContext); // FIXME jsfbeta
// component.queueEvent(new ActionEvent(component));
treeNodeCommand.queueEvent(new ActionEvent(treeNodeCommand));
}
UIForm form = ComponentUtil.findForm(component);
if (form != null) {
form.setSubmitted(true);
if (LOG.isDebugEnabled()) {
LOG.debug("setting Form Active: " + form.getClientId(facesContext));
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("actionId: " + actionId);
LOG.debug("nodeId: " + nodeId);
}
}
node.setValid(true);
}