You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2006/10/04 10:22:01 UTC
svn commit: r452791 -
/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UITreeNode.java
Author: weber
Date: Wed Oct 4 01:22:00 2006
New Revision: 452791
URL: http://svn.apache.org/viewvc?view=rev&rev=452791
Log:
TOBAGO-142 (tree should use jsf valueBinding mechanismn to lookup reference values)
Modified:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UITreeNode.java
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UITreeNode.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UITreeNode.java?view=diff&rev=452791&r1=452790&r2=452791
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UITreeNode.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UITreeNode.java Wed Oct 4 01:22:00 2006
@@ -16,11 +16,11 @@
* limitations under the License.
*/
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DISABLED;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DISABLED_REFERENCE;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DISABLED;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DISABLED_REFERENCE;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ID_REFERENCE;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_NAME;
import static org.apache.myfaces.tobago.TobagoConstants.ATTR_NAME_REFERENCE;
@@ -29,9 +29,11 @@
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.MutableTreeNode;
import javax.swing.tree.TreeNode;
+import java.util.Map;
public class UITreeNode extends UIInput {
@@ -152,13 +154,20 @@
}
}
+ @SuppressWarnings("unchecked")
private Object getReference(TreeNode treeNode, String key) {
Object value = null;
UITree root = findTreeRoot();
String reference = (String) root.getAttributes().get(key);
if (reference != null) {
try {
- value = PropertyUtils.getProperty(treeNode, reference);
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Map requestMap = facesContext.getExternalContext().getRequestMap();
+ String ref = "#{tobagoTreeNode." + reference + "}";
+ ValueBinding vb = facesContext.getApplication().createValueBinding(ref);
+ requestMap.put("tobagoTreeNode", treeNode);
+ value = vb.getValue(facesContext);
+ requestMap.remove("tobagoTreeNode");
} catch (Exception e) {
LOG.warn(
"Can't find " + key + " over ref='" + reference