You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2009/06/25 12:27:15 UTC
svn commit: r788312 - in /myfaces/tobago/trunk:
core/src/main/java/org/apache/myfaces/tobago/context/
core/src/main/java/org/apache/myfaces/tobago/taglib/component/
core/src/main/java/org/apache/myfaces/tobago/taglib/decl/
example/demo/src/main/webapp/...
Author: lofwyr
Date: Thu Jun 25 10:27:14 2009
New Revision: 788312
URL: http://svn.apache.org/viewvc?rev=788312&view=rev
Log:
TOBAGO-770: The command tags should have a possibility to link to resources (html, jsp, jsf pages) with respect to the resource management.
Added:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/HasResource.java
myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/plain.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/plain_de.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/resource-attribute.xhtml
- copied, changed from r786116, myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/link-attribute.xhtml
myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/MultiSuffixSeleniumTest.java
myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/tc/
myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/tc/button/
myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/tc/button/LinkAttributeSeleniumTest.java
- copied, changed from r786116, myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/SimpleSeleniumTest.java
myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/tc/button/ResourceAttributeSeleniumTest.java
Modified:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerUtil.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeNodeTagDeclaration.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/AbstractCommandTagDeclaration.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/HasLink.java
myfaces/tobago/trunk/example/demo/src/main/webapp/reference/command.jsp
myfaces/tobago/trunk/example/test/src/main/webapp/WEB-INF/web.xml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/link-attribute.xhtml
myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/plain.html
myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/plain_de.html
myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/AutomaticSeleniumTest.java
myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumTest.java
myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/SimpleSeleniumTest.java
myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension/MenuCheckboxExtensionTag.java
myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension/MenuRadioExtensionTag.java
myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerUtil.java?rev=788312&r1=788311&r2=788312&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerUtil.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerUtil.java Thu Jun 25 10:27:14 2009
@@ -55,11 +55,6 @@
.getImage(facesContext.getViewRoot(), name);
}
- public static String getBlankPage(FacesContext context) {
- return context.getExternalContext().getRequestContextPath()
- + "/org/apache/myfaces/tobago/renderkit/html/standard/blank.html";
- }
-
/**
* Searchs for an image and return it with the context path
*/
@@ -134,4 +129,13 @@
String filename = ResourceUtils.addPostfixToFilename(image, "Disabled");
return getImageWithPath(facesContext, filename, true);
}
+
+ public static String getBlankPage(FacesContext facesContext) {
+ return facesContext.getExternalContext().getRequestContextPath()
+ + "/org/apache/myfaces/tobago/renderkit/html/standard/blank.html";
+ }
+
+ public static String getPageWithoutContextPath(FacesContext facesContext, String name) {
+ return ResourceManagerFactory.getResourceManager(facesContext).getImage(facesContext.getViewRoot(), name);
+ }
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeNodeTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeNodeTagDeclaration.java?rev=788312&r1=788311&r2=788312&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeNodeTagDeclaration.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/TreeNodeTagDeclaration.java Thu Jun 25 10:27:14 2009
@@ -26,21 +26,15 @@
import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
import org.apache.myfaces.tobago.component.Facets;
import org.apache.myfaces.tobago.component.RendererTypes;
-import org.apache.myfaces.tobago.taglib.decl.HasAction;
-import org.apache.myfaces.tobago.taglib.decl.HasActionListener;
+import org.apache.myfaces.tobago.taglib.decl.AbstractCommandTagDeclaration;
import org.apache.myfaces.tobago.taglib.decl.HasIdBindingAndRendered;
import org.apache.myfaces.tobago.taglib.decl.HasImage;
import org.apache.myfaces.tobago.taglib.decl.HasLabel;
-import org.apache.myfaces.tobago.taglib.decl.HasLink;
import org.apache.myfaces.tobago.taglib.decl.HasMarkup;
-import org.apache.myfaces.tobago.taglib.decl.HasOnclick;
-import org.apache.myfaces.tobago.taglib.decl.HasRenderedPartially;
import org.apache.myfaces.tobago.taglib.decl.HasTarget;
import org.apache.myfaces.tobago.taglib.decl.HasTip;
import org.apache.myfaces.tobago.taglib.decl.HasValue;
import org.apache.myfaces.tobago.taglib.decl.IsDisabled;
-import org.apache.myfaces.tobago.taglib.decl.IsImmediateCommand;
-import org.apache.myfaces.tobago.taglib.decl.IsTransition;
/**
* Creates a tree node.
@@ -55,13 +49,12 @@
allowedChildComponenents = {
"org.apache.myfaces.tobago.TreeNode",
"org.apache.myfaces.tobago.TreeData"
- },
+ },
facets = {
- @Facet(name = Facets.ADDENDUM, description = "Displays an additional component to a node.")})
+ @Facet(name = Facets.ADDENDUM, description = "Displays an additional component to a node.")})
public interface TreeNodeTagDeclaration
- extends HasIdBindingAndRendered, HasLabel, HasValue, HasMarkup, HasAction, HasActionListener, IsImmediateCommand,
- HasOnclick, HasLink, IsTransition, HasRenderedPartially, HasTip, HasTarget,
- HasImage, IsDisabled {
+ extends HasIdBindingAndRendered, HasLabel, HasValue, HasMarkup, HasTip, HasTarget, HasImage, IsDisabled,
+ AbstractCommandTagDeclaration {
/**
* Flag indicating if the subnodes are to be displayed.
@@ -82,7 +75,7 @@
*/
@TagAttribute
@UIComponentTagAttribute(type = {},
- expression = DynamicExpression.METHOD_BINDING_REQUIRED,
- methodSignature = "org.apache.myfaces.tobago.event.TreeExpansionEvent")
+ expression = DynamicExpression.METHOD_BINDING_REQUIRED,
+ methodSignature = "org.apache.myfaces.tobago.event.TreeExpansionEvent")
void setTreeExpansionListener(String treeExpansionListener);
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/AbstractCommandTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/AbstractCommandTagDeclaration.java?rev=788312&r1=788311&r2=788312&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/AbstractCommandTagDeclaration.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/AbstractCommandTagDeclaration.java Thu Jun 25 10:27:14 2009
@@ -23,5 +23,5 @@
*/
public interface AbstractCommandTagDeclaration extends HasAction, HasActionListener, IsImmediateCommand,
- HasOnclick, HasLink, IsTransition, HasRenderedPartially {
+ HasOnclick, HasLink, HasResource, IsTransition, HasRenderedPartially {
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/HasLink.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/HasLink.java?rev=788312&r1=788311&r2=788312&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/HasLink.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/HasLink.java Thu Jun 25 10:27:14 2009
@@ -20,18 +20,24 @@
import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
-/*
- * Date: 19.04.2006
- * Time: 11:41:03
- */
public interface HasLink {
/**
- * Link to an arbitrary URL
+ * Link to an arbitrary URL, either an internal link or an external link.
+
+ * <dl>
+ * <dt>internal absolute link</dt>
+ * <dd>Starts with a slash '/' character. The context path will be added.
+ * A session id will be added, if needed.</dd>
+ * <dt>external link</dt>
+ * <dd>Contains a colon ':' character.
+ * The link will not be modified.</dd>
+ * <dt>internal relative link</dt>
+ * <dd>Any other strings. A session id will be added, if needed.</dd>
+ * </dl>
*
- * @param link
+ * @param link The external or internal link.
*/
@TagAttribute
@UIComponentTagAttribute()
void setLink(String link);
-
}
Added: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/HasResource.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/HasResource.java?rev=788312&view=auto
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/HasResource.java (added)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/decl/HasResource.java Thu Jun 25 10:27:14 2009
@@ -0,0 +1,48 @@
+package org.apache.myfaces.tobago.taglib.decl;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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 KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
+import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
+
+public interface HasResource {
+ /**
+ * Link to an internal resource.
+ * Resources will be processed by the resource management.
+ * E. g. define help.html and it will be served help_es.html or help_de.html if available.
+ * For JSF-Pages you have to set the jsfResource attribute.
+ *
+ * @param resource The internal resource.
+ * @see #setJsfResource(String)
+ */
+ @TagAttribute
+ @UIComponentTagAttribute()
+ void setResource(String resource);
+
+ /**
+ * Flag indicating that the resource referenced by the resource attribute is a jsf resource.
+ * That means that the url has to be processed to change the prefix or suffix (e. g. *.jsf or
+ * /faces/*). Default is false.
+ *
+ * @param jsfResource Is the Resource a JSF page or not?
+ */
+ @TagAttribute
+ @UIComponentTagAttribute(type = "java.lang.Boolean", defaultValue = "false")
+ void setJsfResource(String jsfResource);
+
+}
Modified: myfaces/tobago/trunk/example/demo/src/main/webapp/reference/command.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/reference/command.jsp?rev=788312&r1=788311&r2=788312&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/reference/command.jsp (original)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/reference/command.jsp Thu Jun 25 10:27:14 2009
@@ -23,7 +23,7 @@
<jsp:body>
<tc:box label="Command Controls">
<f:facet name="layout">
- <tc:gridLayout columns="100px;100px;100px;100px;*" rows="fixed;fixed;fixed;fixed;fixed;fixed;fixed;fixed;fixed;fixed;fixed;*"/>
+ <tc:gridLayout columns="100px;100px;100px;100px;100px;*" rows="fixed;fixed;fixed;fixed;fixed;fixed;fixed;fixed;fixed;fixed;fixed;*"/>
</f:facet>
<%-- standard --%>
@@ -37,6 +37,7 @@
<%-- code-sniplet-end id="button" --%>
<tc:button label="On Click" onclick="alert('Hallo Tobago!');"/>
<tc:button label="Link" link="http://www.apache.org/"/>
+ <tc:button label="Resource" resource="help.html"/>
<tc:cell/>
<%-- code-sniplet-start id="link" --%>
@@ -44,6 +45,7 @@
<%-- code-sniplet-end id="link" --%>
<tc:link label="On Click" onclick="alert('Hallo Tobago!');"/>
<tc:link label="Link" link="http://www.apache.org/"/>
+ <tc:link label="Resource" resource="help.html"/>
<tc:cell/>
<%-- confirmation --%>
@@ -67,6 +69,11 @@
<tc:out value="Are you sure?"/>
</f:facet>
</tc:button>
+ <tc:button label="Resource" resource="help.html">
+ <f:facet name="confirmation">
+ <tc:out value="Are you sure?"/>
+ </f:facet>
+ </tc:button>
<tc:cell/>
<tc:link label="Action" action="reference/command">
@@ -84,6 +91,11 @@
<tc:out value="Are you sure?"/>
</f:facet>
</tc:link>
+ <tc:link label="Resource" resource="help.html">
+ <f:facet name="confirmation">
+ <tc:out value="Are you sure?"/>
+ </f:facet>
+ </tc:link>
<tc:cell/>
<%-- target --%>
@@ -95,11 +107,13 @@
<tc:button label="Action" action="reference/command" target="Command Target"/>
<tc:button label="N/A" disabled="true"/>
<tc:button label="N/A yet" disabled="true"/>
+ <tc:button label="N/A yet" disabled="true"/>
<tc:cell/>
<tc:link label="Action" action="reference/command" target="Command Target"/>
<tc:link label="N/A" disabled="true"/>
- <tc:link label="Link" link="/index.html" target="Command Target"/>
+ <tc:link label="Link" link="http://www.apache.org/" target="Command Target"/>
+ <tc:link label="Resource" resource="help.html" target="Command Target"/>
<tc:cell/>
<%-- default command --%>
@@ -110,18 +124,19 @@
<tc:cell/>
<tc:cell/>
<tc:cell/>
+ <tc:cell/>
<%-- dynamic widths --%>
- <tc:cell spanX="5">
- <tc:separator >
+ <tc:cell spanX="6">
+ <tc:separator>
<f:facet name="label">
<tc:label value="Layout"/>
</f:facet>
</tc:separator>
</tc:cell>
- <tc:cell spanX="5">
+ <tc:cell spanX="6">
<tc:panel>
<f:facet name="layout">
<tc:gridLayout rows="fixed" columns="fixed;fixed;fixed;*"/>
@@ -134,7 +149,7 @@
</tc:panel>
</tc:cell>
- <tc:cell spanX="5">
+ <tc:cell spanX="6">
<tc:panel>
<f:facet name="layout">
<tc:gridLayout rows="fixed" columns="fixed;*"/>
@@ -145,7 +160,7 @@
</tc:panel>
</tc:cell>
- <tc:cell spanX="5">
+ <tc:cell spanX="6">
<tc:panel>
<f:facet name="layout">
<tc:gridLayout rows="45px" columns="100px;100px;*"/>
@@ -165,6 +180,7 @@
<tc:cell/>
<tc:cell/>
<tc:cell/>
+ <tc:cell/>
</tc:box>
</jsp:body>
Modified: myfaces/tobago/trunk/example/test/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/webapp/WEB-INF/web.xml?rev=788312&r1=788311&r2=788312&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/webapp/WEB-INF/web.xml (original)
+++ myfaces/tobago/trunk/example/test/src/main/webapp/WEB-INF/web.xml Thu Jun 25 10:27:14 2009
@@ -72,6 +72,7 @@
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
+ <url-pattern>*.html</url-pattern>
<page-encoding>UTF-8</page-encoding>
</jsp-property-group>
</jsp-config>
Modified: myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/link-attribute.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/link-attribute.xhtml?rev=788312&r1=788311&r2=788312&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/link-attribute.xhtml (original)
+++ myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/link-attribute.xhtml Thu Jun 25 10:27:14 2009
@@ -22,14 +22,15 @@
xmlns:tx="http://myfaces.apache.org/tobago/extension"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core">
- <tc:page id="page" width="300px" height="50px">
+ <tc:page id="page">
+ <tc:gridLayoutConstraint width="300px" height="50px"/>
<f:facet name="layout">
<tc:gridLayout/>
</f:facet>
- <tc:button label="internal link with slash" link="/tc/button/plain.html" />
- <tc:button label="internal link without slash" link="plain.html" />
- <tc:button label="external link" link="http://www.apache.org/" />
+ <tc:button id="button-internal-link-with-slash" label="internal link with slash" link="/tc/button/plain.html"/>
+ <tc:button id="button-internal-link-without-slash" label="internal link without slash" link="plain.html"/>
+ <tc:button id="button-external-link" label="external link" link="http://www.apache.org/"/>
</tc:page>
</f:view>
Modified: myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/plain.html
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/plain.html?rev=788312&r1=788311&r2=788312&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/plain.html (original)
+++ myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/plain.html Thu Jun 25 10:27:14 2009
@@ -1,5 +1,5 @@
<html>
<body>
-A simple page for the resource test.
+A simple page for the resource test (static).
</body>
</html>
Added: myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/plain.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/plain.xhtml?rev=788312&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/plain.xhtml (added)
+++ myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/plain.xhtml Thu Jun 25 10:27:14 2009
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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 KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<f:view
+ xmlns:jsp="http://java.sun.com/JSP/Page"
+ xmlns:tc="http://myfaces.apache.org/tobago/component"
+ xmlns:tx="http://myfaces.apache.org/tobago/extension"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core">
+ <tc:page id="page" width="300px" height="50px">
+ <f:facet name="layout">
+ <tc:gridLayout/>
+ </f:facet>
+
+ <tc:out value="A simple page for the resource test (dynamic)."/>
+
+ </tc:page>
+</f:view>
Modified: myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/plain_de.html
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/plain_de.html?rev=788312&r1=788311&r2=788312&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/plain_de.html (original)
+++ myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/plain_de.html Thu Jun 25 10:27:14 2009
@@ -1,5 +1,5 @@
<html>
<body>
-Eine einfache Seite für den Resourcen-Test.
+Eine einfache Seite für den Resourcen-Test (statisch).
</body>
</html>
Added: myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/plain_de.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/plain_de.xhtml?rev=788312&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/plain_de.xhtml (added)
+++ myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/plain_de.xhtml Thu Jun 25 10:27:14 2009
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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 KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<f:view
+ xmlns:jsp="http://java.sun.com/JSP/Page"
+ xmlns:tc="http://myfaces.apache.org/tobago/component"
+ xmlns:tx="http://myfaces.apache.org/tobago/extension"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core">
+ <tc:page id="page" width="300px" height="50px">
+ <f:facet name="layout">
+ <tc:gridLayout/>
+ </f:facet>
+
+ <tc:out value="Eine einfache Seite für den Resourcen-Test (dynamisch)."/>
+
+ </tc:page>
+</f:view>
Copied: myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/resource-attribute.xhtml (from r786116, myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/link-attribute.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/resource-attribute.xhtml?p2=myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/resource-attribute.xhtml&p1=myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/link-attribute.xhtml&r1=786116&r2=788312&rev=788312&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/link-attribute.xhtml (original)
+++ myfaces/tobago/trunk/example/test/src/main/webapp/tc/button/resource-attribute.xhtml Thu Jun 25 10:27:14 2009
@@ -22,14 +22,14 @@
xmlns:tx="http://myfaces.apache.org/tobago/extension"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core">
- <tc:page id="page" width="300px" height="50px">
+ <tc:page id="page">
+ <tc:gridLayoutConstraint width="300px" height="50px"/>
<f:facet name="layout">
<tc:gridLayout/>
</f:facet>
- <tc:button label="internal link with slash" link="/tc/button/plain.html" />
- <tc:button label="internal link without slash" link="plain.html" />
- <tc:button label="external link" link="http://www.apache.org/" />
+ <tc:button id="button-html-resource" label="html resource" resource="tc/button/plain.html"/>
+ <tc:button id="button-xhtml-resource" label="xhtml resource" resource="tc/button/plain.xhtml" jsfResource="true"/>
</tc:page>
</f:view>
Modified: myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/AutomaticSeleniumTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/AutomaticSeleniumTest.java?rev=788312&r1=788311&r2=788312&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/AutomaticSeleniumTest.java (original)
+++ myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/AutomaticSeleniumTest.java Thu Jun 25 10:27:14 2009
@@ -17,8 +17,6 @@
* limitations under the License.
*/
-import com.thoughtworks.selenium.SeleniumException;
-import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -30,13 +28,7 @@
@RunWith(Parameterized.class)
public class AutomaticSeleniumTest extends SeleniumTest {
- static final String CONTAINS_A_404 = "contains a 404";
- static final String HAS_ERROR_SEVERITY = "has error severity";
- static final String IS_BROKEN = "is broken";
-
private static final String MAVEN_TARGET = "target/tobago-example-test";
- private static final String CONTEXT_PATH = "tobago-example-test";
- private static final String SERVLET_MAPPING = "faces";
private String url;
@@ -46,35 +38,8 @@
@Test
public void testPageConsistency() {
-
selenium.open(url);
- Assert.assertFalse("Page '" + url + "' " + CONTAINS_A_404 + ". Source=" + selenium.getHtmlSource(), pageNotFound());
- try {
- Assert.assertFalse("Page '" + url + "' " + HAS_ERROR_SEVERITY + ". Source=" + selenium.getHtmlSource(), isErrorOnPage());
- } catch (SeleniumException e) {
- Assert.fail("Page '" + url + "' " + IS_BROKEN + ". Not a Tobago page? Source=" + selenium.getHtmlSource() + " exception=" + e);
- }
- }
-
- /**
- * Was the page not found?
- *
- * @return True if the page not found.
- */
- // XXX might be improved, I didn't find a way to read the HTTP status code
- protected boolean pageNotFound() {
- return selenium.getHtmlSource().contains("404");
- }
-
- /**
- * Checks the page for the Tobago JavaScript Logging Framework and tests its severity.
- *
- * @return True if the severity level of the page is error
- * @throws SeleniumException If the page is not a Tobago page, or any other problem with JavaScrpt or the page.
- */
- protected boolean isErrorOnPage() throws SeleniumException {
- String errorSeverity = selenium.getEval("window.LOG.getMaximumSeverity() >= window.LOG.ERROR");
- return Boolean.parseBoolean(errorSeverity);
+ checkPage();
}
@Parameterized.Parameters
@@ -107,10 +72,4 @@
}
}
}
-
- protected static String createUrl(String page) {
- Assert.assertTrue("Page name must start with a slash.", page.startsWith("/"));
- return '/' + CONTEXT_PATH + '/' + SERVLET_MAPPING + page;
- }
-
}
Added: myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/MultiSuffixSeleniumTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/MultiSuffixSeleniumTest.java?rev=788312&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/MultiSuffixSeleniumTest.java (added)
+++ myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/MultiSuffixSeleniumTest.java Thu Jun 25 10:27:14 2009
@@ -0,0 +1,49 @@
+package org.apache.myfaces.tobago.example.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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 KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.junit.runner.RunWith;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+@RunWith(Parameterized.class)
+public abstract class MultiSuffixSeleniumTest extends SeleniumTest {
+
+ private String suffix;
+
+ public MultiSuffixSeleniumTest(String suffix) {
+ this.suffix = suffix;
+ }
+
+ public void open(String urlFragment) {
+ selenium.open(createUrl(urlFragment + suffix));
+ }
+
+ protected void sleep() throws InterruptedException {
+ Thread.sleep(5000L);
+ }
+
+ @Parameterized.Parameters
+ public static Collection<Object[]> findFormats() {
+ return Arrays.asList(
+ new Object[]{"xhtml"},
+ new Object[]{"jspx"}
+ );
+ }
+}
Modified: myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumTest.java?rev=788312&r1=788311&r2=788312&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumTest.java (original)
+++ myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/SeleniumTest.java Thu Jun 25 10:27:14 2009
@@ -18,18 +18,25 @@
*/
import com.thoughtworks.selenium.DefaultSelenium;
+import com.thoughtworks.selenium.SeleniumException;
import org.junit.After;
+import org.junit.Assert;
import org.junit.Before;
public abstract class SeleniumTest {
- private static final String BASE_URL = "http://localhost:8080/";
+ private static final String CONTEXT_PATH = "tobago-example-test";
+ private static final String SERVLET_MAPPING = "faces";
+
+ public static final String CONTAINS_A_404 = "contains a 404";
+ public static final String HAS_ERROR_SEVERITY = "has error severity";
+ public static final String IS_BROKEN = "is broken";
protected DefaultSelenium selenium;
@Before
public void setUp() throws Exception {
- selenium = createSeleniumClient(BASE_URL);
+ selenium = createSeleniumClient();
selenium.start();
}
@@ -38,7 +45,53 @@
selenium.stop();
}
- protected DefaultSelenium createSeleniumClient(String url) throws Exception {
- return new DefaultSelenium("localhost", 4444, "*firefox", url);
+ protected DefaultSelenium createSeleniumClient() throws Exception {
+ return new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:8080/");
+ }
+
+ protected void checkPage() {
+ Assert.assertFalse(
+ "Page '" + selenium.getLocation() + "' " + CONTAINS_A_404 + ". " + getHtmlSource(), pageNotFound());
+ try {
+ Assert.assertFalse(
+ "Page '" + selenium.getLocation() + "' " + HAS_ERROR_SEVERITY + ". " + getHtmlSource(), isErrorOnPage());
+ } catch (SeleniumException e) {
+ Assert.fail(
+ "Page '" + selenium.getLocation() + "' " + IS_BROKEN + ". Not a Tobago page? " + getHtmlSource()
+ + " exception=" + e);
+ }
+ }
+
+ /**
+ * Was the page not found?
+ *
+ * @return True if the page not found.
+ */
+ // XXX might be improved, I didn't find a way to read the HTTP status code
+ protected boolean pageNotFound() {
+ return selenium.getHtmlSource().contains("404");
+ }
+
+ /**
+ * Checks the page for the Tobago JavaScript Logging Framework and tests its severity.
+ *
+ * @return True if the severity level of the page is error
+ * @throws com.thoughtworks.selenium.SeleniumException
+ * If the page is not a Tobago page, or any other problem with JavaScrpt or the page.
+ */
+ protected boolean isErrorOnPage() throws SeleniumException {
+ String errorSeverity = selenium.getEval("window.LOG.getMaximumSeverity() >= window.LOG.ERROR");
+ return Boolean.parseBoolean(errorSeverity);
+ }
+
+ protected String getHtmlSource() {
+ return "\ncode=\n********************************************************************************\n"
+ + selenium.getHtmlSource()
+ + "\n********************************************************************************\n";
+ }
+
+ protected static String createUrl(String page) {
+ Assert.assertTrue("Page name must start with a slash.", page.startsWith("/"));
+ return '/' + CONTEXT_PATH + '/' + SERVLET_MAPPING + page;
}
}
Modified: myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/SimpleSeleniumTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/SimpleSeleniumTest.java?rev=788312&r1=788311&r2=788312&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/SimpleSeleniumTest.java (original)
+++ myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/SimpleSeleniumTest.java Thu Jun 25 10:27:14 2009
@@ -24,7 +24,7 @@
@Test
public void testHelloWorld() {
- selenium.open("http://localhost:8080/tobago-example-test/faces/simple.xhtml");
+ selenium.open("/tobago-example-test/faces/simple.xhtml");
Assert.assertEquals("Simple Test", selenium.getValue("page:in"));
selenium.captureScreenshot(SimpleSeleniumTest.class.getName() + ".testHelloWorld.png");
}
Copied: myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/tc/button/LinkAttributeSeleniumTest.java (from r786116, myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/SimpleSeleniumTest.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/tc/button/LinkAttributeSeleniumTest.java?p2=myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/tc/button/LinkAttributeSeleniumTest.java&p1=myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/SimpleSeleniumTest.java&r1=786116&r2=788312&rev=788312&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/SimpleSeleniumTest.java (original)
+++ myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/tc/button/LinkAttributeSeleniumTest.java Thu Jun 25 10:27:14 2009
@@ -1,4 +1,4 @@
-package org.apache.myfaces.tobago.example.test;
+package org.apache.myfaces.tobago.example.test.tc.button;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,16 +17,46 @@
* limitations under the License.
*/
+import org.apache.myfaces.tobago.example.test.MultiSuffixSeleniumTest;
+import org.apache.myfaces.tobago.example.test.Parameterized;
import org.junit.Assert;
import org.junit.Test;
+import org.junit.runner.RunWith;
-public class SimpleSeleniumTest extends SeleniumTest {
+@RunWith(Parameterized.class)
+public class LinkAttributeSeleniumTest extends MultiSuffixSeleniumTest {
+
+ public LinkAttributeSeleniumTest(String suffix) {
+ super(suffix);
+ }
@Test
- public void testHelloWorld() {
- selenium.open("http://localhost:8080/tobago-example-test/faces/simple.xhtml");
- Assert.assertEquals("Simple Test", selenium.getValue("page:in"));
- selenium.captureScreenshot(SimpleSeleniumTest.class.getName() + ".testHelloWorld.png");
+ public void testInternalLinkWithSlash() {
+ open("/tc/button/link-attribute.");
+ selenium.click("page:button-internal-link-with-slash");
+ Assert.assertEquals(
+ getHtmlSource(),
+ "A simple page for the resource test (static).", selenium.getText("//html/body"));
}
+ @Test
+ public void testInternalLinkWithoutSlash() {
+ open("/tc/button/link-attribute.");
+ selenium.click("page:button-internal-link-without-slash");
+ Assert.assertEquals(
+ getHtmlSource(),
+ "A simple page for the resource test (static).", selenium.getText("//html/body"));
+ }
+
+ @Test
+ public void testExternalLink() throws InterruptedException {
+ open("/tc/button/link-attribute.");
+ selenium.click("page:button-external-link");
+ // XXX This sleep call is not nice...
+ sleep();
+ // go to the apache home page
+ Assert.assertTrue(
+ getHtmlSource(),
+ selenium.getText("//html/head/title").contains("Apache Software Foundation"));
+ }
}
Added: myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/tc/button/ResourceAttributeSeleniumTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/tc/button/ResourceAttributeSeleniumTest.java?rev=788312&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/tc/button/ResourceAttributeSeleniumTest.java (added)
+++ myfaces/tobago/trunk/example/test/src/test/java/org/apache/myfaces/tobago/example/test/tc/button/ResourceAttributeSeleniumTest.java Thu Jun 25 10:27:14 2009
@@ -0,0 +1,52 @@
+package org.apache.myfaces.tobago.example.test.tc.button;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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 KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.myfaces.tobago.example.test.MultiSuffixSeleniumTest;
+import org.apache.myfaces.tobago.example.test.Parameterized;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(Parameterized.class)
+public class ResourceAttributeSeleniumTest extends MultiSuffixSeleniumTest {
+
+ public ResourceAttributeSeleniumTest(String suffix) {
+ super(suffix);
+ }
+
+ @Test
+ public void testHtmlResource() throws InterruptedException {
+ open("/tc/button/resource-attribute.");
+ selenium.click("page:button-html-resource");
+ // XXX This sleep call is not nice...
+ sleep();
+ Assert.assertEquals(getHtmlSource(),
+ "Eine einfache Seite für den Resourcen-Test (statisch).", selenium.getText("//html/body"));
+ }
+
+ @Test
+ public void testXhtmlResource() throws InterruptedException {
+ open("/tc/button/resource-attribute.");
+ selenium.click("page:button-xhtml-resource");
+ // XXX This sleep call is not nice...
+ sleep();
+ Assert.assertTrue(getHtmlSource(),
+ selenium.getText("//html/body").contains("Eine einfache Seite für den Resourcen-Test (dynamisch)."));
+ }
+}
Modified: myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension/MenuCheckboxExtensionTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension/MenuCheckboxExtensionTag.java?rev=788312&r1=788311&r2=788312&view=diff
==============================================================================
--- myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension/MenuCheckboxExtensionTag.java (original)
+++ myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension/MenuCheckboxExtensionTag.java Thu Jun 25 10:27:14 2009
@@ -17,11 +17,12 @@
* limitations under the License.
*/
+import org.apache.commons.lang.StringUtils;
import org.apache.myfaces.tobago.apt.annotation.ExtensionTag;
import org.apache.myfaces.tobago.apt.annotation.Tag;
-import org.apache.myfaces.tobago.component.Facets;
import org.apache.myfaces.tobago.component.AbstractUICommand;
import static org.apache.myfaces.tobago.component.Attributes.RENDERED_PARTIALLY;
+import org.apache.myfaces.tobago.component.Facets;
import org.apache.myfaces.tobago.internal.taglib.MenuItemTag;
import org.apache.myfaces.tobago.internal.taglib.SelectBooleanCheckboxTag;
import org.apache.myfaces.tobago.taglib.decl.AbstractCommandTagDeclaration;
@@ -30,14 +31,12 @@
import org.apache.myfaces.tobago.taglib.decl.HasLabel;
import org.apache.myfaces.tobago.taglib.decl.IsDisabled;
-import javax.faces.webapp.FacetTag;
import javax.faces.component.UIComponent;
import javax.faces.el.ValueBinding;
+import javax.faces.webapp.FacetTag;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
-import org.apache.commons.lang.StringUtils;
-
/*
* Date: 09.05.2006
* Time: 00:00:49
@@ -61,6 +60,8 @@
private String actionListener;
private String onclick;
private String link;
+ private String resource;
+ private String jsfResource;
private String disabled;
private String binding;
private String label;
@@ -89,6 +90,12 @@
if (link != null) {
menuCommandTag.setLink(link);
}
+ if (resource != null) {
+ menuCommandTag.setResource(resource);
+ }
+ if (jsfResource != null) {
+ menuCommandTag.setJsfResource(jsfResource);
+ }
if (disabled != null) {
menuCommandTag.setDisabled(disabled);
}
@@ -163,6 +170,14 @@
this.link = navigate;
}
+ public void setResource(String resource) {
+ this.resource = resource;
+ }
+
+ public void setJsfResource(String jsfResource) {
+ this.jsfResource = jsfResource;
+ }
+
public void setBinding(String binding) throws JspException {
this.binding = binding;
}
@@ -203,6 +218,8 @@
actionListener = null;
onclick = null;
link = null;
+ resource = null;
+ jsfResource = null;
disabled = null;
binding = null;
label = null;
Modified: myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension/MenuRadioExtensionTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension/MenuRadioExtensionTag.java?rev=788312&r1=788311&r2=788312&view=diff
==============================================================================
--- myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension/MenuRadioExtensionTag.java (original)
+++ myfaces/tobago/trunk/extension/tobago-taglib-extension/src/main/java/org/apache/myfaces/tobago/taglib/extension/MenuRadioExtensionTag.java Thu Jun 25 10:27:14 2009
@@ -17,11 +17,12 @@
* limitations under the License.
*/
+import org.apache.commons.lang.StringUtils;
import org.apache.myfaces.tobago.apt.annotation.ExtensionTag;
import org.apache.myfaces.tobago.apt.annotation.Tag;
-import org.apache.myfaces.tobago.component.Facets;
import org.apache.myfaces.tobago.component.AbstractUICommand;
import static org.apache.myfaces.tobago.component.Attributes.RENDERED_PARTIALLY;
+import org.apache.myfaces.tobago.component.Facets;
import org.apache.myfaces.tobago.internal.taglib.MenuItemTag;
import org.apache.myfaces.tobago.internal.taglib.SelectOneRadioTag;
import org.apache.myfaces.tobago.taglib.decl.AbstractCommandTagDeclaration;
@@ -31,14 +32,12 @@
import org.apache.myfaces.tobago.taglib.decl.HasValue;
import org.apache.myfaces.tobago.taglib.decl.IsDisabled;
-import javax.faces.webapp.FacetTag;
import javax.faces.component.UIComponent;
import javax.faces.el.ValueBinding;
+import javax.faces.webapp.FacetTag;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
-import org.apache.commons.lang.StringUtils;
-
/*
* Date: 09.05.2006
* Time: 17:41:39
@@ -63,6 +62,8 @@
private String actionListener;
private String onclick;
private String link;
+ private String resource;
+ private String jsfResource;
private String disabled;
private String binding;
private String label;
@@ -93,6 +94,12 @@
if (link != null) {
menuCommandTag.setLink(link);
}
+ if (resource != null) {
+ menuCommandTag.setResource(resource);
+ }
+ if (jsfResource != null) {
+ menuCommandTag.setJsfResource(jsfResource);
+ }
if (disabled != null) {
menuCommandTag.setDisabled(disabled);
}
@@ -172,6 +179,14 @@
this.link = navigate;
}
+ public void setResource(String resource) {
+ this.resource = resource;
+ }
+
+ public void setJsfResource(String jsfResource) {
+ this.jsfResource = jsfResource;
+ }
+
public void setBinding(String binding) throws JspException {
this.binding = binding;
}
@@ -216,6 +231,8 @@
actionListener = null;
onclick = null;
link = null;
+ resource = null;
+ jsfResource = null;
disabled = null;
binding = null;
label = null;
Modified: myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java?rev=788312&r1=788311&r2=788312&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java Thu Jun 25 10:27:14 2009
@@ -24,15 +24,16 @@
import org.apache.myfaces.tobago.component.Facets;
import org.apache.myfaces.tobago.component.UIPopup;
import org.apache.myfaces.tobago.context.ClientProperties;
+import org.apache.myfaces.tobago.context.ResourceManagerUtil;
import org.apache.myfaces.tobago.event.PopupActionListener;
import org.apache.myfaces.tobago.util.ComponentUtil;
import javax.faces.application.Application;
import javax.faces.application.ViewHandler;
-import javax.faces.component.UICommand;
import javax.faces.component.UIComponent;
import javax.faces.component.UIParameter;
import javax.faces.component.ValueHolder;
+import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import java.net.URLDecoder;
import java.util.Arrays;
@@ -50,15 +51,15 @@
private String href;
private String target;
- public CommandRendererHelper(FacesContext facesContext, UICommand component) {
+ public CommandRendererHelper(FacesContext facesContext, AbstractUICommand component) {
initOnclick(facesContext, component, null);
}
- public CommandRendererHelper(FacesContext facesContext, UICommand component, Tag tag) {
+ public CommandRendererHelper(FacesContext facesContext, AbstractUICommand component, Tag tag) {
initOnclick(facesContext, component, tag);
}
- private void initOnclick(FacesContext facesContext, UICommand command, Tag tag) {
+ private void initOnclick(FacesContext facesContext, AbstractUICommand command, Tag tag) {
disabled = ComponentUtil.getBooleanAttribute(command, Attributes.DISABLED);
href = getEmptyHref(facesContext);
@@ -79,7 +80,7 @@
boolean defaultCommand = ComponentUtil.getBooleanAttribute(command, Attributes.DEFAULT_COMMAND);
boolean transition = ComponentUtil.getBooleanAttribute(command, Attributes.TRANSITION);
- if (command.getAttributes().get(Attributes.LINK) != null) {
+ if (command.getLink() != null || command.getResource() != null) {
String url = generateUrl(facesContext, command);
if (tag == Tag.ANCHOR) {
onclick = null;
@@ -168,44 +169,64 @@
return onclick;
}
- private String generateUrl(FacesContext facesContext, UIComponent component) {
+ private String generateUrl(FacesContext facesContext, AbstractUICommand component) {
String url;
Application application = facesContext.getApplication();
ViewHandler viewHandler = application.getViewHandler();
+ ExternalContext externalContext = facesContext.getExternalContext();
- String link = (String) component.getAttributes().get(Attributes.LINK);
- if (link.startsWith("/")) { // internal URL
- url = viewHandler.getActionURL(facesContext, link);
- } else { // external URL
- url = link;
- }
+ if (component.getResource() != null) {
+ boolean jsfResource = component.isJsfResource();
+ url = ResourceManagerUtil.getPageWithoutContextPath(facesContext, component.getResource());
+ if (url != null) {
+ if (jsfResource) {
+ url = viewHandler.getActionURL(facesContext, url);
+ url = externalContext.encodeActionURL(url);
+ } else {
+ url = viewHandler.getResourceURL(facesContext, url);
+ url = externalContext.encodeResourceURL(url);
+ }
+ } else {
+ url = "";
+ }
+ } else if (component.getLink() != null) {
- url = facesContext.getExternalContext().encodeActionURL(url);
+ String link = component.getLink();
+ if (link.startsWith("/")) { // internal absolute link
+ url = viewHandler.getActionURL(facesContext, link);
+ url = externalContext.encodeActionURL(url);
+ } else if (link.contains(":")) { // external link
+ url = link;
+ } else { // internal relative link
+ url = externalContext.encodeResourceURL(link);
+ }
- StringBuilder builder = new StringBuilder(url);
- boolean firstParameter = !url.contains("?");
- for (UIComponent child : (List<UIComponent>) component.getChildren()) {
- if (child instanceof UIParameter) {
- UIParameter parameter = (UIParameter) child;
- if (firstParameter) {
- builder.append("?");
- firstParameter = false;
- } else {
- builder.append("&");
+ StringBuilder builder = new StringBuilder(url);
+ boolean firstParameter = !url.contains("?");
+ for (UIComponent child : (List<UIComponent>) component.getChildren()) {
+ if (child instanceof UIParameter) {
+ UIParameter parameter = (UIParameter) child;
+ if (firstParameter) {
+ builder.append("?");
+ firstParameter = false;
+ } else {
+ builder.append("&");
+ }
+ builder.append(parameter.getName());
+ builder.append("=");
+ Object value = parameter.getValue();
+ // TODO encoding
+ builder.append(value != null ? URLDecoder.decode(value.toString()) : null);
}
- builder.append(parameter.getName());
- builder.append("=");
- Object value = parameter.getValue();
- // TODO encoding
- builder.append(value != null ? URLDecoder.decode(value.toString()) : null);
}
+ url = builder.toString();
+ } else {
+ throw new AssertionError("Needed " + Attributes.LINK + " or " + Attributes.RESOURCE);
}
- url = builder.toString();
return url;
}
-
public String getOnclick() {
return onclick;
}