You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mb...@apache.org on 2005/10/25 18:22:13 UTC
svn commit: r328404 [3/3] - in /myfaces:
examples/trunk/simple/css/jscookmenu/
examples/trunk/simple/css/jscookmenu/ThemeOffice/
sandbox/trunk/src/java/org/apache/myfaces/custom/accordion/
sandbox/trunk/src/java/org/apache/myfaces/custom/autoupdatedata...
Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/tree/HtmlTree.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/tree/HtmlTree.java?rev=328404&r1=328403&r2=328404&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/tree/HtmlTree.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/tree/HtmlTree.java Tue Oct 25 09:21:17 2005
@@ -16,14 +16,16 @@
package org.apache.myfaces.custom.tree;
import java.io.IOException;
-import java.util.*;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
import javax.faces.component.UIViewRoot;
import javax.faces.component.html.HtmlPanelGroup;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
-import org.apache.myfaces.component.html.util.AddResource;
import org.apache.myfaces.custom.tree.event.TreeSelectionEvent;
import org.apache.myfaces.custom.tree.event.TreeSelectionListener;
import org.apache.myfaces.custom.tree.model.TreeModel;
@@ -52,7 +54,7 @@
public class HtmlTree extends HtmlPanelGroup implements TreeModelListener
{
- public static final int DEFAULT_EXPIRE_LISTENERS = 8 * 60 * 60 * 1000; // 8 hours
+ public static final long DEFAULT_EXPIRE_LISTENERS = 8 * 60 * 60 * 1000; // 8 hours
private static final String FACET_ROOTNODE = "rootNode";
private static final String PREVIOUS_VIEW_ROOT = HtmlTree.class.getName() + ".PREVIOUS_VIEW_ROOT";
private static final int EVENT_CHANGED = 0;
@@ -61,21 +63,6 @@
private static final int EVENT_STRUCTURE_CHANGED = 3;
private static int counter = 0;
- // Defaut images
- private static final String DEFAULT_IMAGE_ICON_LINE = "images/line.gif";
- private static final String DEFAULT_IMAGE_ICON_NOLINE = "images/noline.gif";
- private static final String DEFAULT_IMAGE_ICON_CHILD_FIRST = "images/line_first.gif";
- private static final String DEFAULT_IMAGE_ICON_CHILD_MIDDLE = "images/line_middle.gif";
- private static final String DEFAULT_IMAGE_ICON_CHILD_LAST = "images/line_last.gif";
- private static final String DEFAULT_IMAGE_ICON_NODE_OPEN = "images/node_open.gif";
- private static final String DEFAULT_IMAGE_ICON_NODE_OPEN_FIRST = "images/node_open_first.gif";
- private static final String DEFAULT_IMAGE_ICON_NODE_OPEN_MIDDLE = "images/node_open_middle.gif";
- private static final String DEFAULT_IMAGE_ICON_NODE_OPEN_LAST = "images/node_open_last.gif";
- private static final String DEFAULT_IMAGE_ICON_NODE_CLOSE = "images/node_close.gif";
- private static final String DEFAULT_IMAGE_ICON_NODE_CLOSE_FIRST = "images/node_close_first.gif";
- private static final String DEFAULT_IMAGE_ICON_NODE_CLOSE_MIDDLE = "images/node_close_middle.gif";
- private static final String DEFAULT_IMAGE_ICON_NODE_CLOSE_LAST = "images/node_close_last.gif";
-
private IconProvider iconProvider;
private boolean itemStatesRestored = false;
private String var;
@@ -101,7 +88,7 @@
private int uniqueIdCounter = 0;
private int[] selectedPath;
private int internalId;
- private long expireListeners = DEFAULT_EXPIRE_LISTENERS;
+ private Long expireListeners;
/**
@@ -172,16 +159,29 @@
this.var = var;
}
+ protected String getStringValue(String value, String vbName)
+ {
+ if(value != null)
+ {
+ return value;
+ }
+ ValueBinding vb = getValueBinding(vbName);
+ if(vb != null)
+ {
+ Object obj = vb.getValue(getFacesContext());
+ if(obj != null)
+ {
+ return obj.toString();
+ }
+ }
+ return null;
+ }
public String getIconLine()
{
- if( iconLine != null )
- return iconLine;
-
- return getDefaultImagePath( DEFAULT_IMAGE_ICON_LINE );
+ return getStringValue(iconLine, "iconLine");
}
-
public void setIconLine(String iconLine)
{
this.iconLine = iconLine;
@@ -190,10 +190,7 @@
public String getIconNoline()
{
- if( iconNoline != null )
- return iconNoline;
-
- return getDefaultImagePath( DEFAULT_IMAGE_ICON_NOLINE );
+ return getStringValue(iconNoline, "iconNoline");
}
@@ -205,10 +202,7 @@
public String getIconChildFirst()
{
- if( iconChildFirst != null )
- return iconChildFirst;
-
- return getDefaultImagePath( DEFAULT_IMAGE_ICON_CHILD_FIRST );
+ return getStringValue(iconChildFirst, "iconChildFirst");
}
@@ -220,10 +214,7 @@
public String getIconChildMiddle()
{
- if( iconChildMiddle != null )
- return iconChildMiddle;
-
- return getDefaultImagePath( DEFAULT_IMAGE_ICON_CHILD_MIDDLE );
+ return getStringValue(iconChildMiddle, "iconChildMiddle");
}
@@ -235,10 +226,7 @@
public String getIconChildLast()
{
- if( iconChildLast != null )
- return iconChildLast;
-
- return getDefaultImagePath( DEFAULT_IMAGE_ICON_CHILD_LAST );
+ return getStringValue(iconChildLast, "iconChildLast");
}
@@ -250,10 +238,7 @@
public String getIconNodeOpen()
{
- if( iconNodeOpen != null )
- return iconNodeOpen;
-
- return getDefaultImagePath( DEFAULT_IMAGE_ICON_NODE_OPEN );
+ return getStringValue(iconNodeOpen, "iconNodeOpen");
}
@@ -265,10 +250,7 @@
public String getIconNodeOpenFirst()
{
- if( iconNodeOpenFirst != null )
- return iconNodeOpenFirst;
-
- return getDefaultImagePath( DEFAULT_IMAGE_ICON_NODE_OPEN_FIRST );
+ return getStringValue(iconNodeOpenFirst, "iconNodeOpenFirst");
}
@@ -280,10 +262,7 @@
public String getIconNodeOpenMiddle()
{
- if( iconNodeOpenMiddle != null )
- return iconNodeOpenMiddle;
-
- return getDefaultImagePath( DEFAULT_IMAGE_ICON_NODE_OPEN_MIDDLE );
+ return getStringValue(iconNodeOpenMiddle, "iconNodeOpenMiddle");
}
@@ -295,10 +274,7 @@
public String getIconNodeOpenLast()
{
- if( iconNodeOpenLast != null )
- return iconNodeOpenLast;
-
- return getDefaultImagePath( DEFAULT_IMAGE_ICON_NODE_OPEN_LAST );
+ return getStringValue(iconNodeOpenLast, "iconNodeOpenLast");
}
@@ -310,10 +286,7 @@
public String getIconNodeClose()
{
- if( iconNodeClose != null )
- return iconNodeClose;
-
- return getDefaultImagePath( DEFAULT_IMAGE_ICON_NODE_CLOSE );
+ return getStringValue(iconNodeClose, "iconNodeClose");
}
@@ -325,10 +298,7 @@
public String getIconNodeCloseFirst()
{
- if( iconNodeCloseFirst != null )
- return iconNodeCloseFirst;
-
- return getDefaultImagePath( DEFAULT_IMAGE_ICON_NODE_CLOSE_FIRST );
+ return getStringValue(iconNodeCloseFirst, "iconNodeCloseFirst");
}
@@ -340,10 +310,7 @@
public String getIconNodeCloseMiddle()
{
- if( iconNodeCloseMiddle != null )
- return iconNodeCloseMiddle;
-
- return getDefaultImagePath( DEFAULT_IMAGE_ICON_NODE_CLOSE_MIDDLE );
+ return getStringValue(iconNodeCloseMiddle, "iconNodeCloseMiddle");
}
@@ -355,10 +322,7 @@
public String getIconNodeCloseLast()
{
- if( iconNodeCloseLast != null )
- return iconNodeCloseLast;
-
- return getDefaultImagePath( DEFAULT_IMAGE_ICON_NODE_CLOSE_LAST );
+ return getStringValue(iconNodeCloseLast, "iconNodeCloseLast");
}
@@ -370,7 +334,7 @@
public String getStyleClass()
{
- return styleClass;
+ return getStringValue(styleClass, "styleClass");
}
@@ -382,7 +346,7 @@
public String getNodeClass()
{
- return nodeClass;
+ return getStringValue(nodeClass, "nodeClass");
}
@@ -397,7 +361,7 @@
*/
public String getRowClasses()
{
- return rowClasses;
+ return getStringValue(rowClasses, "rowClasses");
}
@@ -415,7 +379,7 @@
*/
public String getColumnClasses()
{
- return columnClasses;
+ return getStringValue(columnClasses, "columnClasses");
}
@@ -433,7 +397,7 @@
*/
public String getSelectedNodeClass()
{
- return selectedNodeClass;
+ return getStringValue(selectedNodeClass, "selectedNodeClass");
}
@@ -448,7 +412,7 @@
public String getIconClass()
{
- return iconClass;
+ return getStringValue(iconClass, "iconClass");
}
@@ -460,13 +424,26 @@
public long getExpireListeners()
{
- return expireListeners;
+ if(expireListeners != null)
+ {
+ return expireListeners.longValue();
+ }
+ ValueBinding vb = getValueBinding("expireListeners");
+ if(vb != null)
+ {
+ Object obj = vb.getValue(getFacesContext());
+ if(obj instanceof java.lang.Number)
+ {
+ return ((java.lang.Number)obj).longValue();
+ }
+ }
+ return DEFAULT_EXPIRE_LISTENERS;
}
public void setExpireListeners(long expireListeners)
{
- this.expireListeners = expireListeners;
+ this.expireListeners = new Long(expireListeners);
}
@@ -628,7 +605,7 @@
values[18] = selectedPath;
values[19] = iconClass;
values[20] = new Integer(internalId);
- values[21] = new Long(expireListeners);
+ values[21] = expireListeners;
values[22] = rowClasses;
values[23] = columnClasses;
values[24] = var;
@@ -660,7 +637,7 @@
selectedPath = (int[]) values[18];
iconClass = (String) values[19];
internalId = ((Integer) values[20]).intValue();
- expireListeners = ((Long) values[21]).longValue();
+ expireListeners = (Long) values[21];
rowClasses = (String) values[22];
columnClasses = (String) values[23];
var = (String) values[24];
@@ -837,7 +814,7 @@
if (listener.getId() == internalId)
{
found = true;
- } else if (currentTime - listener.getLastAccessTime() > expireListeners)
+ } else if (currentTime - listener.getLastAccessTime() > getExpireListeners())
{
iterator.remove();
}
@@ -931,11 +908,6 @@
expandChildren(context, child);
}
}
- }
-
- public static String getDefaultImagePath(String relativePathInResourceFolder)
- {
- return AddResource.getResourceMappedPath(HtmlTree.class, relativePathInResourceFolder, null);
}
private static class ModelListener implements TreeModelListener
Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeRenderer.java?rev=328404&r1=328403&r2=328404&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeRenderer.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/tree/renderkit/html/HtmlTreeRenderer.java Tue Oct 25 09:21:17 2005
@@ -15,6 +15,7 @@
*/
package org.apache.myfaces.custom.tree.renderkit.html;
+import org.apache.myfaces.component.html.util.AddResource;
import org.apache.myfaces.custom.tree.HtmlTree;
import org.apache.myfaces.custom.tree.HtmlTreeColumn;
import org.apache.myfaces.custom.tree.HtmlTreeImageCommandLink;
@@ -44,6 +45,20 @@
*/
public class HtmlTreeRenderer extends HtmlTableRendererBase
{
+ // Defaut images
+ private static final String DEFAULT_IMAGE_ICON_LINE = "images/line.gif";
+ private static final String DEFAULT_IMAGE_ICON_NOLINE = "images/noline.gif";
+ private static final String DEFAULT_IMAGE_ICON_CHILD_FIRST = "images/line_first.gif";
+ private static final String DEFAULT_IMAGE_ICON_CHILD_MIDDLE = "images/line_middle.gif";
+ private static final String DEFAULT_IMAGE_ICON_CHILD_LAST = "images/line_last.gif";
+ private static final String DEFAULT_IMAGE_ICON_NODE_OPEN = "images/node_open.gif";
+ private static final String DEFAULT_IMAGE_ICON_NODE_OPEN_FIRST = "images/node_open_first.gif";
+ private static final String DEFAULT_IMAGE_ICON_NODE_OPEN_MIDDLE = "images/node_open_middle.gif";
+ private static final String DEFAULT_IMAGE_ICON_NODE_OPEN_LAST = "images/node_open_last.gif";
+ private static final String DEFAULT_IMAGE_ICON_NODE_CLOSE = "images/node_close.gif";
+ private static final String DEFAULT_IMAGE_ICON_NODE_CLOSE_FIRST = "images/node_close_first.gif";
+ private static final String DEFAULT_IMAGE_ICON_NODE_CLOSE_MIDDLE = "images/node_close_middle.gif";
+ private static final String DEFAULT_IMAGE_ICON_NODE_CLOSE_LAST = "images/node_close_last.gif";
private static final Integer ZERO = new Integer(0);
@@ -337,6 +352,12 @@
}
}
+ public String getDefaultImagePath(FacesContext context, String relativePathInResourceFolder)
+ {
+ AddResource instance = AddResource.getInstance(context);
+ return instance.getResourceUri(context, HtmlTree.class, relativePathInResourceFolder, false);
+ }
+
/**
* <p>
* Render the column where the tree is displayed.
@@ -362,7 +383,7 @@
{
int state = layout[i];
writer.startElement(HTML.TD_ELEM, child);
- String url = getLayoutImage(tree, state);
+ String url = getLayoutImage(facesContext, tree, state);
if ((url != null) && (url.length() > 0))
{
@@ -398,7 +419,7 @@
// command link
writer.startElement(HTML.TD_ELEM, tree);
int state = layout[layout.length - 1];
- String url = getLayoutImage(tree, state);
+ String url = getLayoutImage(facesContext, tree, state);
if (state == HtmlTreeNode.CHILD || state == HtmlTreeNode.CHILD_FIRST || state == HtmlTreeNode.CHILD_LAST)
{
@@ -409,7 +430,7 @@
{
HtmlTreeImageCommandLink expandCollapse = (HtmlTreeImageCommandLink) child
.getExpandCollapseCommand(facesContext);
- expandCollapse.setImage(getLayoutImage(tree, layout[layout.length - 1]));
+ expandCollapse.setImage(getLayoutImage(facesContext, tree, layout[layout.length - 1]));
expandCollapse.encodeBegin(facesContext);
expandCollapse.encodeEnd(facesContext);
@@ -428,7 +449,7 @@
if (!child.isLeaf(facesContext))
{
// todo: icon provider
- url = HtmlTree.getDefaultImagePath( DEFAULT_IMAGE_ICON_FOLDER );
+ url = getDefaultImagePath(facesContext, DEFAULT_IMAGE_ICON_FOLDER );
}
else
{
@@ -509,38 +530,48 @@
writer.endElement(HTML.IMG_ELEM);
}
- protected String getLayoutImage(HtmlTree tree, int state)
+ protected String getLayoutImage(FacesContext context, HtmlTree tree, int state)
{
switch (state)
{
case HtmlTreeNode.OPEN:
- return tree.getIconNodeOpenMiddle();
+ return getImageUrl(context, tree.getIconNodeOpenMiddle(), DEFAULT_IMAGE_ICON_NODE_OPEN_MIDDLE);
case HtmlTreeNode.OPEN_FIRST:
- return tree.getIconNodeOpenFirst();
+ return getImageUrl(context, tree.getIconNodeOpenFirst(), DEFAULT_IMAGE_ICON_NODE_OPEN_FIRST);
case HtmlTreeNode.OPEN_LAST:
- return tree.getIconNodeOpenLast();
+ return getImageUrl(context, tree.getIconNodeOpenLast(), DEFAULT_IMAGE_ICON_NODE_OPEN_LAST);
case HtmlTreeNode.OPEN_SINGLE:
- return tree.getIconNodeOpen();
+ return getImageUrl(context, tree.getIconNodeOpen(), DEFAULT_IMAGE_ICON_NODE_OPEN);
case HtmlTreeNode.CLOSED:
- return tree.getIconNodeCloseMiddle();
+ return getImageUrl(context, tree.getIconNodeCloseMiddle(), DEFAULT_IMAGE_ICON_NODE_CLOSE_MIDDLE);
case HtmlTreeNode.CLOSED_FIRST:
- return tree.getIconNodeCloseFirst();
+ return getImageUrl(context, tree.getIconNodeCloseFirst(), DEFAULT_IMAGE_ICON_NODE_CLOSE_FIRST);
case HtmlTreeNode.CLOSED_LAST:
- return tree.getIconNodeCloseLast();
+ return getImageUrl(context, tree.getIconNodeCloseLast(), DEFAULT_IMAGE_ICON_NODE_CLOSE_LAST);
case HtmlTreeNode.CLOSED_SINGLE:
- return tree.getIconNodeClose();
+ return getImageUrl(context, tree.getIconNodeClose(), DEFAULT_IMAGE_ICON_NODE_CLOSE);
case HtmlTreeNode.CHILD:
- return tree.getIconChildMiddle();
+ return getImageUrl(context, tree.getIconChildMiddle(), DEFAULT_IMAGE_ICON_CHILD_MIDDLE);
case HtmlTreeNode.CHILD_FIRST:
- return tree.getIconChildFirst();
+ return getImageUrl(context, tree.getIconChildFirst(), DEFAULT_IMAGE_ICON_CHILD_FIRST);
case HtmlTreeNode.CHILD_LAST:
- return tree.getIconChildLast();
+ return getImageUrl(context, tree.getIconChildLast(), DEFAULT_IMAGE_ICON_CHILD_LAST);
case HtmlTreeNode.LINE:
- return tree.getIconLine();
+ return getImageUrl(context, tree.getIconLine(), DEFAULT_IMAGE_ICON_LINE);
case HtmlTreeNode.EMPTY:
- return tree.getIconNoline();
+ return getImageUrl(context, tree.getIconNoline(), DEFAULT_IMAGE_ICON_NOLINE);
default:
- return tree.getIconNoline();
+ return getImageUrl(context, tree.getIconNoline(), DEFAULT_IMAGE_ICON_NOLINE);
+ }
+ }
+
+ protected String getImageUrl(FacesContext context, String userValue, String resourceValue)
+ {
+ AddResource addResource = AddResource.getInstance(context);
+ if(userValue != null)
+ {
+ return addResource.getResourceUri(context, userValue, false);
}
+ return addResource.getResourceUri(context, HtmlTree.class, resourceValue, false);
}
}
Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/tree/taglib/TreeTag.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/tree/taglib/TreeTag.java?rev=328404&r1=328403&r2=328404&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/tree/taglib/TreeTag.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/tree/taglib/TreeTag.java Tue Oct 25 09:21:17 2005
@@ -84,7 +84,7 @@
private boolean expandRoot;
- private long expireListeners = HtmlTree.DEFAULT_EXPIRE_LISTENERS;
+ private String expireListeners;
public String getComponentType() {
return "org.apache.myfaces.HtmlTree";
@@ -321,11 +321,11 @@
this.expandRoot = expandRoot;
}
- public long getExpireListeners() {
+ public String getExpireListeners() {
return expireListeners;
}
- public void setExpireListeners(long expireListeners) {
+ public void setExpireListeners(String expireListeners) {
this.expireListeners = expireListeners;
}
@@ -389,7 +389,6 @@
selectedNodeClass = null;
iconClass = null;
expandRoot = false;
- expireListeners = HtmlTree.DEFAULT_EXPIRE_LISTENERS;
}
/**
@@ -436,6 +435,6 @@
setStringProperty(component, "nodeClass", nodeClass);
setStringProperty(component, "selectedNodeClass", selectedNodeClass);
setStringProperty(component, "iconClass", iconClass);
- ((HtmlTree) component).setExpireListeners(expireListeners);
+ setLongProperty(component, "expireListeners", expireListeners);
}
}
Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/tree2/HtmlTreeRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/tree2/HtmlTreeRenderer.java?rev=328404&r1=328403&r2=328404&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/tree2/HtmlTreeRenderer.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/tree2/HtmlTreeRenderer.java Tue Oct 25 09:21:17 2005
@@ -53,7 +53,6 @@
protected static final String TOGGLE_SPAN = "org.apache.myfaces.tree.TOGGLE_SPAN";
protected static final String ROOT_NODE_ID = "0";
- private static final String JAVASCRIPT_ENCODED = "org.apache.myfaces.tree.JAVASCRIPT_ENCODED";
private static final String NAV_COMMAND = "org.apache.myfaces.tree.NAV_COMMAND";
private static final String ENCODING = "UTF-8";
private static final String ATTRIB_DELIM = ";";
@@ -325,8 +324,8 @@
{
boolean lastChild = tree.isLastChild((String)pathInfo[i]);
String lineSrc = (!lastChild && showLines)
- ? getImageSrc(context, tree, "line-trunk.gif")
- : getImageSrc(context, tree, "spacer.gif");
+ ? getImageSrc(context, tree, "line-trunk.gif", true)
+ : getImageSrc(context, tree, "spacer.gif", true);
out.startElement(HTML.TD_ELEM, tree);
out.writeAttribute(HTML.WIDTH_ATTR, "19", null);
@@ -469,9 +468,9 @@
}
// adjust navSrc and altSrc so that the images can be retrieved using the extensions filter
- String navSrcUrl = getImageSrc(null, tree, navSrc);
- navSrc = getImageSrc(context, tree, navSrc);
- altSrc = getImageSrc(context, tree, altSrc);
+ String navSrcUrl = getImageSrc(context, tree, navSrc, false);
+ navSrc = getImageSrc(context, tree, navSrc, true);
+ altSrc = getImageSrc(context, tree, altSrc, true);
// render nav cell
out.startElement(HTML.TD_ELEM, tree);
@@ -481,7 +480,7 @@
if ((bitMask & LINES)!=0 && (bitMask & LAST)==0)
{
- out.writeURIAttribute("background", getImageSrc(context, tree, "line-trunk.gif"), null);
+ out.writeURIAttribute("background", getImageSrc(context, tree, "line-trunk.gif", true), null);
}
// add the appropriate image for the nav control
@@ -592,36 +591,19 @@
*/
private void encodeJavascript(FacesContext context, UIComponent component) throws IOException
{
- // check to see if javascript has already been written (which could happen if more than one tree on the same page)
- if (context.getExternalContext().getRequestMap().containsKey(JAVASCRIPT_ENCODED))
- {
- return;
- }
-
// render javascript function for client-side toggle (it won't be used if user has opted for server-side toggle)
- ResponseWriter out = context.getResponseWriter();
String javascriptLocation = (String)component.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
+ AddResource addResource = AddResource.getInstance(context);
if (javascriptLocation == null)
{
- AddResource.addJavaScriptHere(HtmlTreeRenderer.class, "javascript/tree.js", context, component);
- AddResource.addJavaScriptHere(HtmlTreeRenderer.class, "javascript/cookielib.js", context, component);
+ addResource.addJavaScriptToHeader(context, HtmlTreeRenderer.class, "javascript/tree.js");
+ addResource.addJavaScriptToHeader(context, HtmlTreeRenderer.class, "javascript/cookielib.js");
}
else
{
- out.startElement(HTML.SCRIPT_ELEM, component);
- out.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
- out.writeAttribute(HTML.SRC_ATTR,
- javascriptLocation + "/tree.js", null);
- out.endElement(HTML.SCRIPT_ELEM);
-
- out.startElement(HTML.SCRIPT_ELEM, component);
- out.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
- out.writeAttribute(HTML.SRC_ATTR,
- javascriptLocation + "/cookielib.js", null);
- out.endElement(HTML.SCRIPT_ELEM);
+ addResource.addJavaScriptToHeader(context, javascriptLocation + "/tree.js");
+ addResource.addJavaScriptToHeader(context, javascriptLocation + "/cookielib.js");
}
-
- context.getExternalContext().getRequestMap().put(JAVASCRIPT_ENCODED, Boolean.TRUE);
}
/**
@@ -634,17 +616,18 @@
* @param imageName The name of the image file to use.
* @return The image src information.
*/
- private String getImageSrc(FacesContext context, UIComponent component, String imageName)
+ private String getImageSrc(FacesContext context, UIComponent component, String imageName, boolean withContextPath)
{
String imageLocation = (String)component.getAttributes().get(JSFAttr.IMAGE_LOCATION);
+ AddResource addResource = AddResource.getInstance(context);
if (imageLocation == null)
{
- return AddResource.getResourceMappedPath(HtmlTreeRenderer.class,
- "images/" + imageName, context);
+ return addResource.getResourceUri(context, HtmlTreeRenderer.class,
+ "images/" + imageName, withContextPath);
}
else
{
- return imageLocation + "/" + imageName;
+ return addResource.getResourceUri(context, imageLocation + "/" + imageName, withContextPath);
}
}
Modified: myfaces/tomahawk/trunk/src/test/org/apache/myfaces/custom/date/HtmlDateRenderCactus.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/test/org/apache/myfaces/custom/date/HtmlDateRenderCactus.java?rev=328404&r1=328403&r2=328404&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/test/org/apache/myfaces/custom/date/HtmlDateRenderCactus.java (original)
+++ myfaces/tomahawk/trunk/src/test/org/apache/myfaces/custom/date/HtmlDateRenderCactus.java Tue Oct 25 09:21:17 2005
@@ -70,7 +70,7 @@
inputDate.setId("test");
inputDate.setType("date");
Date today = new Date();
- inputDate.setSubmittedValue(new UserData(today, Locale.ENGLISH, null));
+ inputDate.setSubmittedValue(new UserData(today, Locale.ENGLISH, null, true));
HtmlDateRenderer subject = new HtmlDateRenderer();
// decode
subject.decode(facesContext, inputDate);
Modified: myfaces/tomahawk/trunk/src/test/org/apache/myfaces/custom/date/HtmlDateRendererTest.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/test/org/apache/myfaces/custom/date/HtmlDateRendererTest.java?rev=328404&r1=328403&r2=328404&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/test/org/apache/myfaces/custom/date/HtmlDateRendererTest.java (original)
+++ myfaces/tomahawk/trunk/src/test/org/apache/myfaces/custom/date/HtmlDateRendererTest.java Tue Oct 25 09:21:17 2005
@@ -70,7 +70,7 @@
inputDate.setId("test");
inputDate.setType("date");
Date today = new Date();
- inputDate.setSubmittedValue(new UserData(today, Locale.ENGLISH, null));
+ inputDate.setSubmittedValue(new UserData(today, Locale.ENGLISH, null, true));
HtmlDateRenderer subject = new HtmlDateRenderer();
// setup the request map
Map map = new HashMap();