You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by jw...@apache.org on 2007/11/12 22:03:40 UTC
svn commit: r594297 [5/39] - in /myfaces/trinidad/branches/1.2.4-branch: ./
trinidad-api/
trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/
trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/
trinidad-api/src/main/jav...
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/SetActionListenerTag.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/SetActionListenerTag.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/SetActionListenerTag.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/SetActionListenerTag.java Mon Nov 12 13:03:17 2007
@@ -27,14 +27,12 @@
import com.sun.facelets.FaceletContext;
import com.sun.facelets.FaceletException;
-import com.sun.facelets.el.LegacyValueBinding;
import com.sun.facelets.tag.TagAttribute;
import com.sun.facelets.tag.TagConfig;
import com.sun.facelets.tag.TagHandler;
import com.sun.facelets.tag.jsf.ComponentSupport;
/**
- * @todo it should be removed after we consume JSF1.2.
*/
public class SetActionListenerTag extends TagHandler
{
@@ -46,7 +44,6 @@
_to = getRequiredAttribute("to");
}
- @SuppressWarnings("deprecation")
public void apply(FaceletContext faceletContext,
UIComponent parent) throws FaceletException, ELException
{
@@ -59,10 +56,8 @@
Object.class);
ActionSource actionSource= (ActionSource) parent;
SetActionListener listener = new SetActionListener();
- listener.setValueBinding("from",
- new LegacyValueBinding(fromExpression));
- listener.setValueBinding("to",
- new LegacyValueBinding(toExpression));
+ listener.setValueExpression("from", fromExpression);
+ listener.setValueExpression("to", toExpression);
actionSource.addActionListener(listener);
}
}
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/TrinidadListenersTagRule.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/TrinidadListenersTagRule.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/TrinidadListenersTagRule.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/facelets/TrinidadListenersTagRule.java Mon Nov 12 13:03:17 2007
@@ -41,9 +41,9 @@
{
public static final MetaRule Instance = new TrinidadListenersTagRule();
- private static class ListenerPropertyMetadata extends Metadata
+ private static class ListenerMBPropertyMetadata extends Metadata
{
- public ListenerPropertyMetadata(Method method, TagAttribute attribute, Class[] paramList)
+ public ListenerMBPropertyMetadata(Method method, TagAttribute attribute, Class[] paramList)
{
_method = method;
_attribute = attribute;
@@ -76,6 +76,42 @@
private final TagAttribute _attribute;
private Class[] _paramList;
}
+
+ private static class ListenerMEPropertyMetadata extends Metadata
+ {
+ public ListenerMEPropertyMetadata(Method method, TagAttribute attribute, Class[] paramList)
+ {
+ _method = method;
+ _attribute = attribute;
+ _paramList = paramList;
+ }
+
+ @Override
+ @SuppressWarnings("deprecation")
+ public void applyMetadata(FaceletContext ctx, Object instance)
+ {
+ MethodExpression expr =
+ _attribute.getMethodExpression(ctx, null, _paramList);
+
+ try
+ {
+ _method.invoke(instance,
+ new Object[]{expr});
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new TagAttributeException(_attribute, e.getCause());
+ }
+ catch (Exception e)
+ {
+ throw new TagAttributeException(_attribute, e);
+ }
+ }
+
+ private final Method _method;
+ private final TagAttribute _attribute;
+ private Class[] _paramList;
+ }
@Override
@@ -84,7 +120,11 @@
TagAttribute attribute,
MetadataTarget meta)
{
- if ((meta.getPropertyType(name) == MethodBinding.class) &&
+ Class metaType = meta.getPropertyType(name);
+ boolean isMethodBinding = (metaType == MethodBinding.class);
+ boolean isMethodExpression = (metaType == MethodExpression.class);
+
+ if ((isMethodBinding || isMethodExpression) &&
name.endsWith("Listener"))
{
// OK, we're trying to call setFooListener()
@@ -112,8 +152,12 @@
return null;
// And go
- return new ListenerPropertyMetadata(m, attribute,
- new Class[]{eventClass});
+ if (isMethodBinding)
+ return new ListenerMBPropertyMetadata(m, attribute,
+ new Class[]{eventClass});
+ else
+ return new ListenerMEPropertyMetadata(m, attribute,
+ new Class[]{eventClass});
}
}
return null;
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/HtmlResponseWriter.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/HtmlResponseWriter.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/HtmlResponseWriter.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/HtmlResponseWriter.java Mon Nov 12 13:03:17 2007
@@ -81,6 +81,7 @@
public void flush() throws IOException
{
_closeStartIfNecessary();
+ _out.flush();
}
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/IndentingResponseWriter.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/IndentingResponseWriter.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/IndentingResponseWriter.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/IndentingResponseWriter.java Mon Nov 12 13:03:17 2007
@@ -112,6 +112,16 @@
* Writes a String, escaped properly for this method.
*/
@Override
+ public void writeText(Object text, UIComponent component, String componentPropertyName) throws IOException
+ {
+ _seeIfJustEndedElement();
+ super.writeText(text, component, componentPropertyName);
+ }
+
+ /**
+ * Writes a String, escaped properly for this method.
+ */
+ @Override
public void writeText(Object text, String componentPropertyName) throws IOException
{
_seeIfJustEndedElement();
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/ResponseWriterDecorator.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/ResponseWriterDecorator.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/ResponseWriterDecorator.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/ResponseWriterDecorator.java Mon Nov 12 13:03:17 2007
@@ -126,6 +126,15 @@
getResponseWriter().writeComment(comment);
}
+
+
+ @Override
+ public void writeText(Object text, UIComponent component,
+ String propertyName)
+ throws IOException
+ {
+ getResponseWriter().writeText(text, component, propertyName);
+ }
@Override
public void writeText(Object text, String componentPropertyName) throws IOException
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/XhtmlResponseWriter.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/XhtmlResponseWriter.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/XhtmlResponseWriter.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/io/XhtmlResponseWriter.java Mon Nov 12 13:03:17 2007
@@ -84,6 +84,7 @@
public void flush() throws IOException
{
_closeStartIfNecessary();
+ _out.flush();
}
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/ItemNode.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/ItemNode.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/ItemNode.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/ItemNode.java Mon Nov 12 13:03:17 2007
@@ -73,7 +73,7 @@
{
// Value of action is EL method binding, so we
// need to evaluate it
- value = (String)MenuUtils.getBoundValue(value);
+ value = MenuUtils.getBoundValue(value, String.class);
}
// Post me as the selected Node for the request
@@ -112,7 +112,7 @@
{
// Value of action is EL method binding, so we
// need to evaluate it
- value = (String)MenuUtils.getBoundValue(value);
+ value = MenuUtils.getBoundValue(value, String.class);
setActionListener(value);
}
@@ -149,7 +149,7 @@
{
// Value of action is EL method binding, so we
// need to evaluate it
- value = (String)MenuUtils.getBoundValue(value);
+ value = MenuUtils.getBoundValue(value, String.class);
setLaunchListener(value);
}
@@ -186,7 +186,7 @@
{
// Value of action is EL method binding, so we
// need to evaluate it
- value = (String)MenuUtils.getBoundValue(value);
+ value = MenuUtils.getBoundValue(value, String.class);
setReturnListener(value);
}
@@ -372,7 +372,7 @@
{
// Value of action is EL method binding, so we
// need to evaluate it
- value = (String)MenuUtils.getBoundValue(value);
+ value = MenuUtils.getBoundValue(value, String.class);
}
// Appending nodeId to URL so that we can identify the node
@@ -408,7 +408,7 @@
{
// Value of destination is EL value binding, so we
// need to evaluate it
- value = (String)MenuUtils.getBoundValue(value);
+ value = MenuUtils.getBoundValue(value, String.class);
setTargetFrame(value);
}
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuContentHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuContentHandlerImpl.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuContentHandlerImpl.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuContentHandlerImpl.java Mon Nov 12 13:03:17 2007
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -50,55 +50,55 @@
* Handler called by the SAXParser when parsing menu metadata
* as part of the XML Menu Model of Trinidad Faces.
* <p>
- * This is called through the Services API (See XMLMenuModel.java) to
+ * This is called through the Services API (See XMLMenuModel.java) to
* keep the separation between API's and internal modules.
* <p>
* startElement() and endElement() are called as one would expect,
* at the start of parsing an element in the menu metadata file and
* at the end of parsing an element in the menu metadata file.
- *
+ *
* The menu model is created as a List of itemNodes and groupNodes
* which is available to and used by the XMLMenuModel to create the
* TreeModel and internal Maps.
- *
+ *
*/
- /*
- * IMPORTANT NOTE: Much of the work and data structures used by the
- * XMLMenuModel are created (and kept) in this class. This is necessarily the
- * case because the scope of the XMLMenuModel is request. The
- * MenuContentHandlerImpl is shared so it does not get rebuilt upon each
+ /*
+ * IMPORTANT NOTE: Much of the work and data structures used by the
+ * XMLMenuModel are created (and kept) in this class. This is necessarily the
+ * case because the scope of the XMLMenuModel is request. The
+ * MenuContentHandlerImpl is shared so it does not get rebuilt upon each
* request as the XMLMenuModel does. So the XMLMenuModel can get its data
* each time it is rebuilt (on each request) without having to reparse and
* recreate all of its data structures. It simply gets them from here.
- *
- * As well as the tree, three hashmaps are created in order to be able to
- * resolve cases where multiple menu items cause navigation to the same viewId.
+ *
+ * As well as the tree, three hashmaps are created in order to be able to
+ * resolve cases where multiple menu items cause navigation to the same viewId.
* All 3 of these maps are created after the metadata is parsed and the tree is
- * built, in the _addToMaps method.
- *
- * o The first hashMap is called the viewIdFocusPathMap and is built by
- * traversing the tree after it is built (see endDocument()).
- * Each node's focusViewId is
- * obtained and used as the key to an entry in the viewIdHashMap. An ArrayList
- * is used as the entry's value and each item in the ArrayList is a node's
- * rowkey from the tree. This allows us to have duplicate rowkeys for a single
- * focusViewId which translates to a menu that contains multiple items pointing
- * to the same page. In general, each entry will have an ArrayList of rowkeys
+ * built, in the _addToMaps method.
+ *
+ * o The first hashMap is called the viewIdFocusPathMap and is built by
+ * traversing the tree after it is built (see endDocument()).
+ * Each node's focusViewId is
+ * obtained and used as the key to an entry in the viewIdHashMap. An ArrayList
+ * is used as the entry's value and each item in the ArrayList is a node's
+ * rowkey from the tree. This allows us to have duplicate rowkeys for a single
+ * focusViewId which translates to a menu that contains multiple items pointing
+ * to the same page. In general, each entry will have an ArrayList of rowkeys
* with only 1 rowkey, AKA focus path.
- * o The second hashMap is called the nodeFocusPathMap and is built at the
- * same time the viewIdHashMap is built. Each entry's key is the actual node
+ * o The second hashMap is called the nodeFocusPathMap and is built at the
+ * same time the viewIdHashMap is built. Each entry's key is the actual node
* and the value is the row key. Since the model keeps track of the currently
- * selected menu node, this hashmap can be used to resolve viewId's with
+ * selected menu node, this hashmap can be used to resolve viewId's with
* multiple focus paths. Since we have the currently selected node, we just
* use this hashMap to get its focus path.
* o The third hashMap is called idNodeMap and is built at the same time as the
* previous maps. This map is populated by having each entry contain the node's
- * id as the key and the actual node as the value. In order to keep track of
- * the currently selected node in the case of a GET, the node's id is appended
- * to the request URL as a parameter. The currently selected node's id is
- * picked up and this map is used to get the actual node that is currently
+ * id as the key and the actual node as the value. In order to keep track of
+ * the currently selected node in the case of a GET, the node's id is appended
+ * to the request URL as a parameter. The currently selected node's id is
+ * picked up and this map is used to get the actual node that is currently
* selected.
- */
+ */
public class MenuContentHandlerImpl extends DefaultHandler
implements MenuContentHandler
{
@@ -108,14 +108,14 @@
public MenuContentHandlerImpl()
{
super();
-
+
// Init the essential maps.
_treeModelMap = new HashMap<String, TreeModel>();
_viewIdFocusPathMapMap = new HashMap<Object, Map<String, List<Object>>>();
_nodeFocusPathMapMap = new HashMap<Object, Map<Object, List<Object>>>();
_idNodeMapMap = new HashMap<Object, Map<String, Object>>();
}
-
+
/**
* Called by the SAX Parser at the start of parsing a document.
*/
@@ -125,18 +125,18 @@
_nodeDepth = 0;
_menuNodes = new ArrayList<List<MenuNode>>();
_menuList = null;
-
- // Handler Id will have to change also to be unique
+
+ // Handler Id will have to change also to be unique
_handlerId = Integer.toString(System.identityHashCode(_menuNodes));
}
-
+
/**
* Start the parsing of an node element entry in the menu metadata file.
* <p>
* If the entry is for an itemNode or a destinationNode, create the node
* and it to the List. If the entry is for a sharedNode, a new submenu
* model is created.
- *
+ *
* @param nameSpaceUri - only used when passed to super class.
* @param localElemName - only used when passed to super class.
* @param qualifiedElemName - String designating the node type of the entry.
@@ -145,26 +145,26 @@
*/
@SuppressWarnings("unchecked")
@Override
- public void startElement(String nameSpaceUri, String localElemName,
+ public void startElement(String nameSpaceUri, String localElemName,
String qualifiedElemName, Attributes attrList)
throws SAXException
{
- super.startElement(nameSpaceUri, localElemName, qualifiedElemName,
+ super.startElement(nameSpaceUri, localElemName, qualifiedElemName,
attrList);
-
+
if (_ROOT_NODE.equals(qualifiedElemName))
{
// Unless both of these are specified, don't attempt to load
// the resource bundle.
String resBundle = attrList.getValue(_RES_BUNDLE_ATTR);
String resBundleKey = attrList.getValue(_VAR_ATTR);
-
+
if ( (resBundle != null && !"".equals(resBundle))
&& (resBundleKey != null && !"".equals(resBundleKey))
)
- {
+ {
// Load the resource Bundle.
- // Ensure the bundle key is unique by appending the
+ // Ensure the bundle key is unique by appending the
// handler Id.
MenuUtils.loadBundle(resBundle, resBundleKey + getHandlerId());
_resBundleKey = resBundleKey;
@@ -177,34 +177,34 @@
boolean isNonSharedNode = ( _ITEM_NODE.equals(qualifiedElemName)
|| _GROUP_NODE.equals(qualifiedElemName)
);
-
- if (isNonSharedNode)
+
+ if (isNonSharedNode)
{
- _currentNodeStyle = ( _ITEM_NODE.equals(qualifiedElemName)
+ _currentNodeStyle = ( _ITEM_NODE.equals(qualifiedElemName)
? MenuConstants.NODE_STYLE_ITEM
: MenuConstants.NODE_STYLE_GROUP
);
_nodeDepth++;
-
+
if ((_skipDepth >= 0) && (_nodeDepth > _skipDepth))
{
// This sub-tree is being skipped, so just return
return;
}
-
- if (_menuNodes.size() < _nodeDepth)
+
+ if (_menuNodes.size() < _nodeDepth)
{
_menuNodes.add(new ArrayList<MenuNode>());
}
_attrMap = _getMapFromList(attrList);
-
+
// Create either an itemNode or groupNode.
MenuNode menuNode = _createMenuNode();
-
+
if (menuNode == null)
{
- // No menu item is created, so note that we are
+ // No menu item is created, so note that we are
// now skipping the subtree
_skipDepth = _nodeDepth;
}
@@ -217,23 +217,23 @@
menuNode.setResBundleKey(_resBundleKey);
menuNode.setResBundleName(_resBundleName);
}
-
+
// Set the node's MenuContentHandlerImpl id so that when
// the node's getLabel() method is called, we can
// use the handlerId to insert into the label
// if it is an EL expression.
menuNode.setHandlerId(getHandlerId());
-
+
// Set the root model on the node so we can call into
// the root model from the node to populate its
// idNodeMap (See XMLMenuModel.java)
menuNode.setRootModelKey(getRootModelKey());
-
+
// Set the local model (created when parsing a sharedNode)
// on the node in case the node needs to get back to its
// local model.
// menuNode.setModel(getModel());
-
+
List<MenuNode> list = _menuNodes.get(_nodeDepth-1);
list.add(menuNode);
}
@@ -241,31 +241,33 @@
else if (_SHARED_NODE.equals(qualifiedElemName))
{
_nodeDepth++;
-
+
// SharedNode's "ref" property points to another submenu's metadata,
// and thus a new model, which we build here. Note: this will
// recursively call into this MenuContentHandlerImpl when parsing the
// submenu's metadata.
String expr = attrList.getValue(_REF_ATTR);
-
+
// Need to push several items onto the stack now as we recurse
// into another menu model.
- _saveModelData();
+ _saveModelData();
// Create the sub menu model specified in the sharedNode
- XMLMenuModel menuModel = (XMLMenuModel)MenuUtils.getBoundValue(expr);
-
+ XMLMenuModel menuModel = (XMLMenuModel)MenuUtils.getBoundValue(expr,
+ Object.class);
+
+
// Now must pop the values cause we are back to the parent
// model.
_restoreModelData();
-
+
// Name of the managed bean that is the sub menu XMLMenuModel.
- String modelStr = expr.substring(expr.indexOf('{')+1,
+ String modelStr = expr.substring(expr.indexOf('{')+1,
expr.indexOf('}'));
-
+
// There are 2 ways that a Model can be invalid:
// 1) Something such as a missing managed bean definition
- // for the submenu model causes the creation of the
+ // for the submenu model causes the creation of the
// XMLMenuModel for the submenu to fail. This will result
// in menuModel being NULL.
// 2) Some kind of parsing error in its metadata. If a node
@@ -277,22 +279,22 @@
{
Object subMenuObj = menuModel.getWrappedData();
List<MenuNode> subMenuList = null;
-
+
if (subMenuObj instanceof ChildPropertyTreeModel)
{
- subMenuList =
+ subMenuList =
(List<MenuNode>)((ChildPropertyTreeModel)subMenuObj).getWrappedData();
}
-
+
if (subMenuList != null)
{
// SharedNode could be the first child
// So we need a new list for the children
- if (_menuNodes.size() < _nodeDepth)
+ if (_menuNodes.size() < _nodeDepth)
{
_menuNodes.add(new ArrayList<MenuNode>());
}
-
+
List<MenuNode> list = _menuNodes.get(_nodeDepth-1);
list.addAll(subMenuList);
}
@@ -312,7 +314,7 @@
new NullPointerException("Shared Node Model not created for "
+ modelStr + ". Check for the existence of the corresponding "
+ "managed bean in your config files.");
-
+
_LOG.severe (npe.getMessage(), npe);
}
}
@@ -325,12 +327,12 @@
}
}
}
-
+
/**
- * Processing done at the end of parsing a node enty element from the
+ * Processing done at the end of parsing a node enty element from the
* menu metadata file. This manages the node depth properly so that
* method startElement works correctly to build the List.
- *
+ *
* @param nameSpaceUri - not used.
* @param localElemName - not used.
* @param qualifiedElemName - String designating the node type of the entry.
@@ -338,9 +340,9 @@
@Override
public void endElement(String nameSpaceUri, String localElemName, String qualifiedElemName)
{
- if ( _ITEM_NODE.equals(qualifiedElemName)
+ if ( _ITEM_NODE.equals(qualifiedElemName)
|| _GROUP_NODE.equals(qualifiedElemName)
- )
+ )
{
_nodeDepth--;
@@ -358,14 +360,14 @@
// The parent menu item is the last menu item at the previous depth
List<MenuNode> parentList = _menuNodes.get(_nodeDepth-1);
MenuNode parentNode = parentList.get(parentList.size()-1);
-
+
parentNode.setChildren(_menuNodes.get(_nodeDepth));
}
// If we have dropped back two levels, then we are done adding
// the parent's sub tree, remove the list of menu items at that level
// so they don't get added twice.
- if (_nodeDepth == (_menuNodes.size() - 2))
+ if (_nodeDepth == (_menuNodes.size() - 2))
{
_menuNodes.remove(_nodeDepth+1);
}
@@ -379,21 +381,21 @@
// that a sharedNode model is not created properly. However,
// we only log an error and let parsing continue so that the whole
// Tree can get created w/o the failed sharedNode submenu model.
- // Thus we need the 2nd conditional here to detect if we are at
+ // Thus we need the 2nd conditional here to detect if we are at
// the end of parsing a failed sharedNode.
if (_nodeDepth > 0 && _menuNodes.size() > _nodeDepth)
{
// The parent menu item is the last menu item at the previous depth
List<MenuNode> parentList = _menuNodes.get(_nodeDepth-1);
MenuNode parentNode = parentList.get(parentList.size()-1);
-
+
parentNode.setChildren(_menuNodes.get(_nodeDepth));
}
}
}
/**
- * Called by the SAX Parser at the end of parsing a document.
+ * Called by the SAX Parser at the end of parsing a document.
* Here, the menuList is put on the menuList map.
*/
@Override
@@ -404,92 +406,92 @@
// Empty tree is created to prevent
// later NPEs if menu model methods are called.
_LOG.warning ("CREATE_TREE_WARNING: Empty Tree!");
-
+
// Create empty treeModel
ChildPropertyTreeModel treeModel = new ChildPropertyTreeModel();
-
+
// Put it in the map
- _treeModelMap.put(_currentTreeModelMapKey, treeModel);
+ _treeModelMap.put(_currentTreeModelMapKey, treeModel);
}
else
{
_menuList = _menuNodes.get(0);
-
+
// Create the treeModel
- ChildPropertyTreeModel treeModel =
+ ChildPropertyTreeModel treeModel =
new ChildPropertyTreeModel(_menuList, "children");
-
+
// Put it in the map
_treeModelMap.put(_currentTreeModelMapKey, treeModel);
-
- // If Model is the Root, then build Model's hashmaps
+
+ // If Model is the Root, then build Model's hashmaps
// and set them on the Root Model.
XMLMenuModel rootModel = getRootModel();
-
+
if (rootModel == getModel())
{
_viewIdFocusPathMap = new HashMap<String,List<Object>>();
_nodeFocusPathMap = new HashMap<Object, List<Object>>();
_idNodeMap = new HashMap<String, Object>();
- Object oldPath = treeModel.getRowKey();
-
+ Object oldPath = treeModel.getRowKey();
+
treeModel.setRowKey(null);
-
+
// Populate the maps
_addToMaps(treeModel, _viewIdFocusPathMap, _nodeFocusPathMap, _idNodeMap);
-
+
// Cache the maps. There is a possibility of multiple
// root models so we must cache the maps on a per root model
// basis.
_viewIdFocusPathMapMap.put(_currentTreeModelMapKey, _viewIdFocusPathMap);
_nodeFocusPathMapMap.put(_currentTreeModelMapKey, _nodeFocusPathMap);
_idNodeMapMap.put(_currentTreeModelMapKey, _idNodeMap);
-
+
treeModel.setRowKey(oldPath);
}
}
}
-
+
/**
* Get the Model's viewIdFocusPathMap
- *
+ *
* @return the Model's viewIdFocusPathMap
*/
public Map<String, List<Object>> getViewIdFocusPathMap(Object modelKey)
{
- return _viewIdFocusPathMapMap.get(modelKey);
+ return _viewIdFocusPathMapMap.get(modelKey);
}
-
+
/**
* Get the Model's nodeFocusPathMap
- *
+ *
* @return the Model's nodeFocusPathMap
*/
public Map<Object, List<Object>> getNodeFocusPathMap(Object modelKey)
{
- return _nodeFocusPathMapMap.get(modelKey);
+ return _nodeFocusPathMapMap.get(modelKey);
}
/**
* Get the Model's idNodeMap
- *
+ *
* @return the Model's idNodeMap
*/
public Map<String, Object> getIdNodeMap(Object modelKey)
{
- return _idNodeMapMap.get(modelKey);
+ return _idNodeMapMap.get(modelKey);
}
/**
* Get the treeModel built during parsing
- *
+ *
* @return List of menu nodes.
*/
public TreeModel getTreeModel(String uri)
{
TreeModel model = _treeModelMap.get(uri);
- // If we have a cached model, return it.
+ // If we have a cached model, return it.
if (model != null)
return model;
@@ -503,9 +505,9 @@
// and SAXParser here.
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parser = factory.newSAXParser();
-
+
// Call the local menu model's getStream() method. This is a model
- // method so that it can be overridden by any model extending
+ // method so that it can be overridden by any model extending
// XmlMenuModel.
InputStream inStream = getModel().getStream(uri);
@@ -516,7 +518,7 @@
}
catch (SAXException saxex)
{
- _LOG.severe ( "SAX Parse Exception parsing " + uri + ": " +
+ _LOG.severe ( "SAX Parse Exception parsing " + uri + ": " +
saxex.getMessage(), saxex);
}
catch (IOException ioe)
@@ -538,41 +540,41 @@
/**
* Get the top-level, root menu model, which contains
* the entire menu tree.
- *
+ *
* @return root, top-level XMLMenuModel
*/
@SuppressWarnings("unchecked")
public XMLMenuModel getRootModel()
{
FacesContext facesContext = FacesContext.getCurrentInstance();
- Map<String, Object> requestMap =
+ Map<String, Object> requestMap =
facesContext.getExternalContext().getRequestMap();
-
+
XMLMenuModel model = (XMLMenuModel) requestMap.get(getRootModelKey());
return model;
}
-
+
/**
* Get the top-level, root menu model's Request Map Key.
- *
+ *
* @return root, top-level XMLMenuModel's Request Map Key.
*/
public String getRootModelKey()
{
return _rootModelKey;
}
-
+
/**
* Sets the root menu Model's Request map key.
* <p>
* This is always only the top-level, root model's Request map key.
- * We do this because the MenuContentHandlerImpl and nodes need to be able
+ * We do this because the MenuContentHandlerImpl and nodes need to be able
* to call into the root model to:
* <ul>
* <li>notify them root menu model of the currently selected node on a POST
* <li>group node needs to find its referenced item node.
* </ul>
- *
+ *
* @param rootModelKey - String the root, top-level menu model's Request
* map key.
*/
@@ -583,32 +585,32 @@
/**
* Get the local (sharedNode) menu model.
- *
+ *
* @return sharedNode's XMLMenuModel
*/
@SuppressWarnings("unchecked")
public XMLMenuModel getModel()
{
FacesContext facesContext = FacesContext.getCurrentInstance();
- Map<String, Object> requestMap =
+ Map<String, Object> requestMap =
facesContext.getExternalContext().getRequestMap();
-
+
return (XMLMenuModel) requestMap.get(getModelUri());
}
-
+
/**
* Get the local (sharedNode) menu model's Uri.
- *
+ *
* @return sharedNode's XMLMenuModel Uri
*/
public String getModelUri()
{
return _localModelUri;
}
-
+
/**
* Sets the local (sharedNode's) menu Model's Uri.
- *
+ *
* @param localModelUri - String the root, top-level menu model's Uri.
*/
public void setModelUri(String localModelUri)
@@ -617,56 +619,56 @@
}
/**
- * Sets the treeModel map key used to get a cached treeModel
+ * Sets the treeModel map key used to get a cached treeModel
* from the MenuContentHandlerImpl.
- *
+ *
* Note: this is set from the XMLMenuModel BEFORE parsing begins
- *
+ *
* @param uri String path to the menu model's metadata
*/
public void setTreeModelKey(String uri)
{
_currentTreeModelMapKey = uri;
}
-
+
//=======================================================================
// Package Private Methods
//=======================================================================
/**
* Gets the MenuContentHandlerImpl's id.
- *
+ *
* This is set in the MenuContentHandlerImpl's Constructor
* and is used to ensure that the all resource bundle keys
* and node ids are unique.
- *
+ *
* @return String handler id.
*/
String getHandlerId()
{
return _handlerId;
}
-
+
/**
* Returns the hashmap key for a resource bundle.
- *
+ *
* This the value of the "var" attribute for the menu root node
* from the menu's metadata
- *
+ *
* @return String hashmap key.
*/
String getBundleKey()
{
return _resBundleKey;
}
-
+
//=======================================================================
// Private Methods
//=======================================================================
-
+
/**
- * Create a Map of name/value pairs from the attrList given
+ * Create a Map of name/value pairs from the attrList given
* to us by the Sax parser.
- *
+ *
* @param attrList List of attributes of an XML element
* @return Map hashMap of attributes converted to name/value pairs.
*/
@@ -674,15 +676,15 @@
private Map<String, String> _getMapFromList(Attributes attrList)
{
Map<String, String> attrMap = new HashMap<String, String>();
-
+
for (int i=0; i < attrList.getLength(); i++)
{
attrMap.put(attrList.getQName(i), attrList.getValue(i) );
}
-
+
return attrMap;
}
-
+
/**
* Creates a MenuNode from attribute list.
*
@@ -691,19 +693,19 @@
private MenuNode _createMenuNode ()
{
// Get generic attributes
-
+
// If the node has rendered = false, do not create it.
// This is a security risk and cannot be allowed
String renderedStr = _getAndRemoveAttrValue(_RENDERED_ATTR);
-
+
// We do not create nodes whose rendered attr is false
- // and if the Root model or the local model's (sharedNode
+ // and if the Root model or the local model's (sharedNode
// model) says that nodes whose rendered attribute is false
// should not be created, then we don't either.
//
// This default value of false (don't create nodes whose
- // rendered attr is false) can be overridden by the
- // XMLMenuModel's managed property, createHiddenNodes.
+ // rendered attr is false) can be overridden by the
+ // XMLMenuModel's managed property, createHiddenNodes.
// Typically this is done in faces-config.xml
//
if ( "false".equals(renderedStr)
@@ -714,7 +716,7 @@
{
return null;
}
-
+
String label = _getAndRemoveAttrValue(_LABEL_ATTR);
String icon = _getAndRemoveAttrValue(_ICON_ATTR);
String disabledStr = _getAndRemoveAttrValue(_DISABLED_ATTR);
@@ -723,12 +725,12 @@
String labelAndAccessKey = _getAndRemoveAttrValue(_LABEL_AND_ACCESSKEY_ATTR);
String id = _getAndRemoveAttrValue(_ID_ATTR);
String visibleStr = _getAndRemoveAttrValue(_VISIBLE_ATTR);
-
+
MenuNode menuNode = ( _currentNodeStyle == MenuConstants.NODE_STYLE_ITEM
? _createItemNode()
: _createGroupNode()
);
-
+
// Set the generic attributes
menuNode.setLabel(label);
menuNode.setIcon(icon);
@@ -738,22 +740,22 @@
menuNode.setAccessKey(accessKey);
menuNode.setId(id);
menuNode.setVisible(visibleStr);
-
+
if (labelAndAccessKey != null)
menuNode.setLabelAndAccessKey(labelAndAccessKey);
return menuNode;
}
-
+
/**
- * Creates an itemNode from attribute list obtained by parsing an
+ * Creates an itemNode from attribute list obtained by parsing an
* itemNode menu metadata entry.
- *
+ *
* @return Node of type ItemNode.
*/
private ItemNode _createItemNode()
{
- // Create the itemNode
+ // Create the itemNode
ItemNode itemNode = new ItemNode();
String action = _getAndRemoveAttrValue(_ACTION_ATTR);
@@ -770,10 +772,10 @@
// Former Destination node attrs
String destination = _getAndRemoveAttrValue(_DESTINATION_ATTR);
String targetFrame = _getAndRemoveAttrValue(_TARGETFRAME_ATTR);
-
+
// An item node with one of two(2) possible values:
// 1) outcome
- // 2) EL method binding (which can return either a URI or
+ // 2) EL method binding (which can return either a URI or
// an outcome
// Set its properties - null is ok.
@@ -791,38 +793,38 @@
// Former destination node attrs
itemNode.setDestination(destination);
itemNode.setTargetFrame(targetFrame);
-
+
// Set the Any Attributes Attrlist
if (_attrMap.size() > 0)
{
itemNode.setCustomPropList(_attrMap);
}
-
+
return itemNode;
}
/**
* Creates a GroupNode from attribute list passed obtained by parsing
* a GroupNode menu metadata entry.
- *
+ *
* @return Node of type GroupNode
*/
private GroupNode _createGroupNode()
{
- // Create the GroupNode
+ // Create the GroupNode
GroupNode groupNode = new GroupNode();
String idRef = _getAndRemoveAttrValue(_IDREF_ATTR);
-
+
// Set its attributes - null is ok
groupNode.setIdRef(idRef);
-
+
return groupNode;
}
/**
- * Saves all information needed for parsing and building model data
+ * Saves all information needed for parsing and building model data
* before recursing into the new model of a sharedNode.
- *
+ *
* Note: if you add a new push in this method, you must also add
* a corresponding pop in _restoreModelData() below in the correct order.
*/
@@ -837,16 +839,16 @@
// DO NOT CHANGE THE ORDER HERE. IT MUST MATCH
// "pops" DONE BELOW in _restoreModelData.
int nodeDepthSave = _nodeDepth;
- ArrayList<List<MenuNode>> menuNodesSave =
+ ArrayList<List<MenuNode>> menuNodesSave =
new ArrayList<List<MenuNode>>(_menuNodes);
-
-
- ArrayList<Object> menuListSave =
+
+
+ ArrayList<Object> menuListSave =
( _menuList != null
? new ArrayList<Object>(_menuList)
: null
);
-
+
String mapTreeKeySave = _currentTreeModelMapKey;
String localModelUriSave = _localModelUri;
String handlerId = _handlerId;
@@ -855,11 +857,11 @@
_saveDataStack.push(nodeDepthSave);
_saveDataStack.push(menuNodesSave);
_saveDataStack.push(menuListSave);
- _saveDataStack.push(mapTreeKeySave);
- _saveDataStack.push(localModelUriSave);
- _saveDataStack.push(handlerId);
- _saveDataStack.push(resBundleName);
- _saveDataStack.push(resBundleKey);
+ _saveDataStack.push(mapTreeKeySave);
+ _saveDataStack.push(localModelUriSave);
+ _saveDataStack.push(handlerId);
+ _saveDataStack.push(resBundleName);
+ _saveDataStack.push(resBundleKey);
}
/**
@@ -881,25 +883,25 @@
_currentTreeModelMapKey = (String) _saveDataStack.pop();
_menuList = (ArrayList<MenuNode>) _saveDataStack.pop();
_menuNodes = (ArrayList<List<MenuNode>>) _saveDataStack.pop();
- _nodeDepth = ((Integer)_saveDataStack.pop()).intValue();
+ _nodeDepth = ((Integer)_saveDataStack.pop()).intValue();
}
-
+
/**
* Gets the specified attribute's value from the Attributes List
- * passed in by the parser. Also removes this attribute so that
- * once we are finished processing and removing all the known
+ * passed in by the parser. Also removes this attribute so that
+ * once we are finished processing and removing all the known
* attributes, those left are custom attributes.
- *
+ *
* @param attrName
* @return String value of the attribute in the Attributes List.
*/
- private String _getAndRemoveAttrValue(String attrName)
+ private String _getAndRemoveAttrValue(String attrName)
{
String attrValue = _attrMap.get(attrName);
-
+
if (attrValue != null)
_attrMap.remove(attrName);
-
+
return attrValue;
}
@@ -907,9 +909,9 @@
* Menu Model Data Structure section.
* ======================================================================*/
/**
- * Traverses the tree and builds the model's viewIdFocusPathMap,
+ * Traverses the tree and builds the model's viewIdFocusPathMap,
* nodeFocusPathMap, and _idNodeMap
- *
+ *
* @param tree
*/
@SuppressWarnings("unchecked")
@@ -928,24 +930,24 @@
// Get its focus path
List<Object> focusPath = (List<Object>)tree.getRowKey();
-
+
// Get the focusViewId of the node
- Object viewIdObject = node.getFocusViewId();
-
+ Object viewIdObject = node.getFocusViewId();
+
if (viewIdObject != null)
- {
+ {
// Put this entry in the nodeFocusPathMap
nodeFocusPathMap.put(node, focusPath);
// Does this viewId already exist in the _viewIdFocusPathMap?
- List<Object> existingFpArrayList =
+ List<Object> existingFpArrayList =
_viewIdFocusPathMap.get(viewIdObject);
-
+
if (existingFpArrayList == null)
{
// This is a node with a unique focusViewId. Simply create
// and Arraylist and add the focusPath as the single entry
- // to the focus path ArrayList. Then put the focusPath
+ // to the focus path ArrayList. Then put the focusPath
// ArrayList in the focusPath HashMap.
List<Object> fpArrayList = new ArrayList<Object>();
fpArrayList.add(focusPath);
@@ -953,15 +955,15 @@
}
else
{
- // This is a node that points to the same viewId as at least one
+ // This is a node that points to the same viewId as at least one
// other node.
-
+
// If the node's defaultFocusPath is set to true, we move it to
- // the head of the ArrayList. The 0th element of the list is
- // always returned when navigation to a viewId occurs from outside
+ // the head of the ArrayList. The 0th element of the list is
+ // always returned when navigation to a viewId occurs from outside
// the menu model (that is _currentNode is null)
boolean defFocusPath = node.getDefaultFocusPath();
-
+
if (defFocusPath)
{
existingFpArrayList.add(0, focusPath);
@@ -969,18 +971,18 @@
else
{
existingFpArrayList.add(focusPath);
- }
+ }
}
}
-
+
// Get the Id of the node
- String idProp = node.getUniqueId();
-
+ String idProp = node.getUniqueId();
+
if (idProp != null)
{
idNodeMap.put(idProp, node);
}
-
+
if (tree.isContainer() && !tree.isContainerEmpty())
{
tree.enterContainer();
@@ -988,12 +990,12 @@
tree.exitContainer();
}
}
- }
-
+ }
+
//========================================================================
// Private variables
//========================================================================
-
+
private List<List<MenuNode>> _menuNodes;
private List<MenuNode> _menuList;
private String _currentTreeModelMapKey;
@@ -1003,21 +1005,21 @@
private String _handlerId;
private String _resBundleKey;
private String _resBundleName;
-
+
private Map<String, String> _attrMap;
private Map<String, TreeModel> _treeModelMap;
private Map<Object, Map<String, List<Object>>> _viewIdFocusPathMapMap;
private Map<Object, Map<String, Object>> _idNodeMapMap;
- private Map<Object, Map<Object, List<Object>>> _nodeFocusPathMapMap;
+ private Map<Object, Map<Object, List<Object>>> _nodeFocusPathMapMap;
private Stack<Object> _saveDataStack;
private Map<String, List<Object>> _viewIdFocusPathMap;
private Map<Object, List<Object>> _nodeFocusPathMap;
private Map<String, Object> _idNodeMap;
-
+
// Local (shared) Menu models Uri
private String _localModelUri = null;
-
+
// Root Menu model's Session map key
private String _rootModelKey = null;
@@ -1026,8 +1028,8 @@
private final static String _ITEM_NODE = "itemNode";
private final static String _SHARED_NODE = "sharedNode";
private final static String _ROOT_NODE = "menu";
-
- // Attributes
+
+ // Attributes
private final static String _LABEL_ATTR = "label";
private final static String _RENDERED_ATTR = "rendered";
private final static String _ID_ATTR = "id";
@@ -1036,7 +1038,7 @@
private final static String _DISABLED_ATTR = "disabled";
private final static String _DESTINATION_ATTR = "destination";
private final static String _ACTION_ATTR = "action";
- private final static String _REF_ATTR = "ref";
+ private final static String _REF_ATTR = "ref";
private final static String _READONLY_ATTR = "readOnly";
private final static String _VAR_ATTR = "var";
private final static String _RES_BUNDLE_ATTR = "resourceBundle";
@@ -1053,8 +1055,8 @@
private final static String _WINDOWWIDTH_ATTR = "windowWidth";
private final static String _DEFAULT_FOCUS_PATH_ATTR = "defaultFocusPath";
private final static String _VISIBLE_ATTR = "visible";
-
- private final static TrinidadLogger _LOG =
+
+ private final static TrinidadLogger _LOG =
TrinidadLogger.createTrinidadLogger(MenuContentHandlerImpl.class);
-
+
} // endclass MenuContentHandlerImpl
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuNode.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuNode.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuNode.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuNode.java Mon Nov 12 13:03:17 2007
@@ -745,9 +745,9 @@
if (str == null)
return null;
- String keystr = MenuUtils.stringReplaceFirst(str.trim(), _bundleKey,
+ String keystr = MenuUtils.stringReplaceFirst(str.trim(), _bundleKey,
_bundleKey + getHandlerId());
- String elVal = (String) MenuUtils.getBoundValue(keystr);
+ String elVal = MenuUtils.getBoundValue(keystr, String.class);
return elVal;
}
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuUtils.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuUtils.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuUtils.java Mon Nov 12 13:03:17 2007
@@ -30,8 +30,6 @@
import java.util.Set;
import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-
import javax.faces.webapp.UIComponentTag;
import org.apache.myfaces.trinidad.logging.TrinidadLogger;
@@ -76,10 +74,8 @@
* @param str2 - String to replace the first occurrence of str1
* @return StringBuffer
*/
- static StringBuffer stringBufferReplaceFirst(
- StringBuffer fullBuf,
- String str1,
- String str2)
+ static StringBuffer stringBufferReplaceFirst(StringBuffer fullBuf, String str1,
+ String str2)
{
if (fullBuf == null)
return null;
@@ -105,9 +101,8 @@
return returnBuf;
}
-
//=======================================================================
- // Bound Value/EL Binding utilities
+ // Bound Value/EL Expression utilities
//=======================================================================
/**
@@ -115,18 +110,17 @@
*
* @param elExpression - String representing an EL expression
*/
- static Object getBoundValue(String elExpression)
+ static <T> T getBoundValue(String elExpression, Class<T> desiredClass)
{
- Object retVal = null;
-
try
{
- // Value of rendered is EL method binding, so we
- // need to evaluate it
- FacesContext ctx = FacesContext.getCurrentInstance();
- ValueBinding binding =
- ctx.getApplication().createValueBinding(elExpression);
- retVal = binding.getValue(ctx);
+ if (desiredClass == null)
+ throw new NullPointerException();
+
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ return (T) ctx.getApplication().evaluateExpressionGet(ctx,
+ elExpression,
+ desiredClass);
}
catch (Exception ex)
{
@@ -135,7 +129,6 @@
_LOG.severe(ex);
return null;
}
- return retVal;
}
/**
@@ -160,7 +153,7 @@
&& UIComponentTag.isValueReference(boolStr)
)
{
- Boolean bValue = (Boolean) getBoundValue(boolStr);
+ Boolean bValue = getBoundValue(boolStr, Boolean.class);
return bValue.booleanValue();
}
else
@@ -184,7 +177,7 @@
&& UIComponentTag.isValueReference(propVal)
)
{
- String elVal = (String) getBoundValue(propVal);
+ String elVal = getBoundValue(propVal, String.class);
return elVal;
}
return propVal;
@@ -202,7 +195,7 @@
&& UIComponentTag.isValueReference(propVal)
)
{
- Integer elVal = (Integer) getBoundValue(propVal);
+ Integer elVal = getBoundValue(propVal, Integer.class);
return elVal.intValue();
}
return Integer.parseInt(propVal);
@@ -224,11 +217,17 @@
facesContext.getExternalContext().getApplicationMap();
// Get the request Locale
- Locale requestLocale = facesContext.getViewRoot().getLocale();
-
+ Locale requestLocale = facesContext.getExternalContext().getRequestLocale();
+
+ // Make sure it is not null
if (requestLocale == null)
{
- requestLocale = facesContext.getApplication().getDefaultLocale();
+ requestLocale = facesContext.getViewRoot().getLocale();
+
+ if (requestLocale == null)
+ {
+ requestLocale = facesContext.getApplication().getDefaultLocale();
+ }
}
// Is there a bundle with this key already on the session map?
@@ -260,7 +259,7 @@
// if _bundleName is an EL, then get its value
if (UIComponentTag.isValueReference(resBundle))
{
- bundleName = (String)MenuUtils.getBoundValue(resBundle);
+ bundleName = MenuUtils.getBoundValue(resBundle, String.class);
}
else
{
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderKit.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderKit.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderKit.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderKit.java Mon Nov 12 13:03:17 2007
@@ -602,8 +602,7 @@
}
else
{
- PartialPageContext ppc = rc.getPartialPageContext();
- if (ppc != null)
+ if (isPartialRequest(fContext.getExternalContext()))
rw = new PPRResponseWriter(rw, rc);
}
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreResponseStateManager.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreResponseStateManager.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreResponseStateManager.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreResponseStateManager.java Mon Nov 12 13:03:17 2007
@@ -69,7 +69,10 @@
ResponseWriter rw = context.getResponseWriter();
rw.startElement("input", null);
rw.writeAttribute("type", "hidden", null);
- rw.writeAttribute("name", _STATE_FIELD_NAME, null);
+ rw.writeAttribute("name", VIEW_STATE_PARAM, null);
+ // Don't write out the ID, as it can be written
+ // out twice
+ // rw.writeAttribute("id", VIEW_STATE_PARAM, null);
String s = encodeSerializedViewAsString(serializedView);
rw.writeAttribute("value", s, null);
@@ -77,6 +80,16 @@
rw.endElement("input");
}
+ @Override
+ /**
+ * A request is a postback if it contains the state parameter.
+ */
+ public boolean isPostback(FacesContext context)
+ {
+ Map requestParams = context.getExternalContext().getRequestParameterMap();
+ return requestParams.containsKey(VIEW_STATE_PARAM);
+ }
+
protected String encodeSerializedViewAsString(
StateManager.SerializedView serializedView) throws IOException
@@ -146,7 +159,7 @@
Map<String, String> requestParamMap =
context.getExternalContext().getRequestParameterMap();
- String stateString = requestParamMap.get(_STATE_FIELD_NAME);
+ String stateString = requestParamMap.get(VIEW_STATE_PARAM);
if (stateString == null)
return null;
@@ -196,8 +209,6 @@
return view;
}
-
- static private final String _STATE_FIELD_NAME = "org.apache.myfaces.trinidad.faces.STATE";
/* Test code for dumping out the page's state
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/skin/BaseSkin.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/skin/BaseSkin.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/skin/BaseSkin.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/skin/BaseSkin.java Mon Nov 12 13:03:17 2007
@@ -18,8 +18,7 @@
*/
package org.apache.myfaces.trinidadinternal.renderkit.core.skin;
-
-import javax.faces.el.ValueBinding;
+import javax.el.ValueExpression;
import org.apache.myfaces.trinidadinternal.skin.SkinImpl;
@@ -49,7 +48,7 @@
}
@Override
- protected ValueBinding getTranslationSourceValueBinding()
+ protected ValueExpression getTranslationSourceValueExpression()
{
return null;
}
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/EditableValueRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/EditableValueRenderer.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/EditableValueRenderer.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/EditableValueRenderer.java Mon Nov 12 13:03:17 2007
@@ -22,12 +22,13 @@
import java.util.Iterator;
+import javax.el.ValueExpression;
+
import javax.faces.component.EditableValueHolder;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
-import javax.faces.el.ValueBinding;
import javax.faces.validator.Validator;
import org.apache.myfaces.trinidad.logging.TrinidadLogger;
@@ -237,15 +238,15 @@
if (Boolean.TRUE.equals(o))
return true;
- // Now, if the ValueBinding underlying the value says it's
+ // Now, if the ValueExpression underlying the value says it's
// read-only, then again, it is.
- ValueBinding vb = getValueBinding(bean);
- if ((vb != null) && vb.isReadOnly(context))
+ ValueExpression ve = getValueExpression(bean);
+ if ((ve != null) && ve.isReadOnly(context.getELContext()))
{
if (_LOG.isFiner())
{
_LOG.finer("Value expression {0} is read-only",
- vb.getExpressionString());
+ ve.getExpressionString());
}
return true;
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputColorRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputColorRenderer.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputColorRenderer.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputColorRenderer.java Mon Nov 12 13:03:17 2007
@@ -77,7 +77,7 @@
{
FacesBean bean = getFacesBean(component);
// If there's a non-default action, then just launch away
- if (getAction(bean) != null)
+ if (getActionExpression(bean) != null)
{
super.queueActionEvent(context, component);
}
@@ -293,7 +293,7 @@
// If the field has an action, use the default behavior. Or,
// if the field doesn't support launching a window at all,
// use the default behavior.
- if ((getAction(bean) != null) ||
+ if ((getActionExpression(bean) != null) ||
!Boolean.TRUE.equals(
arc.getAgent().getCapabilities().get(TrinidadAgent.CAP_MULTIPLE_WINDOWS)))
return super.getLaunchOnclick(context, arc, component, bean);
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputDateRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputDateRenderer.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputDateRenderer.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputDateRenderer.java Mon Nov 12 13:03:17 2007
@@ -79,7 +79,7 @@
{
FacesBean bean = getFacesBean(component);
// If there's a non-default action, then just launch away
- if (getAction(bean) != null)
+ if (getActionExpression(bean) != null)
{
super.queueActionEvent(context, component);
}
@@ -357,7 +357,7 @@
// If the field has an action, use the default behavior. Or,
// if the field doesn't support launching a window at all,
// use the default behavior.
- if ((getAction(bean) != null) ||
+ if ((getActionExpression(bean) != null) ||
!Boolean.TRUE.equals(
arc.getAgent().getCapabilities().get(TrinidadAgent.CAP_MULTIPLE_WINDOWS)))
return super.getLaunchOnclick(context, arc, component, bean);
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputListOfValuesRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputListOfValuesRenderer.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputListOfValuesRenderer.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputListOfValuesRenderer.java Mon Nov 12 13:03:17 2007
@@ -63,7 +63,7 @@
super.findTypeConstants(type);
_searchDescKey = type.findKey("searchDesc");
_iconKey = type.findKey("icon");
- _actionKey = type.findKey("action");
+ _actionExpressionKey = type.findKey("actionExpression");
}
//
@@ -360,9 +360,9 @@
return true;
}
- protected Object getAction(FacesBean bean)
+ protected Object getActionExpression(FacesBean bean)
{
- return bean.getProperty(_actionKey);
+ return bean.getProperty(_actionExpressionKey);
}
protected String getSearchDesc(
@@ -395,7 +395,7 @@
return "af|inputListOfValues::content";
}
- private PropertyKey _actionKey;
+ private PropertyKey _actionExpressionKey;
private PropertyKey _iconKey;
private PropertyKey _searchDescKey;
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleSelectManyRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleSelectManyRenderer.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleSelectManyRenderer.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleSelectManyRenderer.java Mon Nov 12 13:03:17 2007
@@ -26,14 +26,14 @@
import java.util.Arrays;
import java.util.List;
+import javax.el.ValueExpression;
+
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
-import javax.faces.el.ValueBinding;
-
import javax.faces.model.SelectItem;
import org.apache.myfaces.trinidad.logging.TrinidadLogger;
@@ -95,10 +95,10 @@
converter = getDefaultConverter(context, bean);
Class<?> modelClass = null;
- ValueBinding binding = getValueBinding(bean);
- if (binding != null)
+ ValueExpression expression = getValueExpression(bean);
+ if (expression != null)
{
- modelClass = binding.getType(context);
+ modelClass = expression.getType(context.getELContext());
}
boolean valuePassThru = getValuePassThru(getFacesBean(component));
@@ -151,11 +151,11 @@
FacesContext context,
FacesBean bean)
{
- ValueBinding binding = getValueBinding(bean);
- if (binding == null)
+ ValueExpression expression = getValueExpression(bean);
+ if (expression == null)
return null;
- Class<?> type = binding.getType(context);
+ Class<?> type = expression.getType(context.getELContext());
if ((type == null) || type.isAssignableFrom(List.class))
return null;
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ValueRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ValueRenderer.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ValueRenderer.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ValueRenderer.java Mon Nov 12 13:03:17 2007
@@ -18,10 +18,11 @@
*/
package org.apache.myfaces.trinidadinternal.renderkit.core.xhtml;
+import javax.el.ValueExpression;
+
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
-import javax.faces.el.ValueBinding;
import org.apache.myfaces.trinidad.bean.FacesBean;
import org.apache.myfaces.trinidad.bean.PropertyKey;
@@ -70,11 +71,11 @@
FacesContext context,
FacesBean bean)
{
- ValueBinding binding = getValueBinding(bean);
- if (binding == null)
+ ValueExpression expression = getValueExpression(bean);
+ if (expression == null)
return null;
- Class<?> type = binding.getType(context);
+ Class<?> type = expression.getType(context.getELContext());
return ConverterUtils.createConverter(context, type);
}
@@ -84,11 +85,11 @@
}
/**
- * Returns the ValueBinding for the "value" property.
+ * Returns the ValueExpression for the "value" property.
*/
- protected ValueBinding getValueBinding(FacesBean bean)
+ protected ValueExpression getValueExpression(FacesBean bean)
{
- return bean.getValueBinding(_valueKey);
+ return bean.getValueExpression(_valueKey);
}
protected Converter getConverter(FacesBean bean)
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TableSelectOneRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TableSelectOneRenderer.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TableSelectOneRenderer.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TableSelectOneRenderer.java Mon Nov 12 13:03:17 2007
@@ -239,6 +239,13 @@
}
@Override
+ protected String getClientId(FacesContext context, UIComponent component)
+ {
+ // We use the table's container client ID
+ return component.getContainerClientId(context);
+ }
+
+ @Override
protected Object getSubmittedValue(FacesBean bean)
{
TableRenderingContext tContext =
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeNodeColumnRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeNodeColumnRenderer.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeNodeColumnRenderer.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeNodeColumnRenderer.java Mon Nov 12 13:03:17 2007
@@ -138,7 +138,7 @@
{
// we need to render a unique ID for the expand/collapse link, so that
// PPR can restore the focus correctly after a PPR request:
- String tableName = tContext.getTable().getClientId(fc);
+ String tableName = tContext.getTable().getContainerClientId(fc);
String id = tableName + NamingContainer.SEPARATOR_CHAR + _ICON_ID;
fc.getResponseWriter().writeAttribute("id", id, null);
}
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/htmlBasic/ComponentFacesBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/htmlBasic/ComponentFacesBean.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/htmlBasic/ComponentFacesBean.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/htmlBasic/ComponentFacesBean.java Mon Nov 12 13:03:17 2007
@@ -21,6 +21,8 @@
import java.util.Iterator;
import java.util.Set;
+import javax.el.ValueExpression;
+
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
@@ -68,9 +70,20 @@
throw new UnsupportedOperationException();
}
+
final public ValueBinding getValueBinding(PropertyKey key)
{
return _component.getValueBinding(key.getName());
+ }
+
+ final public ValueExpression getValueExpression(PropertyKey key)
+ {
+ return _component.getValueExpression(key.getName());
+ }
+
+ final public void setValueExpression(PropertyKey key, ValueExpression expression)
+ {
+ throw new UnsupportedOperationException();
}
final public Object getRawProperty(PropertyKey key)
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/uix/SelectItemSupport.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/uix/SelectItemSupport.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/uix/SelectItemSupport.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/uix/SelectItemSupport.java Mon Nov 12 13:03:17 2007
@@ -25,13 +25,14 @@
import java.util.List;
import java.util.Map;
+import javax.el.ValueExpression;
+
import javax.faces.component.UIComponent;
import javax.faces.component.UISelectItem;
import javax.faces.component.UISelectItems;
import javax.faces.component.ValueHolder;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
-import javax.faces.el.ValueBinding;
import javax.faces.model.SelectItem;
import org.apache.myfaces.trinidad.component.UIXSelectItem;
import org.apache.myfaces.trinidadinternal.convert.ConverterUtils;
@@ -373,13 +374,13 @@
Converter converter = null;
Class<?> modelClass = null;
- ValueBinding binding = component.getValueBinding("value");
- if (binding != null)
+ ValueExpression expression = component.getValueExpression("value");
+ if (expression != null)
{
- modelClass = binding.getType(fContext);
+ modelClass = expression.getType(fContext.getELContext());
if (modelClass == null)
{
- Object o = binding.getValue(fContext);
+ Object o = expression.getValue(fContext.getELContext());
if (o != null)
{
modelClass = o.getClass();
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/share/expl/Coercions.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/share/expl/Coercions.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/share/expl/Coercions.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/share/expl/Coercions.java Mon Nov 12 13:03:17 2007
@@ -180,6 +180,11 @@
{
return text;
}
+ else if (Enum.class.isAssignableFrom(type))
+ {
+ return Enum.valueOf((Class<? extends Enum>) type, text);
+ }
+
throw new IllegalArgumentException(_LOG.getMessage(
"CANNOT_BE_PARSED", new Object[]{text, type.getName()}));
}
@@ -275,6 +280,10 @@
Array.set(res, 0, arrayValue);
}
return res;
+ }
+ else if (Enum.class.isAssignableFrom(type))
+ {
+ return Enum.valueOf((Class<? extends Enum>) type, value.toString());
}
throw new IllegalArgumentException(_LOG.getMessage(
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinExtension.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinExtension.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinExtension.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinExtension.java Mon Nov 12 13:03:17 2007
@@ -23,9 +23,8 @@
import java.util.MissingResourceException;
import java.util.Stack;
+import javax.el.ValueExpression;
import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-
import org.apache.myfaces.trinidad.logging.TrinidadLogger;
import org.apache.myfaces.trinidad.context.LocaleContext;
import org.apache.myfaces.trinidad.context.RenderingContext;
@@ -101,7 +100,7 @@
_renderKitId = renderKitId;
_styleSheetName = styleSheetName;
_bundleName = resourceBundleName;
- _translationSourceVB = null;
+ _translationSourceVE = null;
}
/**
@@ -129,8 +128,8 @@
* Must be non-null.
* @param renderKitId The render-kit-id that this Skin is designed for.
* @param styleSheetName The name of the stylesheet for this Skin.
- * @param translationSourceValueBinding
- * A ValueBinding that points to a translation source of type
+ * @param translationSourceValueExpression
+ * A ValueExpression that points to a translation source of type
* Map or ResourceBundle. This can be used instead of a
* resource bundle name.
* @throws NullPointerException if baseSkin, id, or family is null.
@@ -142,7 +141,7 @@
String family,
String renderKitId,
String styleSheetName,
- ValueBinding translationSourceValueBinding
+ ValueExpression translationSourceValueExpression
)
{
if (baseSkin == null)
@@ -161,7 +160,7 @@
_renderKitId = renderKitId;
_styleSheetName = styleSheetName;
_bundleName = null;
- _translationSourceVB = translationSourceValueBinding;
+ _translationSourceVE = translationSourceValueExpression;
}
@@ -218,7 +217,7 @@
_renderKitId = renderKitId;
_styleSheetName = styleSheetName;
_bundleName = null;
- _translationSourceVB = null;
+ _translationSourceVE = null;
}
/**
* Creates a Skin which extends the specified base
@@ -331,15 +330,15 @@
}
/**
- * Returns the translation source ValueBinding for the SkinExtension.
+ * Returns the translation source ValueExpression for the SkinExtension.
* Note: A skin cannot have both a bundleName and a translation source
- * value binding. If they do, then the bundlename takes precedence.
+ * value expression. If they do, then the bundlename takes precedence.
* A translation source can be a map of keys/values or a ResourceBundle.
*/
@Override
- public ValueBinding getTranslationSourceValueBinding()
+ public ValueExpression getTranslationSourceValueExpression()
{
- return _translationSourceVB;
+ return _translationSourceVE;
}
/**
@@ -386,7 +385,7 @@
// Look for the skin's translated value
// -first Skin's translation source, then SkinAddition translation sources.
// A translation source is either a bundleName or
- // a translationSourceValueBinding
+ // a translationSourceValueExpression
// If that's not found, then look in the base skin's translated value.
// getCachedTranslatedValue will protect against MissingResourceExceptions
@@ -651,7 +650,7 @@
private SkinImpl _baseSkin;
private String _styleSheetName;
private String _bundleName;
- private ValueBinding _translationSourceVB;
+ private ValueExpression _translationSourceVE;
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinImpl.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinImpl.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinImpl.java Mon Nov 12 13:03:17 2007
@@ -34,6 +34,9 @@
import java.util.concurrent.atomic.AtomicInteger;
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
@@ -477,19 +480,19 @@
* We differentiate between the two types of resource bundles so that
* the Skin's own resource bundle can take precedence.
* Note: A skin cannot have both a bundleName and a translation source
- * value binding. If they do, then the bundlename takes precedence.
+ * value expression. If they do, then the bundlename takes precedence.
*/
abstract protected String getBundleName();
/**
- * Returns the ValueBinding of the translation source for this Skin instance.
+ * Returns the ValueExpression of the translation source for this Skin instance.
* This does not include the SkinAddition translation source.
* The Skin's own resource bundle or translation source can take precedence
* over the SkinAdditions resource bundle or translation source.
* Note: A skin cannot have both a bundleName and a translation source
* value expression. If they do, then the bundleName takes precedence.
*/
- abstract protected ValueBinding getTranslationSourceValueBinding();
+ abstract protected ValueExpression getTranslationSourceValueExpression();
/**
* Find the actual icon
@@ -772,11 +775,11 @@
/*
* Returns the List of TranslationSource. A TranslationSource can be
- * a resource bundle name or a translation-source ValueBinding that
+ * a resource bundle name or a translation-source ValueExpression that
* resolves to a Map or a ResourceBundle.
* The List indlues TranslationSources from the Skin and the SkinAdditions.
* @see #getBundleName()
- * @see #getTranslationSourceValueBinding()
+ * @see #getTranslationSourceValueExpression()
*/
private List<TranslationSource> _getTranslationSourceList()
{
@@ -793,9 +796,9 @@
int translationSourceCount = 0;
String bName = getBundleName();
- ValueBinding ve = null;
+ ValueExpression ve = null;
if (bName == null)
- ve = getTranslationSourceValueBinding();
+ ve = getTranslationSourceValueExpression();
if (bName != null || ve != null)
translationSourceCount++;
@@ -808,11 +811,11 @@
// First put in the Skin's translation information, then the SkinAdditions'
// translation information.
- // Note: bundleName takes precedence over translationSourceValueBinding.
+ // Note: bundleName takes precedence over translationSourceValueExpression.
if (bName != null)
translationSourceList.add(new ResourceBundleNameTranslationSource(bName));
else if (ve != null)
- translationSourceList.add(new ValueBindingTranslationSource(ve));
+ translationSourceList.add(new ValueExprTranslationSource(ve));
for (SkinAddition add : additions)
{
@@ -821,9 +824,18 @@
translationSourceList.add(new ResourceBundleNameTranslationSource(name));
else
{
+ ValueExpression additionVe = add.getTranslationSourceValueExpression();
+ if (additionVe != null)
+ translationSourceList.add(new ValueExprTranslationSource(additionVe));
+ else
+ {
+ // try the deprecated ValueBinding last.
+ // This code can be deleted when we delete the deprecated api
+ // SkinAddition's getTranslationSourceValueBinding
ValueBinding additionVb = add.getTranslationSourceValueBinding();
if (additionVb != null)
translationSourceList.add(new ValueBindingTranslationSource(additionVb));
+ }
}
}
@@ -1067,6 +1079,48 @@
public final String _bundleName;
}
+ private static class ValueExprTranslationSource implements TranslationSource
+ {
+
+ public ValueExprTranslationSource(
+ ValueExpression ve)
+ {
+ _translationSourceVE = ve;
+ }
+
+ // fill in the keyValueMap from a ValueExpression. The ValueExpression
+ // types that we support are Map and ResourceBundle.
+ // If checkForKey is true, it will not overwrite if the key exists already.
+ public void fillInKeyValueMap(
+ LocaleContext lContext,
+ Map keyValueMap,
+ boolean checkForKey)
+ {
+ ELContext elContext = FacesContext.getCurrentInstance().getELContext();
+
+ Object veValue = _translationSourceVE.getValue(elContext);
+
+ if (veValue instanceof Map)
+ {
+ Map<String, String> translationSourceMap =
+ (Map<String, String>)_translationSourceVE.getValue(elContext);
+ _fillInKeyValueMapFromMap(translationSourceMap, keyValueMap, checkForKey);
+ }
+ else if (veValue instanceof ResourceBundle)
+ {
+ ResourceBundle bundle =
+ (ResourceBundle)_translationSourceVE.getValue(elContext);
+ _fillInKeyValueMapFromResourceBundle(bundle, keyValueMap, checkForKey);
+ }
+ else
+ {
+ _LOG.warning("INVALID_TRANSLATION_SOURCE_VE_TYPE");
+ }
+ }
+
+ public final ValueExpression _translationSourceVE;
+ }
+
private static class ValueBindingTranslationSource implements TranslationSource
{
Modified: myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinNotAvailable.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinNotAvailable.java?rev=594297&r1=594296&r2=594297&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinNotAvailable.java (original)
+++ myfaces/trinidad/branches/1.2.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinNotAvailable.java Mon Nov 12 13:03:17 2007
@@ -18,8 +18,7 @@
*/
package org.apache.myfaces.trinidadinternal.skin;
-
-import javax.faces.el.ValueBinding;
+import javax.el.ValueExpression;
import org.apache.myfaces.trinidad.context.LocaleContext;
@@ -61,7 +60,7 @@
@Override
- protected ValueBinding getTranslationSourceValueBinding()
+ protected ValueExpression getTranslationSourceValueExpression()
{
return null;
}