You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2008/11/11 09:36:31 UTC
svn commit: r712993 - in
/myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src:
main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/
test/resources/org/apache/myfaces/trinidadinternal/renderkit/golden/
Author: matzew
Date: Tue Nov 11 00:36:31 2008
New Revision: 712993
URL: http://svn.apache.org/viewvc?rev=712993&view=rev
Log:
TRINIDAD-1299 - tr:goButton: icon is not displayed
Thx to Mamallan Uthaman for the patch
Modified:
myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/GoButtonRenderer.java
myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlRenderer.java
myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/test/resources/org/apache/myfaces/trinidadinternal/renderkit/golden/goButton-minimalPPC-golden.xml
Modified: myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/GoButtonRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/GoButtonRenderer.java?rev=712993&r1=712992&r2=712993&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/GoButtonRenderer.java (original)
+++ myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/GoButtonRenderer.java Tue Nov 11 00:36:31 2008
@@ -81,43 +81,71 @@
arc.setCurrentClientId(clientId);
String element;
- boolean useButton;
- boolean isFormElement = false;
+ boolean useButton = false;
+ boolean useInput = false;
+ boolean supportScriptEvents = false;
+ boolean imageLink = false;
+ boolean iconAvailable = false;
+ String icon = getIcon(bean);
+
+ if (icon != null)
+ {
+ iconAvailable = true;
+ }
if ((supportsScripting(arc) && supportsIntrinsicEvents(arc)))
{
- if (supportsAdvancedForms(arc))
- {
- element = XhtmlLafConstants.BUTTON_ELEMENT;
- }
- else
- {
- element = XhtmlLafConstants.INPUT_ELEMENT;
- isFormElement = true;
- }
-
+ supportScriptEvents = true;
+ }
+
+ if (supportScriptEvents)
+ {
+ if (supportsAdvancedForms(arc))
+ {
+ element = XhtmlLafConstants.BUTTON_ELEMENT;
useButton = true;
+ }
+ //if icon is set, render as an image element within a link element
+ //since "buttons" html element is not supported and "input" element of
+ //type=image does not support "onClick" JS handler.
+ else if (iconAvailable && !supportsOnClickOnImgInput(arc))
+ {
+ element = XhtmlLafConstants.LINK_ELEMENT;
+ imageLink = true;
+ }
+ else
+ {
+ element = XhtmlLafConstants.INPUT_ELEMENT;
+ useInput = true;
+ }
}
else
{
- element = XhtmlLafConstants.LINK_ELEMENT;
- useButton = false;
+ element = XhtmlLafConstants.LINK_ELEMENT;
}
-
+
ResponseWriter rw = context.getResponseWriter();
+ boolean disabled = getDisabled(bean);
rw.startElement(element, component);
renderId(context, component);
- boolean disabled = getDisabled(bean);
- if (useButton)
- {
- rw.writeAttribute("type", "button", null);
- if (disabled)
+
+ if (supportScriptEvents)
+ {
+ if (useInput && iconAvailable)
+ {
+ rw.writeAttribute("type", "image", null);
+ }
+ //For any element like <button> or <input> except <a> set type to "button"
+ else if (!imageLink)
+ {
+ rw.writeAttribute("type", "button", null);
+ }
+ // If disabled, render "disable" only for <input> and <button> elements
+ if (!imageLink && disabled)
+ {
rw.writeAttribute("disabled", Boolean.TRUE, "disabled");
+ }
}
- else
- {
- renderEncodedActionURI(context, "href", getDestination(bean));
- }
-
+
if (disabled || !supportsNavigation(arc))
{
// Skip over event attributes when disabled
@@ -126,12 +154,18 @@
else
{
renderAllAttributes(context, arc, bean);
- if (useButton)
+ if (supportScriptEvents)
{
rw.writeAttribute("onclick", getButtonOnclick(bean), null);
+ if (imageLink)
+ {
+ renderEncodedActionURI(context, XhtmlConstants.HREF_ATTRIBUTE, "#");
+ }
}
else
{
+ renderEncodedActionURI(context, XhtmlConstants.HREF_ATTRIBUTE, getDestination(bean));
+
if (supportsTarget(arc))
{
rw.writeAttribute("target", getTargetFrame(bean), null);
@@ -158,29 +192,56 @@
}
String text = getText(bean);
- String icon = getIcon(bean);
-
- if(!isFormElement){
- AccessKeyUtils.renderAccessKeyText(context,
- text,
- accessKey,
- SkinSelectors.AF_ACCESSKEY_STYLE_CLASS);
-
- if (icon != null)
- OutputUtils.renderImage(context, arc, icon, null, null, null,
+
+ if (useButton)
+ {
+
+ AccessKeyUtils.renderAccessKeyText(context,
+ text,
+ accessKey,
+ SkinSelectors.AF_ACCESSKEY_STYLE_CLASS);
+ if (icon != null)
+ OutputUtils.renderImage(context, arc, icon, null, null, null,
getShortDesc(bean));
}
- else {
- if (icon != null && text == null){
- renderEncodedResourceURI(context, "src", icon);
- }
- else{
- rw.writeAttribute("value", text, "text");
- }
+ // For PDAs, render only the image if icon is available
+ else if (!supportScriptEvents)
+ {
+ if(iconAvailable)
+ {
+
+ OutputUtils.renderImage(context, arc, icon, null, null, null,
+ getShortDesc(bean));
+ }
+ else
+ {
+
+ AccessKeyUtils.renderAccessKeyText(context,
+ text,
+ accessKey,
+ SkinSelectors.AF_ACCESSKEY_STYLE_CLASS);
+ }
+ }
+ else
+ {
+ // Render an image tag inside the anchor tag
+ if (imageLink)
+ {
+ OutputUtils.renderImage(context, arc, icon, null, null, null,
+ getShortDesc(bean));
+ }
+ // For input element render src attribute to the url of the icon
+ else if (iconAvailable)
+ {
+ renderEncodedResourceURI(context, "src", icon);
+ }
+ else
+ {
+ rw.writeAttribute("value", text, "text");
+ }
}
rw.endElement(element);
-
arc.setCurrentClientId(null);
}
Modified: myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlRenderer.java?rev=712993&r1=712992&r2=712993&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlRenderer.java (original)
+++ myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/XhtmlRenderer.java Tue Nov 11 00:36:31 2008
@@ -1066,7 +1066,17 @@
}
}
-
+ /**
+ * Returns true if the agent supports the "onclick" JS Handler in an "input"
+ * HTML element of type "image"
+ */
+ static public boolean supportsOnClickOnImgInput(RenderingContext arc)
+ {
+ Object cap = arc.getAgent().getCapabilities().get(
+ TrinidadAgent.CAP_ONCLICK_IMG_INPUT);
+ return !Boolean.FALSE.equals(cap);
+ }
+
private PropertyKey _shortDescKey;
private PropertyKey _styleClassKey;
private PropertyKey _inlineStyleKey;
Modified: myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/test/resources/org/apache/myfaces/trinidadinternal/renderkit/golden/goButton-minimalPPC-golden.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/test/resources/org/apache/myfaces/trinidadinternal/renderkit/golden/goButton-minimalPPC-golden.xml?rev=712993&r1=712992&r2=712993&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/test/resources/org/apache/myfaces/trinidadinternal/renderkit/golden/goButton-minimalPPC-golden.xml (original)
+++ myfaces/trinidad/branches/1.2.9.1-branch/trinidad-impl/src/test/resources/org/apache/myfaces/trinidadinternal/renderkit/golden/goButton-minimalPPC-golden.xml Tue Nov 11 00:36:31 2008
@@ -96,16 +96,20 @@
</input>
<!--AttributeTest[icon,/foo.gif]-->
- <input
+ <a
class="af_goButton"
onclick="document.location='encoded-action-url:http://www.oracle.com'"
- type="button"
- value="ButtonText"
+ href="uri-attr:encoded-action-url:#"
id="uri-attr:mainId"
name="uri-attr:mainId"
>
- </input>
+ <img
+ src="uri-attr:encoded-resource-url:/test-context-path/foo.gif"
+ >
+
+ </img>
+ </a>
<!--AttributeTest[onblur,null]-->
<input