Author: alexsmirnov
Date: 2008-03-26 17:42:04 -0400 (Wed, 26 Mar 2008)
New Revision: 7281
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java
trunk/framework/impl/src/main/java/org/ajax4jsf/application/TreeStrutureNode.java
trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
Log:
fix
http://jira.jboss.com/jira/browse/RF-2737
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java 2008-03-26
20:51:48 UTC (rev 7280)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java 2008-03-26
21:42:04 UTC (rev 7281)
@@ -73,18 +73,20 @@
return null;
}
+ @SuppressWarnings("deprecation")
public SerializedView saveSerializedView(FacesContext arg0) {
// delegate to enclosed class method.
return buildSerializedView(arg0);
}
+ @SuppressWarnings("deprecation")
public void writeState(FacesContext arg0, SerializedView arg1)
throws IOException {
// do nothing
}
}
- private static final Class[] STATE_MANAGER_ARGUMENTS = new Class[] { StateManager.class
};
+ private static final Class<StateManager> STATE_MANAGER_ARGUMENTS =
StateManager.class;
public static final int DEFAULT_NUMBER_OF_VIEWS = 16;
@@ -121,11 +123,11 @@
classLoader = AjaxStateManager.class.getClassLoader();
}
try {
- Class seamStateManagerClass = classLoader
- .loadClass("org.jboss.seam.jsf.SeamStateManager");
- Constructor constructor = seamStateManagerClass
+ Class<? extends StateManager> seamStateManagerClass = classLoader
+ .loadClass("org.jboss.seam.jsf.SeamStateManager").asSubclass(StateManager.class);
+ Constructor<? extends StateManager> constructor = seamStateManagerClass
.getConstructor(STATE_MANAGER_ARGUMENTS);
- seamStateManager = (StateManager) constructor
+ seamStateManager = constructor
.newInstance(new Object[] { new SeamStateManagerWrapper() });
if (_log.isDebugEnabled()) {
_log.debug("Create instance of the SeamStateManager");
@@ -156,7 +158,7 @@
*/
protected Object getTreeStructureToSave(FacesContext context) {
TreeStrutureNode treeStructure = new TreeStrutureNode();
- treeStructure.apply(context, context.getViewRoot(), new HashSet());
+ treeStructure.apply(context, context.getViewRoot(), new HashSet<String>());
return treeStructure;
}
@@ -188,6 +190,7 @@
* @see
javax.faces.application.StateManager#writeState(javax.faces.context.FacesContext,
* javax.faces.application.StateManager.SerializedView)
*/
+ @SuppressWarnings("deprecation")
public void writeState(FacesContext context, SerializedView state)
throws IOException {
parent.writeState(context, state);
@@ -204,6 +207,7 @@
* @see
javax.faces.application.StateManager#restoreView(javax.faces.context.FacesContext,
* java.lang.String, java.lang.String)
*/
+ @SuppressWarnings("deprecation")
public UIViewRoot restoreView(FacesContext context, String viewId,
String renderKitId) {
UIViewRoot viewRoot = null;
@@ -244,6 +248,7 @@
return restoredState;
}
+ @SuppressWarnings("deprecation")
public SerializedView saveSerializedView(FacesContext context) {
if (null == seamStateManager) {
return buildSerializedView(context);
@@ -257,6 +262,7 @@
* @param context
* @return
*/
+ @SuppressWarnings("deprecation")
protected SerializedView buildSerializedView(FacesContext context) {
SerializedView serializedView = null;
UIViewRoot viewRoot = context.getViewRoot();
@@ -280,6 +286,7 @@
* @param state
* @return
*/
+ @SuppressWarnings("deprecation")
protected SerializedView saveStateInSession(FacesContext context,
Object treeStructure, Object state) {
SerializedView serializedView;
@@ -315,6 +322,7 @@
* @param renderKitId
* @return
*/
+ @SuppressWarnings("deprecation")
protected Object restoreLogicalViewId(FacesContext context, String viewId,
String renderKitId) {
Object id = getRenderKit(context, renderKitId)
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/TreeStrutureNode.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/application/TreeStrutureNode.java 2008-03-26
20:51:48 UTC (rev 7280)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/application/TreeStrutureNode.java 2008-03-26
21:42:04 UTC (rev 7281)
@@ -54,24 +54,24 @@
for (Iterator<Entry<String,UIComponent>> i =
componentFacets.entrySet().iterator(); i
.hasNext();) {
Entry<String,UIComponent> element = i.next();
- UIComponent f = (UIComponent) element.getValue();
+ UIComponent f = element.getValue();
if (!f.isTransient()) {
TreeStrutureNode facet = new TreeStrutureNode();
facet.apply(context, f, uniqueIds);
if (null == facets) {
- facets = new HashMap();
+ facets = new HashMap<String, TreeStrutureNode>();
}
facets.put(element.getKey(), facet);
}
}
- for (Iterator i = component.getChildren().iterator(); i.hasNext();) {
- UIComponent child = (UIComponent) i.next();
+ for (Iterator<UIComponent> i = component.getChildren().iterator(); i.hasNext();)
{
+ UIComponent child = i.next();
if (!child.isTransient()) {
TreeStrutureNode t = new TreeStrutureNode();
t.apply(context, child, uniqueIds);
if (null == children) {
- children = new ArrayList();
+ children = new ArrayList<TreeStrutureNode>();
}
children.add(t);
@@ -93,8 +93,8 @@
}
if (null != children) {
- for (Iterator i = children.iterator(); i.hasNext();) {
- TreeStrutureNode node = (TreeStrutureNode) i.next();
+ for (Iterator<TreeStrutureNode> i = children.iterator(); i.hasNext();) {
+ TreeStrutureNode node = i.next();
UIComponent child = node.restore(loader);
component.getChildren().add(child);
}
@@ -106,7 +106,7 @@
/**
* @return the facets
*/
- public Map getFacets() {
+ public Map<String, TreeStrutureNode> getFacets() {
return facets;
}
@@ -114,14 +114,14 @@
* @param facets
* the facets to set
*/
- public void setFacets(Map facets) {
+ public void setFacets(Map<String, TreeStrutureNode> facets) {
this.facets = facets;
}
/**
* @return the children
*/
- public List getChildren() {
+ public List<TreeStrutureNode> getChildren() {
return children;
}
@@ -129,7 +129,7 @@
* @param children
* the children to set
*/
- public void setChildren(List children) {
+ public void setChildren(List<TreeStrutureNode> children) {
this.children = children;
}
@@ -172,7 +172,7 @@
}
int facetsSize = in.readInt();
if (facetsSize > 0) {
- facets = new HashMap(facetsSize);
+ facets = new HashMap<String, TreeStrutureNode>(facetsSize);
for (int i = 0; i < facetsSize; i++) {
String facetName = in.readUTF();
TreeStrutureNode facet = new TreeStrutureNode();
@@ -182,7 +182,7 @@
}
int childrenSize = in.readInt();
if (childrenSize > 0) {
- children = new ArrayList(childrenSize);
+ children = new ArrayList<TreeStrutureNode>(childrenSize);
for (int i = 0; i < childrenSize; i++) {
TreeStrutureNode child = new TreeStrutureNode();
child.readExternal(in);
@@ -196,10 +196,10 @@
out.writeUTF(null == id ? NULL_ID : id);
if (null != facets) {
out.writeInt(facets.size());
- for (Iterator i = facets.entrySet().iterator(); i.hasNext();) {
- Map.Entry entry = (Map.Entry) i.next();
- out.writeUTF((String) entry.getKey());
- TreeStrutureNode node = (TreeStrutureNode) entry.getValue();
+ for (Iterator<Map.Entry<String, TreeStrutureNode>> i =
facets.entrySet().iterator(); i.hasNext();) {
+ Map.Entry<String, TreeStrutureNode> entry = i.next();
+ out.writeUTF(entry.getKey());
+ TreeStrutureNode node = entry.getValue();
node.writeExternal(out);
}
@@ -208,8 +208,8 @@
}
if (null != children) {
out.writeInt(children.size());
- for (Iterator i = children.iterator(); i.hasNext();) {
- TreeStrutureNode child = (TreeStrutureNode) i.next();
+ for (Iterator<TreeStrutureNode> i = children.iterator(); i.hasNext();) {
+ TreeStrutureNode child = i.next();
child.writeExternal(out);
}
Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2008-03-26 20:51:48 UTC
(rev 7280)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2008-03-26 21:42:04 UTC
(rev 7281)
@@ -255,21 +255,18 @@
// first attempt - .getElementById.
var oDoc = this._request.responseXML;
if(oDoc){
- if(typeof(oDoc.getElementById) != 'undefined') {
+ if(typeof(oDoc.evaluate) != 'undefined') {
+ // Xpath is prefer to use, so it work in the Firefox without XHTML xml namespace
in the result.
+ LOG.debug("call XMLDocument.evaluate for id= "+id);
+ return
oDoc.evaluate("//*[(a)id='"+id+"']",oDoc,null,9,null).singleNodeValue;//
9 - XPathResult.FIRST_ORDERED_NODE_TYPE
+ } else if(typeof(oDoc.getElementById) != 'undefined') {
LOG.debug("call getElementById for id= "+id);
- return oDoc.getElementById(id);
- }
- else if(typeof(oDoc.selectSingleNode) != "undefined") {
+ var element = oDoc.getElementById(id);
+ } else if(typeof(oDoc.selectSingleNode) != "undefined") {
LOG.debug("call selectSingleNode for id= "+id);
return oDoc.selectSingleNode("//*[@id='"+id+"']"); /*
XPATH istead of ID */
- }
- // nodeFromID not worked since XML validation disabled by
- // default for MS
- else if(typeof(oDoc.nodeFromID) != "undefined") {
- LOG.debug("call nodeFromID for id= "+id);
- return oDoc.nodeFromID(id);
- }
- LOG.error("No functions for getElementById found ");
+ }
+ LOG.error("No functions for getElementById found ");
} else {
LOG.debug("No parsed XML document in response");
}