You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ar...@apache.org on 2009/12/10 18:46:47 UTC
svn commit: r889345 [5/17] - in
/myfaces/trinidad/branches/ar_clientBehaviors: ./ trinidad-api/
trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/
trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/
trinidad-api/src/main/java/or...
Modified: myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ColumnRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ColumnRenderer.java?rev=889345&r1=889344&r2=889345&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ColumnRenderer.java (original)
+++ myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ColumnRenderer.java Thu Dec 10 17:46:13 2009
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -19,6 +19,7 @@
package org.apache.myfaces.trinidadinternal.renderkit.core.xhtml;
import java.io.IOException;
+
import java.util.Iterator;
import java.util.List;
@@ -29,8 +30,8 @@
import org.apache.myfaces.trinidad.bean.FacesBean;
import org.apache.myfaces.trinidad.component.UIXColumn;
import org.apache.myfaces.trinidad.component.core.data.CoreColumn;
-import org.apache.myfaces.trinidad.logging.TrinidadLogger;
import org.apache.myfaces.trinidad.context.RenderingContext;
+import org.apache.myfaces.trinidad.logging.TrinidadLogger;
import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.table.BandingData;
import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.table.CellUtils;
import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.table.ColumnData;
@@ -38,6 +39,7 @@
import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.table.RowData;
import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.table.TableRenderingContext;
+
public class ColumnRenderer extends ColumnGroupRenderer
{
public ColumnRenderer()
@@ -50,10 +52,11 @@
*/
@Override
protected void encodeAll(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
TableRenderingContext tContext =
TableRenderingContext.getCurrentInstance();
@@ -67,7 +70,7 @@
if (_isColumnGroup(component))
{
- _columnGroupRenderer.encodeAll(context, arc, component, bean);
+ _columnGroupRenderer.encodeAll(context, rc, component, bean);
return;
}
@@ -77,15 +80,15 @@
switch (stage)
{
case RenderStage.INITIAL_STAGE:
- _computeMode(arc, tContext, component, bean);
+ _computeMode(rc, tContext, component, bean);
break;
case RenderStage.COLUMN_HEADER_STAGE:
- _renderHeaderMode(context, arc, tContext, component);
+ _renderHeaderMode(context, rc, tContext, component);
break;
case RenderStage.COLUMN_FOOTER_STAGE:
- _renderFooterMode(context, arc, tContext, component);
+ _renderFooterMode(context, rc, tContext, component);
break;
case RenderStage.TREE_NODE_STAGE:
@@ -93,7 +96,7 @@
break;
case RenderStage.DATA_STAGE:
- _renderDataMode(context, arc, tContext, component);
+ _renderDataMode(context, rc, tContext, component);
break;
case RenderStage.START_ROW_STAGE:
@@ -114,7 +117,8 @@
}
@SuppressWarnings("unchecked")
- private boolean _isColumnGroup(UIComponent column)
+ private boolean _isColumnGroup(
+ UIComponent column)
{
Iterator<UIComponent> kids = column.getChildren().iterator();
// Special columns - nothing is a column group
@@ -126,10 +130,12 @@
@SuppressWarnings("unchecked")
- protected void renderKids(FacesContext context,
- RenderingContext arc,
- TableRenderingContext trc,
- UIComponent column) throws IOException
+ protected void renderKids(
+ FacesContext context,
+ RenderingContext rc,
+ TableRenderingContext trc,
+ UIComponent column
+ ) throws IOException
{
boolean renderedOne = false;
for(UIComponent child : (List<UIComponent>)column.getChildren())
@@ -157,15 +163,17 @@
* Render either one child or all (which depends on useSeparateRows)
* @todo This dual-purpose method is creepy.
*/
- private void _renderKids(FacesContext context,
- RenderingContext arc,
- TableRenderingContext tContext,
- UIComponent column,
- int kid) throws IOException
+ private void _renderKids(
+ FacesContext context,
+ RenderingContext rc,
+ TableRenderingContext tContext,
+ UIComponent column,
+ int kid
+ ) throws IOException
{
if (kid < 0)
{
- renderKids(context, arc, tContext, column);
+ renderKids(context, rc, tContext, column);
}
else
{
@@ -176,8 +184,8 @@
private void _startRowMode(
TableRenderingContext tContext,
- UIComponent column)
- throws IOException
+ UIComponent column
+ ) throws IOException
{
ColumnData colData = tContext.getColumnData();
int physicalIndex = colData.getPhysicalColumnIndex();
@@ -194,13 +202,12 @@
// the default is to span just one row.
}
-
private void _renderDataMode(
- FacesContext context,
- RenderingContext arc,
+ FacesContext context,
+ RenderingContext rc,
TableRenderingContext tContext,
- UIComponent column)
- throws IOException
+ UIComponent column
+ ) throws IOException
{
ColumnData colData = tContext.getColumnData();
RowData rowData = tContext.getRowData();
@@ -229,7 +236,7 @@
int span = (subRow == (totalKids - 1))
? (currentRowSpan - subRow)
: 1;
- _renderTD(context, arc, tContext, column, subRow, span);
+ _renderTD(context, rc, tContext, column, subRow, span);
}
return;
@@ -238,7 +245,7 @@
// we only render if we haven't been rendered before:
if (subRow == 0)
{
- _renderTD(context, arc, tContext, column, -1, currentRowSpan);
+ _renderTD(context, rc, tContext, column, -1, currentRowSpan);
}
}
@@ -248,8 +255,9 @@
* @throws java.io.IOException
*/
public static void renderHeadersAttr(
- FacesContext context,
- TableRenderingContext tContext) throws IOException
+ FacesContext context,
+ TableRenderingContext tContext
+ ) throws IOException
{
if (tContext.isExplicitHeaderIDMode())
{
@@ -271,13 +279,14 @@
/**
* @todo Generate Unique IDs correctly!
*/
- private void _renderTD(FacesContext context,
- RenderingContext arc,
- TableRenderingContext tContext,
- UIComponent column,
- int kidIndex,
- int rowSpan)
- throws IOException
+ private void _renderTD(
+ FacesContext context,
+ RenderingContext rc,
+ TableRenderingContext tContext,
+ UIComponent column,
+ int kidIndex,
+ int rowSpan
+ ) throws IOException
{
ResponseWriter writer = context.getResponseWriter();
ColumnData colData = tContext.getColumnData();
@@ -304,21 +313,21 @@
}
borderStyleClass =
- CellUtils.getHeaderBorderStyle(tContext, arc, false, false);
+ CellUtils.getHeaderBorderStyle(tContext, rc, false, false);
}
else // !isRowHeader
{
writer.startElement(XhtmlConstants.TABLE_DATA_ELEMENT, column);
cellClass = getTableDataStyleClass(tContext);
renderHeadersAttr(context, tContext);
- borderStyleClass = CellUtils.getDataBorderStyle(arc, tContext);
+ borderStyleClass = CellUtils.getDataBorderStyle(rc, tContext);
} // endif (isRowHeader)
FacesBean bean = getFacesBean(column);
- String userStyleClass = getStyleClass(bean);
- String userInlineStyle = getInlineStyle(bean);
+ String userStyleClass = getStyleClass(column, bean);
+ String userInlineStyle = getInlineStyle(column, bean);
- renderStyleClasses(context, arc, new String[]{userStyleClass, cellClass, borderStyleClass});
+ renderStyleClasses(context, rc, new String[]{userStyleClass, cellClass, borderStyleClass});
writer.writeAttribute("style", userInlineStyle, null);
@@ -327,7 +336,7 @@
CellUtils.renderSpan(context, true /*isRowSpan*/, rowSpan);
- _renderKids(context, arc, tContext, column, kidIndex);
+ _renderKids(context, rc, tContext, column, kidIndex);
writer.endElement(isRowHeader
? XhtmlConstants.TABLE_HEADER_ELEMENT
@@ -338,8 +347,9 @@
/**
* @todo I don't think this method is used.
*/
- protected Object getColumnWidthFromTable(TableRenderingContext tContext,
- int index)
+ protected Object getColumnWidthFromTable(
+ TableRenderingContext tContext,
+ int index)
{
return tContext.getColumnWidth(index);
}
@@ -348,12 +358,12 @@
* protected so that the table data style can be overridden.
* see FocusColumnRenderer
*/
- protected String getTableDataStyleClass(TableRenderingContext tContext)
+ protected String getTableDataStyleClass(
+ TableRenderingContext tContext)
{
return getDataStyleClass(tContext);
}
-
protected boolean isSpecialColumn()
{
return false;
@@ -362,7 +372,7 @@
/**
*/
private void _computeMode(
- RenderingContext arc,
+ RenderingContext rc,
TableRenderingContext tContext,
UIComponent component,
FacesBean bean)
@@ -370,7 +380,7 @@
boolean shouldWrap = getShouldWrap();
UIComponent header = getFacet(component, CoreColumn.HEADER_FACET);
- Object headerText = getHeaderText(bean);
+ Object headerText = getHeaderText(component, bean);
// SpecialColumn check is to fix
// 3820854 APPS: NEED WAY TO NOT RENDER SELECTION COLUMN HEADER
@@ -382,19 +392,19 @@
if (isSpecialColumn())
{
colData.setSpecialColumnData(tContext,
- arc,
- getNoWrap(bean) && !shouldWrap,
+ rc,
+ getNoWrap(component, bean) && !shouldWrap,
shouldWrap,
- getFormatType(bean));
+ getFormatType(component, bean));
}
else
{
- colData.setColumnData(getWidth(bean),
- getFormatType(bean),
- getNoWrap(bean) && !shouldWrap,
- getHeaderNoWrap(bean) && !shouldWrap,
- getSeparateRows(bean),
- getRowHeader(bean));
+ colData.setColumnData(getWidth(component, bean),
+ getFormatType(component, bean),
+ getNoWrap(component, bean) && !shouldWrap,
+ getHeaderNoWrap(component, bean) && !shouldWrap,
+ getSeparateRows(component, bean),
+ getRowHeader(component, bean));
}
NodeData parentNode = getParentNode(tContext);
@@ -420,11 +430,11 @@
}
private void _renderFooterMode(
- FacesContext context,
- RenderingContext arc,
+ FacesContext context,
+ RenderingContext rc,
TableRenderingContext tContext,
- UIComponent column)
- throws IOException
+ UIComponent column
+ ) throws IOException
{
ColumnData colData = tContext.getColumnData();
@@ -453,12 +463,12 @@
String borderStyleClass =
CellUtils.getBorderClass(false, true, false, false);
- renderStyleClasses(context, arc,
+ renderStyleClasses(context, rc,
new String[]{styleClass, borderStyleClass});
}
else
- renderStyleClass(context, arc, styleClass);
+ renderStyleClass(context, rc, styleClass);
UIComponent footer = getFacet(column, CoreColumn.FOOTER_FACET);
if (footer != null)
@@ -469,11 +479,11 @@
}
private void _renderHeaderMode(
- FacesContext context,
- RenderingContext arc,
+ FacesContext context,
+ RenderingContext rc,
TableRenderingContext tContext,
- UIComponent column)
- throws IOException
+ UIComponent column
+ ) throws IOException
{
final ColumnData colData = tContext.getColumnData();
int rowSpan = colData.getHeaderRowSpan();
@@ -500,7 +510,7 @@
}
String colID = renderHeaderAndSpan(context,
- arc,
+ rc,
tContext,
column,
rowSpan,
@@ -523,12 +533,12 @@
}
}
-
//
// static code follows ***********************************************
//
- public static String getDataStyleClass(TableRenderingContext tContext)
+ public static String getDataStyleClass(
+ TableRenderingContext tContext)
{
final String cellClass;
final ColumnData colData = tContext.getColumnData();
@@ -564,12 +574,12 @@
public static String renderDataStyleClass(
FacesContext context,
- RenderingContext arc,
+ RenderingContext rc,
TableRenderingContext tContext)
throws IOException
{
String cellClass = getDataStyleClass(tContext);
- renderStyleClass(context, arc, cellClass);
+ renderStyleClass(context, rc, cellClass);
return cellClass;
}
Modified: myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandButtonRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandButtonRenderer.java?rev=889345&r1=889344&r2=889345&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandButtonRenderer.java (original)
+++ myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandButtonRenderer.java Thu Dec 10 17:46:13 2009
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -31,9 +31,9 @@
import org.apache.myfaces.trinidad.bean.PropertyKey;
import org.apache.myfaces.trinidad.component.core.nav.CoreCommandButton;
import org.apache.myfaces.trinidad.context.RenderingContext;
-
import org.apache.myfaces.trinidadinternal.agent.TrinidadAgent;
+
public class CommandButtonRenderer extends CommandLinkRenderer
{
public CommandButtonRenderer()
@@ -41,19 +41,20 @@
this(CoreCommandButton.TYPE);
}
- protected CommandButtonRenderer(FacesBean.Type type)
+ protected CommandButtonRenderer(
+ FacesBean.Type type)
{
super(type);
}
@Override
- protected void findTypeConstants(FacesBean.Type type)
+ protected void findTypeConstants(
+ FacesBean.Type type)
{
super.findTypeConstants(type);
_iconKey = type.findKey("icon");
}
-
@Override
public boolean getRendersChildren()
{
@@ -62,64 +63,65 @@
@Override
protected void encodeAll(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
String clientId = getClientId(context, component);
- if (canSkipRendering(arc, clientId))
+ if (canSkipRendering(rc, clientId))
return;
- if (getPartialSubmit(bean))
+ if (getPartialSubmit(component, bean))
{
- AutoSubmitUtils.writeDependencies(context, arc);
+ AutoSubmitUtils.writeDependencies(context, rc);
}
// Make sure we don't have anything to save
- assert(arc.getCurrentClientId() == null);
- arc.setCurrentClientId(clientId);
-
+ assert(rc.getCurrentClientId() == null);
+ rc.setCurrentClientId(clientId);
+
ResponseWriter rw = context.getResponseWriter();
- String icon = getIcon(bean);
+ String icon = getIcon(component, bean);
//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.
- if((icon != null) && !_supportsOnClickOnImgInput(arc))
+ if((icon != null) && !_supportsOnClickOnImgInput(rc))
{
- if(!getDisabled(bean))
+ if(!getDisabled(component, bean))
{
rw.startElement(XhtmlConstants.LINK_ELEMENT, component);
renderEncodedActionURI(context, XhtmlConstants.HREF_ATTRIBUTE, "#");
- rw.writeAttribute(XhtmlConstants.ONCLICK_ATTRIBUTE,
- getOnclick(bean), null);
+ rw.writeAttribute(XhtmlConstants.ONCLICK_ATTRIBUTE,
+ getOnclick(component, bean), null);
rw.startElement("img", component);
- renderAllAttributes(context, arc, bean);
+ renderAllAttributes(context, rc, component, bean);
renderEncodedResourceURI(context, "src", icon);
rw.endElement("img");
rw.endElement(XhtmlConstants.LINK_ELEMENT);
- }
+ }
else
{
//If disabled attribute is set on PDAs for commandButtons set as icon,
//render a static image
rw.startElement("img",component);
- renderAllAttributes(context, arc, bean);
+ renderAllAttributes(context, rc, component, bean);
renderEncodedResourceURI(context, "src", icon);
rw.endElement("img");
}
- }
+ }
else
{
- boolean useButtonTag = useButtonTags(arc);
+ boolean useButtonTag = useButtonTags(rc);
String element = useButtonTag ? "button" : "input";
rw.startElement(element, component);
renderId(context, component);
// Write the text and access key
- String text = getText(bean);
-
+ String text = getText(component, bean);
+
if (useButtonTag)
rw.writeAttribute("type", getButtonType(), null);
else if (icon != null)
@@ -127,28 +129,28 @@
else
rw.writeAttribute("type", getInputType(), null);
- if (getDisabled(bean))
+ if (getDisabled(component, bean))
{
rw.writeAttribute("disabled", Boolean.TRUE, "disabled");
// Skip over event attributes when disabled
- renderStyleAttributes(context, arc, bean);
+ renderStyleAttributes(context, rc, component, bean);
}
else
{
- renderAllAttributes(context, arc, bean);
+ renderAllAttributes(context, rc, component, bean);
}
char accessKey;
- if (supportsAccessKeys(arc))
+ if (supportsAccessKeys(rc))
{
- accessKey = getAccessKey(bean);
+ accessKey = getAccessKey(component, bean);
if (accessKey != CHAR_UNDEFINED)
{
rw.writeAttribute("accesskey",
Character.valueOf(accessKey),
"accessKey");
- }
- }
+ }
+ }
else
{
accessKey = CHAR_UNDEFINED;
@@ -160,26 +162,26 @@
accessKey,
SkinSelectors.AF_ACCESSKEY_STYLE_CLASS);
if (icon != null)
- OutputUtils.renderImage(context, arc, icon, null, null, null,
- getShortDesc(bean));
- }
+ OutputUtils.renderImage(context, rc, icon, null, null, null,
+ getShortDesc(component, bean));
+ }
else
{
- // For Non-JavaScript browsers, encode the name attribute with the
- // parameter name and value thus it would enable the browsers to
+ // For Non-JavaScript browsers, encode the name attribute with the
+ // parameter name and value thus it would enable the browsers to
// include the name of this element in its payLoad if it submits the
// page.
-
- if(!supportsScripting(arc))
+
+ if(!supportsScripting(rc))
{
- String encodingKey =
+ String encodingKey =
(icon != null)? XhtmlConstants.NO_JS_INPUT_IMAGE_KEY
: XhtmlConstants.NO_JS_PARAMETER_KEY;
-
+
rw.writeAttribute("name", XhtmlConstants.SOURCE_PARAM + encodingKey
+ clientId, null);
}
-
+
if (icon != null)
{
renderEncodedResourceURI(context, "src", icon);
@@ -189,10 +191,10 @@
rw.writeAttribute("value", text, "text");
}
}
-
+
rw.endElement(element);
}
- arc.setCurrentClientId(null);
+ rc.setCurrentClientId(null);
}
protected String getButtonType()
@@ -204,26 +206,27 @@
{
return "submit";
}
-
+
protected boolean useButtonTags(RenderingContext arc)
{
return (supportsScripting(arc) &&
supportsAdvancedForms(arc) &&
supportsIntrinsicEvents(arc));
-
+
}
/**
* Override to return any state-based (selected, disabled, etc.)
- * CSS style markers. HINT: use an immutable, cached List<String>
+ * CSS style markers. HINT: use an immutable, cached List<String>
* for better performance.
*/
protected List<String> getStateStyleClasses(
- FacesContext context,
- RenderingContext arc,
- FacesBean bean)
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean)
{
- if (getDisabled(bean))
+ if (getDisabled(component, bean))
return _DISABLED_STATE_LIST;
return null;
}
@@ -231,22 +234,24 @@
// FIXME: move this implementation to XhtmlRenderer
@Override
protected void renderStyleAttributes(
- FacesContext context,
- RenderingContext arc,
- FacesBean bean,
- String defaultStyleClass) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean,
+ String defaultStyleClass
+ ) throws IOException
{
- String styleClass = getStyleClass(bean);
+ String styleClass = getStyleClass(component, bean);
// -= Simon =-
// FIXME: How come inline style is never read locally?
// String inlineStyle = getInlineStyle(bean);
- List<String> stateStyleClasses = getStateStyleClasses(context, arc, bean);
+ List<String> stateStyleClasses = getStateStyleClasses(context, rc, component, bean);
- if ((styleClass==null) &&
- (defaultStyleClass != null) &&
+ if ((styleClass==null) &&
+ (defaultStyleClass != null) &&
(stateStyleClasses == null))
{
- renderStyleClass(context, arc, defaultStyleClass);
+ renderStyleClass(context, rc, defaultStyleClass);
}
else
{
@@ -257,17 +262,17 @@
else
userStyleClassCount = parsedStyleClasses.size();
- int numStates = ((stateStyleClasses != null) ?
+ int numStates = ((stateStyleClasses != null) ?
stateStyleClasses.size() : 0);
int numClasses = userStyleClassCount +
((defaultStyleClass != null) ? 1 : 0) +
numStates;
if (numClasses > 0)
{
- // set all the styleClasses in one array so we can pass it to
+ // set all the styleClasses in one array so we can pass it to
// renderStyleClasses
String[] styleClasses = new String[numClasses];
-
+
int i=0;
if (parsedStyleClasses != null)
{
@@ -283,17 +288,17 @@
}
if (defaultStyleClass != null)
styleClasses[i++] = defaultStyleClass;
-
+
for (int j=0; j < numStates; j++, i++)
{
styleClasses[i] = stateStyleClasses.get(j);
- }
+ }
- renderStyleClasses(context, arc, styleClasses);
+ renderStyleClasses(context, rc, styleClasses);
}
}
- String style = getInlineStyle(bean);
+ String style = getInlineStyle(component, bean);
if (style != null)
{
context.getResponseWriter().writeAttribute("style",
@@ -303,12 +308,16 @@
}
@Override
- protected String getDefaultStyleClass(FacesBean bean)
+ protected String getDefaultStyleClass(
+ UIComponent component,
+ FacesBean bean)
{
return SkinSelectors.AF_COMMAND_BUTTON_STYLE_CLASS;
}
- protected String getIcon(FacesBean bean)
+ protected String getIcon(
+ UIComponent component,
+ FacesBean bean)
{
return toResourceUri(FacesContext.getCurrentInstance(), bean.getProperty(_iconKey));
}
@@ -322,30 +331,32 @@
@Override
protected void renderId(
FacesContext context,
- UIComponent component) throws IOException
- {
+ UIComponent component
+ ) throws IOException
+ {
if (shouldRenderId(context, component))
{
String clientId = getClientId(context, component);
context.getResponseWriter().writeURIAttribute("id", clientId, "id");
RenderingContext arc = RenderingContext.getCurrentInstance();
- // For Non-JavaScript browsers, name attribute is handled separately
+ // For Non-JavaScript browsers, name attribute is handled separately
// so skip it here
if (supportsScripting(arc))
{
context.getResponseWriter().writeURIAttribute("name", clientId, "id");
}
- }
+ }
}
-
+
/**
- * Returns true if the agent supports the "onclick" JS Handler in an "input"
+ * Returns true if the agent supports the "onclick" JS Handler in an "input"
* HTML element of type "image"
*
*/
- static private boolean _supportsOnClickOnImgInput(RenderingContext arc)
+ static private boolean _supportsOnClickOnImgInput(
+ RenderingContext rc)
{
- Object cap = arc.getAgent().getCapabilities().get(
+ Object cap = rc.getAgent().getCapabilities().get(
TrinidadAgent.CAP_ONCLICK_IMG_INPUT);
return !Boolean.FALSE.equals(cap);
}
Modified: myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandLinkRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandLinkRenderer.java?rev=889345&r1=889344&r2=889345&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandLinkRenderer.java (original)
+++ myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandLinkRenderer.java Thu Dec 10 17:46:13 2009
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -29,11 +29,11 @@
import org.apache.myfaces.trinidad.bean.FacesBean;
import org.apache.myfaces.trinidad.bean.PropertyKey;
import org.apache.myfaces.trinidad.component.core.nav.CoreCommandLink;
+import org.apache.myfaces.trinidad.context.FormData;
+import org.apache.myfaces.trinidad.context.RenderingContext;
import org.apache.myfaces.trinidad.context.RequestContext;
import org.apache.myfaces.trinidad.event.ReturnEvent;
-import org.apache.myfaces.trinidad.context.FormData;
-import org.apache.myfaces.trinidad.context.RenderingContext;
public class CommandLinkRenderer extends GoLinkRenderer
{
@@ -42,13 +42,15 @@
this(CoreCommandLink.TYPE);
}
- protected CommandLinkRenderer(FacesBean.Type type)
+ protected CommandLinkRenderer(
+ FacesBean.Type type)
{
super(type);
}
-
+
@Override
- protected void findTypeConstants(FacesBean.Type type)
+ protected void findTypeConstants(
+ FacesBean.Type type)
{
super.findTypeConstants(type);
_immediateKey = type.findKey("immediate");
@@ -57,7 +59,9 @@
@SuppressWarnings("unchecked")
@Override
- public void decode(FacesContext context, UIComponent component)
+ public void decode(
+ FacesContext context,
+ UIComponent component)
{
RequestContext afContext = RequestContext.getCurrentInstance();
ReturnEvent returnEvent =
@@ -68,79 +72,87 @@
}
else
{
- Map<String, String> parameterMap =
+ Map<String, String> parameterMap =
context.getExternalContext().getRequestParameterMap();
-
+
Object source = parameterMap.get("source");
String clientId = component.getClientId(context);
if ((source != null) && source.equals(clientId))
{
(new ActionEvent(component)).queue();
- if (getPartialSubmit(getFacesBean(component)))
+ if (getPartialSubmit(component, getFacesBean(component)))
{
PartialPageUtils.forcePartialRendering(context);
}
}
}
}
-
+
@Override
protected void encodeBegin(
- FacesContext context,
- RenderingContext arc,
- UIComponent comp,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent comp,
+ FacesBean bean
+ ) throws IOException
{
- if (getPartialSubmit(bean))
+ if (getPartialSubmit(comp, bean))
{
- AutoSubmitUtils.writeDependencies(context, arc);
+ AutoSubmitUtils.writeDependencies(context, rc);
}
-
+
String clientId = getClientId(context, comp);
// Make sure we don't have anything to save
- assert(arc.getCurrentClientId() == null);
- arc.setCurrentClientId(clientId);
-
- // Find the params up front, and save them off -
+ assert(rc.getCurrentClientId() == null);
+ rc.setCurrentClientId(clientId);
+
+ // Find the params up front, and save them off -
// getOnClick() doesn't have access to the UIComponent
String extraParams = AutoSubmitUtils.getParameters(comp);
- Object old = arc.getProperties().put(_EXTRA_SUBMIT_PARAMS_KEY,
+ Object old = rc.getProperties().put(_EXTRA_SUBMIT_PARAMS_KEY,
extraParams);
- super.encodeBegin(context, arc, comp, bean);
+ super.encodeBegin(context, rc, comp, bean);
// Restore any old params, though really, how could that happen??
- arc.getProperties().put(_EXTRA_SUBMIT_PARAMS_KEY, old);
-
- arc.setCurrentClientId(null);
+ rc.getProperties().put(_EXTRA_SUBMIT_PARAMS_KEY, old);
+
+ rc.setCurrentClientId(null);
}
@Override
public void encodeEnd(
- FacesContext context,
- RenderingContext arc,
- UIComponent comp,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent comp,
+ FacesBean bean
+ ) throws IOException
{
- super.encodeEnd(context, arc, comp, bean);
- FormData fd = arc.getFormData();
+ super.encodeEnd(context, rc, comp, bean);
+ FormData fd = rc.getFormData();
if (fd != null)
fd.addNeededValue(XhtmlConstants.SOURCE_PARAM);
}
@Override
- protected String getDestination(FacesBean bean)
+ protected String getDestination(
+ UIComponent component,
+ FacesBean bean)
{
return null;
}
@Override
- protected String getTargetFrame(FacesBean bean)
+ protected String getTargetFrame(
+ UIComponent component,
+ FacesBean bean)
{
return null;
}
@Override
- protected boolean hasOnclick(FacesBean bean)
+ protected boolean hasOnclick(
+ UIComponent component,
+ FacesBean bean)
{
// More efficient
return true;
@@ -149,24 +161,28 @@
/**
* Returns the component's onclick
*/
- protected String getComponentOnclick(FacesBean bean)
+ protected String getComponentOnclick(
+ UIComponent component,
+ FacesBean bean)
{
- return super.getOnclick(bean);
+ return super.getOnclick(component, bean);
}
@Override
- protected String getOnclick(FacesBean bean)
+ protected String getOnclick(
+ UIComponent component,
+ FacesBean bean)
{
- String onclick = getComponentOnclick(bean);
+ String onclick = getComponentOnclick(component, bean);
RenderingContext arc = RenderingContext.getCurrentInstance();
String id = arc.getCurrentClientId();
- boolean immediate = getImmediate(bean);
-
+ boolean immediate = getImmediate(component, bean);
+
String extraParams = (String)
arc.getProperties().get(_EXTRA_SUBMIT_PARAMS_KEY);
String script;
- if (getPartialSubmit(bean))
+ if (getPartialSubmit(component, bean))
{
script = AutoSubmitUtils.getSubmitScript(
arc, id, immediate, false,
@@ -183,10 +199,15 @@
false/* return false*/);
}
+ //return XhtmlUtils.buildClientEventHandler(facesContext, component, false, "click",
+ // params, onclick, script);
+
return XhtmlUtils.getChainedJS(onclick, script, true);
}
- protected boolean getImmediate(FacesBean bean)
+ protected boolean getImmediate(
+ UIComponent component,
+ FacesBean bean)
{
Object o = bean.getProperty(_immediateKey);
if (o == null)
@@ -195,8 +216,9 @@
return Boolean.TRUE.equals(o);
}
-
- protected boolean getPartialSubmit(FacesBean bean)
+ protected boolean getPartialSubmit(
+ UIComponent component,
+ FacesBean bean)
{
Object o = bean.getProperty(_partialSubmitKey);
if (o == null)
@@ -205,9 +227,8 @@
return Boolean.TRUE.equals(o);
}
-
private PropertyKey _immediateKey;
private PropertyKey _partialSubmitKey;
-
+
static private final Object _EXTRA_SUBMIT_PARAMS_KEY = new Object();
}
Modified: myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/DesktopPanelPageHeaderRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/DesktopPanelPageHeaderRenderer.java?rev=889345&r1=889344&r2=889345&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/DesktopPanelPageHeaderRenderer.java (original)
+++ myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/DesktopPanelPageHeaderRenderer.java Thu Dec 10 17:46:13 2009
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -47,7 +47,8 @@
}
@Override
- protected void findTypeConstants(FacesBean.Type type)
+ protected void findTypeConstants(
+ FacesBean.Type type)
{
super.findTypeConstants(type);
_chromeTypeKey = type.findKey("chromeType");
@@ -61,29 +62,31 @@
@Override
protected void encodeAll(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
// =-=AEW We don't have any real agent switching
- if (!isDesktop(arc))
+ if (!isDesktop(rc))
{
- delegateRenderer(context, arc, component, bean, _pdaRenderer);
+ delegateRenderer(context, rc, component, bean, _pdaRenderer);
}
else
{
- encodeAllDesktop(context, arc, component, bean);
+ encodeAllDesktop(context, rc, component, bean);
}
}
protected void encodeAllDesktop(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
UIComponent branding = getFacet(component,
@@ -109,7 +112,7 @@
// brandingApp goes next to the branding, else it goes
// under the branding.
- Object chromeType = getChromeType(bean);
+ Object chromeType = getChromeType(component, bean);
boolean isCompact = !CorePanelPageHeader.CHROME_TYPE_EXPANDED.equals(chromeType);
@@ -117,20 +120,20 @@
boolean AppContextOrCompact =
((brandingAppCont != null) || isCompact);
- boolean isRTL = arc.isRightToLeft();
+ boolean isRTL = rc.isRightToLeft();
boolean hasGlobal = navigationGlobal != null;
boolean hasSwitch = menuSwitch != null;
ResponseWriter writer = context.getResponseWriter();
writer.startElement("span", component);
- renderAllAttributes(context, arc, bean);
+ renderAllAttributes(context, rc, component, bean);
renderId(context, component);
// start the table element for the next piece
writer.startElement("table", null);
- OutputUtils.renderLayoutTableAttributes(context, arc, "0", "100%");
+ OutputUtils.renderLayoutTableAttributes(context, rc, "0", "100%");
int rowSpan = 0;
@@ -196,7 +199,7 @@
// changed the table from 100% to 1% since it seemed to fix
// the bug where you have extra space between branding
// and brandingApp.
- OutputUtils.renderLayoutTableAttributes(context, arc, "2", "1%" );
+ OutputUtils.renderLayoutTableAttributes(context, rc, "2", "1%" );
writer.startElement("tr", null);
writer.startElement("td", null);
@@ -247,7 +250,7 @@
{
writer.writeAttribute("valign", "bottom", null);
}
- else if(isIE(arc))
+ else if(isIE(rc))
{
// this keeps the table small, so that the tabs can
// get close. Otherwise, the table was super wide.
@@ -322,7 +325,7 @@
// we want the navigationGlobal/menuSwitch
// to layer on top of the branding when the browser is too narrow.
- if (isIE(arc))
+ if (isIE(rc))
{
writer.writeAttribute(
"style",
@@ -373,7 +376,7 @@
writer.startElement("tr", null);
}
// render navigation1. takes up two tds.
- _renderNavigation1(context, arc, writer, navigation1, isRTL);
+ _renderNavigation1(context, rc, writer, navigation1, isRTL);
}
}
@@ -402,7 +405,7 @@
if ( hasSearch )
{
// render search in a row
- _renderSearch(context, arc, writer, search, colSpan);
+ _renderSearch(context, rc, writer, search, colSpan);
}
writer.endElement("table");
@@ -412,22 +415,23 @@
}
- protected Object getChromeType(FacesBean bean)
+ protected Object getChromeType(
+ UIComponent component,
+ FacesBean bean)
{
return bean.getProperty(_chromeTypeKey);
}
-
/**
* render two tds, one with the navigation1 and one with a spacer
* @return void
*/
private void _renderNavigation1(
- FacesContext context,
- RenderingContext arc,
- ResponseWriter writer,
- UIComponent navigation1,
- boolean isRTL
+ FacesContext context,
+ RenderingContext rc,
+ ResponseWriter writer,
+ UIComponent navigation1,
+ boolean isRTL
) throws IOException
{
writer.startElement("td", null);
@@ -439,20 +443,19 @@
writer.endElement("td");
writer.startElement("td", null);
- renderSpacer(context, arc, _NAVIGATION1_SPACER_SIZE, "1");
+ renderSpacer(context, rc, _NAVIGATION1_SPACER_SIZE, "1");
writer.endElement("td");
}
-
/**
* render a table row with the navigation2
* @return void
*/
private void _renderNavigation2(
- FacesContext context,
- ResponseWriter writer,
- UIComponent navigation2,
- int colSpan
+ FacesContext context,
+ ResponseWriter writer,
+ UIComponent navigation2,
+ int colSpan
) throws IOException
{
writer.startElement("tr", null);
@@ -471,20 +474,18 @@
writer.endElement("tr");
}
-
/**
* render a table row with the search
* @return void
*/
private void _renderSearch(
- FacesContext context,
- RenderingContext arc,
+ FacesContext context,
+ RenderingContext rc,
ResponseWriter writer,
- UIComponent search,
+ UIComponent search,
int colSpan
) throws IOException
{
-
writer.startElement("tr", null);
writer.startElement("td", null);
writer.writeAttribute("width",
@@ -494,7 +495,7 @@
writer.writeAttribute("colspan", colSpan, null);
writer.startElement("table", null);
- OutputUtils.renderLayoutTableAttributes(context, arc,
+ OutputUtils.renderLayoutTableAttributes(context, rc,
"0",
"100%");
@@ -505,14 +506,14 @@
writer.startElement("td", null);
writer.writeAttribute( "width", "4", null);
- renderSpacer(context, arc, "4", "1");
+ renderSpacer(context, rc, "4", "1");
writer.endElement("td");
writer.startElement("td", null);
writer.writeAttribute("width",
"100%", null);
writer.writeAttribute("colspan","3", null);
- renderStyleClass(context, arc, SkinSelectors.QUICK_SEARCH_BOX_STYLE_CLASS);
+ renderStyleClass(context, rc, SkinSelectors.QUICK_SEARCH_BOX_STYLE_CLASS);
encodeChild(context, search);
@@ -521,7 +522,7 @@
writer.startElement("td", null);
writer.writeAttribute( "width", "4", null);
- renderSpacer(context, arc, "4", "1");
+ renderSpacer(context, rc, "4", "1");
writer.endElement("td");
writer.endElement("tr");
@@ -531,15 +532,13 @@
writer.endElement("tr");
}
-
-
/**
* Figure out how many columns we have to span for navigation2
* and search
* @return int colSpan number of columns to span.
*/
private int _calculateColSpan(
- int brandingCount,
+ int brandingCount,
boolean navigation1Exists,
boolean navigation2Exists
)
@@ -558,10 +557,8 @@
return colSpan;
}
-
private PropertyKey _chromeTypeKey;
-
private CoreRenderer _pdaRenderer = new PdaPanelPageHeaderRenderer();
private static final String _NAVIGATION1_SPACER_SIZE = "10";
-}
+}
\ No newline at end of file
Modified: myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/DocumentRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/DocumentRenderer.java?rev=889345&r1=889344&r2=889345&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/DocumentRenderer.java (original)
+++ myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/DocumentRenderer.java Thu Dec 10 17:46:13 2009
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -25,7 +25,6 @@
import org.apache.myfaces.trinidad.bean.FacesBean;
import org.apache.myfaces.trinidad.component.core.CoreDocument;
-
import org.apache.myfaces.trinidad.context.RenderingContext;
import org.apache.myfaces.trinidad.render.CoreRenderer;
@@ -41,14 +40,16 @@
{
this(CoreDocument.TYPE);
}
-
- protected DocumentRenderer(FacesBean.Type type)
+
+ protected DocumentRenderer(
+ FacesBean.Type type)
{
super(type);
}
-
+
@Override
- protected void findTypeConstants(FacesBean.Type type)
+ protected void findTypeConstants(
+ FacesBean.Type type)
{
super.findTypeConstants(type);
_html = new HtmlRenderer(type);
@@ -64,26 +65,28 @@
@Override
protected void encodeAll(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
- delegateRendererBegin(context, arc, component, bean, _html);
+ delegateRendererBegin(context, rc, component, bean, _html);
- delegateRendererBegin(context, arc, component, bean, _head);
+ delegateRendererBegin(context, rc, component, bean, _head);
UIComponent meta = getFacet(component, CoreDocument.META_CONTAINER_FACET);
if (meta != null)
encodeChild(context, meta);
- delegateRendererEnd(context, arc, component, bean, _head);
+ delegateRendererEnd(context, rc, component, bean, _head);
- delegateRenderer(context, arc, component, bean, _body);
- delegateRendererEnd(context, arc, component, bean, _html);
+ delegateRenderer(context, rc, component, bean, _body);
+ delegateRendererEnd(context, rc, component, bean, _html);
}
static private class Head extends HeadRenderer
{
- public Head(FacesBean.Type type)
+ public Head(
+ FacesBean.Type type)
{
super(type);
}
Modified: myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/EditableValueRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/EditableValueRenderer.java?rev=889345&r1=889344&r2=889345&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/EditableValueRenderer.java (original)
+++ myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/EditableValueRenderer.java Thu Dec 10 17:46:13 2009
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -31,23 +31,25 @@
import javax.faces.convert.ConverterException;
import javax.faces.validator.Validator;
-import org.apache.myfaces.trinidad.logging.TrinidadLogger;
-
import org.apache.myfaces.trinidad.bean.FacesBean;
import org.apache.myfaces.trinidad.bean.PropertyKey;
import org.apache.myfaces.trinidad.component.UIXEditableValue;
import org.apache.myfaces.trinidad.context.FormData;
import org.apache.myfaces.trinidad.context.RenderingContext;
+import org.apache.myfaces.trinidad.logging.TrinidadLogger;
+
abstract public class EditableValueRenderer extends ValueRenderer
{
- protected EditableValueRenderer(FacesBean.Type type)
+ protected EditableValueRenderer(
+ FacesBean.Type type)
{
super(type);
}
@Override
- protected void findTypeConstants(FacesBean.Type type)
+ protected void findTypeConstants(
+ FacesBean.Type type)
{
super.findTypeConstants(type);
_submittedValueKey = type.findKey("submittedValue");
@@ -62,7 +64,9 @@
// DECODING IMPLEMENTATION
//
@Override
- public void decode(FacesContext context, UIComponent component)
+ public void decode(
+ FacesContext context,
+ UIComponent component)
{
if (skipDecode(context))
return;
@@ -108,9 +112,9 @@
Object submittedValue) throws ConverterException
{
FacesBean bean = getFacesBean(component);
- Converter converter = getConverter(bean);
+ Converter converter = getConverter(component, bean);
if (converter == null)
- converter = getDefaultConverter(context, bean);
+ converter = getDefaultConverter(context, component, bean);
if (converter != null)
{
@@ -132,10 +136,9 @@
UIComponent component)
{
FacesBean bean = getFacesBean(component);
- return !getDisabled(bean) && !getReadOnly(context, bean);
+ return !getDisabled(component, bean) && !getReadOnly(context, component, bean);
}
-
/**
* All editable components need IDs.
*/
@@ -156,58 +159,58 @@
UIComponent component,
FacesBean bean)
{
- Object o = getSubmittedValue(bean);
+ Object o = getSubmittedValue(component, bean);
if (o != null)
return o.toString();
return super.getConvertedString(context, component, bean);
}
- protected Object getSubmittedValue(FacesBean bean)
+ protected Object getSubmittedValue(
+ UIComponent component,
+ FacesBean bean)
{
return bean.getProperty(_submittedValueKey);
}
-
-
protected void addOnSubmitConverterValidators(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean
- )throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
// Bug 2748146: Don't do validation of a disabled field! If the field is
// disabled, the user can't have updated it (there is one way for the
// client to hurt themselves here: by changing the disabled state as part
// of a PPR update after the user has updated the field).
- boolean disabled = getDisabled(bean);
+ boolean disabled = getDisabled(component, bean);
if (!disabled)
{
- boolean requiredField = getRequired(bean);
+ boolean requiredField = getRequired(component, bean);
- Converter converter = getConverter(bean);
+ Converter converter = getConverter(component, bean);
if ( converter == null)
- converter = getDefaultConverter(context, bean);
+ converter = getDefaultConverter(context, component, bean);
- Iterator<Validator> validators = getValidators(bean);
+ Iterator<Validator> validators = getValidators(component, bean);
if (requiredField ||
(converter != null) ||
validators.hasNext())
{
- FormData fData = arc.getFormData();
+ FormData fData = rc.getFormData();
if (fData == null)
{
_LOG.warning("COMPONENT_REQUIRES_FORM", component);
return;
}
- boolean immediate = isImmediate(bean);
+ boolean immediate = isImmediate(component, bean);
((CoreFormData) fData).addOnSubmitConverterValidators(component,
converter,
validators,
@@ -228,7 +231,10 @@
/**
* @todo This will need to be cached!!!
*/
- protected boolean getReadOnly(FacesContext context, FacesBean bean)
+ protected boolean getReadOnly(
+ FacesContext context,
+ UIComponent component,
+ FacesBean bean)
{
Object o = bean.getProperty(_readOnlyKey);
if (o == null)
@@ -240,7 +246,7 @@
// Now, if the ValueExpression underlying the value says it's
// read-only, then again, it is.
- ValueExpression ve = getValueExpression(bean);
+ ValueExpression ve = getValueExpression(component, bean);
if ((ve != null) && ve.isReadOnly(context.getELContext()))
{
if (_LOG.isFiner())
@@ -255,7 +261,9 @@
return false;
}
- protected boolean getDisabled(FacesBean bean)
+ protected boolean getDisabled(
+ UIComponent component,
+ FacesBean bean)
{
Object o = bean.getProperty(_disabledKey);
if (o == null)
@@ -264,7 +272,9 @@
return Boolean.TRUE.equals(o);
}
- protected boolean getRequired(FacesBean bean)
+ protected boolean getRequired(
+ UIComponent component,
+ FacesBean bean)
{
Object o = bean.getProperty(_requiredKey);
if (o == null)
@@ -273,8 +283,9 @@
return Boolean.TRUE.equals(o);
}
-
- protected boolean isImmediate(FacesBean bean)
+ protected boolean isImmediate(
+ UIComponent component,
+ FacesBean bean)
{
Object o = bean.getProperty(_immediateKey);
if (o == null)
@@ -284,7 +295,9 @@
}
@SuppressWarnings("unchecked")
- protected Iterator<Validator> getValidators(FacesBean bean)
+ protected Iterator<Validator> getValidators(
+ UIComponent component,
+ FacesBean bean)
{
return (Iterator<Validator>)bean.entries(_validatorsKey);
}
Modified: myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormElementRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormElementRenderer.java?rev=889345&r1=889344&r2=889345&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormElementRenderer.java (original)
+++ myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormElementRenderer.java Thu Dec 10 17:46:13 2009
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -19,6 +19,7 @@
package org.apache.myfaces.trinidadinternal.renderkit.core.xhtml;
import java.io.IOException;
+
import java.util.Map;
import javax.faces.component.UIComponent;
@@ -32,15 +33,18 @@
import org.apache.myfaces.trinidad.bean.PropertyKey;
import org.apache.myfaces.trinidad.context.RenderingContext;
+
abstract public class FormElementRenderer extends EditableValueRenderer
{
- protected FormElementRenderer(FacesBean.Type type)
+ protected FormElementRenderer(
+ FacesBean.Type type)
{
super(type);
}
@Override
- protected void findTypeConstants(FacesBean.Type type)
+ protected void findTypeConstants(
+ FacesBean.Type type)
{
super.findTypeConstants(type);
_autoSubmitKey = type.findKey("autoSubmit");
@@ -50,7 +54,7 @@
_labelKey = type.findKey("label");
_contentStyleKey = type.findKey("contentStyle");
}
-
+
@Override
public boolean getRendersChildren()
@@ -78,15 +82,15 @@
UIComponent component,
String clientId)
{
- Map<String, String> parameterMap =
+ Map<String, String> parameterMap =
context.getExternalContext().getRequestParameterMap();
-
+
String source = parameterMap.get("source");
if (clientId.equals(source))
{
String event = parameterMap.get("event");
if (XhtmlConstants.AUTOSUBMIT_EVENT.equals(event) &&
- isAutoSubmit(getFacesBean(component)))
+ isAutoSubmit(component, getFacesBean(component)))
{
(new AutoSubmitEvent(component)).queue();
}
@@ -95,23 +99,24 @@
@Override
protected final void encodeAll(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
- if (!renderAsElement(context, arc, bean))
+ if (!renderAsElement(context, rc, component, bean))
{
- encodeAllAsNonElement(context, arc, component, bean);
+ encodeAllAsNonElement(context, rc, component, bean);
}
else
{
- encodeAllAsElement(context, arc, component, bean);
+ encodeAllAsElement(context, rc, component, bean);
}
}
-
- protected boolean isHiddenLabelRequired(RenderingContext arc)
+ protected boolean isHiddenLabelRequired(
+ RenderingContext rc)
{
return true;
}
@@ -119,23 +124,23 @@
/**
*/
protected void renderShortDescAsHiddenLabel(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean)
- throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
- if (HiddenLabelUtils.supportsHiddenLabels(arc) &&
- isHiddenLabelRequired(arc))
+ if (HiddenLabelUtils.supportsHiddenLabels(rc) &&
+ isHiddenLabelRequired(rc))
{
String clientId = getClientId(context, component);
- if (HiddenLabelUtils.wantsHiddenLabel(arc, clientId))
+ if (HiddenLabelUtils.wantsHiddenLabel(rc, clientId))
{
- String hiddenLabel = getHiddenLabel(bean);
+ String hiddenLabel = getHiddenLabel(component, bean);
if (hiddenLabel != null)
{
HiddenLabelUtils.outputHiddenLabel(context,
- arc,
+ rc,
clientId,
hiddenLabel,
component);
@@ -143,13 +148,13 @@
}
}
}
-
protected void encodeAllAsElement(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
}
@@ -157,71 +162,76 @@
* @todo Make abstract if always overriden
*/
protected void encodeAllAsNonElement(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
ResponseWriter rw = context.getResponseWriter();
rw.startElement("span", component);
renderId(context, component);
- rw.writeAttribute("title", getShortDesc(bean), "shortDesc");
- renderStyleAttributes(context, arc, bean);
+ rw.writeAttribute("title", getShortDesc(component, bean), "shortDesc");
+ renderStyleAttributes(context, rc, component, bean);
- renderNonElementContent(context, arc, component, bean);
+ renderNonElementContent(context, rc, component, bean);
rw.endElement("span");
}
-
/**
* @todo Remove if never necessary
*/
protected void renderNonElementContent(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
}
@Override
protected void renderEventHandlers(
FacesContext context,
- FacesBean bean) throws IOException
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
- super.renderEventHandlers(context, bean);
- renderFormEventHandlers(context, bean);
+ super.renderEventHandlers(context, component, bean);
+ renderFormEventHandlers(context, component, bean);
}
protected void renderFormEventHandlers(
FacesContext context,
- FacesBean bean) throws IOException
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
ResponseWriter rw = context.getResponseWriter();
- rw.writeAttribute("onblur", getOnblur(bean), "onblur");
- rw.writeAttribute("onfocus", getOnfocus(bean), "onfocus");
- rw.writeAttribute("onchange", getOnchange(bean), "onchange");
+ rw.writeAttribute("onblur", getOnblur(component, bean), "onblur");
+ rw.writeAttribute("onfocus", getOnfocus(component, bean), "onfocus");
+ rw.writeAttribute("onchange", getOnchange(component, bean), "onchange");
}
-
/**
* Should this component render as a form element, or just
* as some non-form content?
*/
protected final boolean renderAsElement(
- FacesContext context,
- RenderingContext arc,
- FacesBean bean)
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean)
{
- if (getReadOnly(context, bean) || !supportsEditing(arc))
+ if (getReadOnly(context, component, bean) || !supportsEditing(rc))
{
- if (!renderReadOnlyAsElement(arc, bean))
+ if (!renderReadOnlyAsElement(rc, component, bean))
return false;
}
- if (!supportsDisabledFormElements(arc) &&
- getDisabled(bean))
+ if (!supportsDisabledFormElements(rc) &&
+ getDisabled(component, bean))
{
return false;
}
@@ -230,13 +240,16 @@
}
protected boolean renderReadOnlyAsElement(
- RenderingContext arc,
- FacesBean bean)
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean)
{
return false;
}
- protected String getLabel(FacesBean bean)
+ protected String getLabel(
+ UIComponent component,
+ FacesBean bean)
{
// Not all FormElements necessarily have a label
if (_labelKey == null)
@@ -245,16 +258,20 @@
return toString(bean.getProperty(_labelKey));
}
- protected String getContentStyle(FacesBean bean)
+ protected String getContentStyle(
+ UIComponent component,
+ FacesBean bean)
{
if (_contentStyleKey == null)
return null;
-
+
return toString(bean.getProperty(_contentStyleKey));
}
-
- protected String getOnblur(FacesBean bean)
+
+ protected String getOnblur(
+ UIComponent component,
+ FacesBean bean)
{
if (_onblurKey == null)
return null;
@@ -262,7 +279,9 @@
return toString(bean.getProperty(_onblurKey));
}
- protected String getOnfocus(FacesBean bean)
+ protected String getOnfocus(
+ UIComponent component,
+ FacesBean bean)
{
if (_onfocusKey == null)
return null;
@@ -270,7 +289,9 @@
return toString(bean.getProperty(_onfocusKey));
}
- protected String getOnchange(FacesBean bean)
+ protected String getOnchange(
+ UIComponent component,
+ FacesBean bean)
{
if (_onchangeKey == null)
return null;
@@ -279,13 +300,17 @@
}
@Override
- protected String getDefaultStyleClass(FacesBean bean)
+ protected String getDefaultStyleClass(
+ UIComponent component,
+ FacesBean bean)
{
return SkinSelectors.AF_FIELD_TEXT_STYLE_CLASS;
}
/* FIXME: this method is never called
- protected String getDefaultDisabledStyleClass(FacesBean bean)
+ protected String getDefaultDisabledStyleClass(
+ UIComponent component,
+ FacesBean bean)
{
return SkinSelectors.AF_FIELD_TEXT_DISABLED_STYLE_CLASS;
}*/
@@ -295,7 +320,9 @@
*
* @param bean the bean
*/
- protected boolean isAutoSubmit(FacesBean bean)
+ protected boolean isAutoSubmit(
+ UIComponent component,
+ FacesBean bean)
{
if (_autoSubmitKey == null)
return false;
@@ -307,11 +334,13 @@
* Return the text for a hidden label, using "shortDesc" if set,
* "label" otherwise.
*/
- protected String getHiddenLabel(FacesBean bean)
+ protected String getHiddenLabel(
+ UIComponent component,
+ FacesBean bean)
{
- String hiddenLabel = getShortDesc(bean);
+ String hiddenLabel = getShortDesc(component, bean);
if (hiddenLabel == null)
- hiddenLabel = getLabel(bean);
+ hiddenLabel = getLabel(component, bean);
return hiddenLabel;
}
@@ -323,19 +352,22 @@
*/
static private final class AutoSubmitEvent extends FacesEvent
{
- public AutoSubmitEvent(UIComponent source)
+ public AutoSubmitEvent(
+ UIComponent source)
{
super(source);
setPhaseId(PhaseId.INVOKE_APPLICATION);
}
@Override
- public void processListener(FacesListener listener)
+ public void processListener(
+ FacesListener listener)
{
}
@Override
- public boolean isAppropriateListener(FacesListener listener)
+ public boolean isAppropriateListener(
+ FacesListener listener)
{
return false;
}
Modified: myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormInputRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormInputRenderer.java?rev=889345&r1=889344&r2=889345&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormInputRenderer.java (original)
+++ myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormInputRenderer.java Thu Dec 10 17:46:13 2009
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -25,35 +25,36 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-
import org.apache.myfaces.trinidad.bean.FacesBean;
-
import org.apache.myfaces.trinidad.bean.PropertyKey;
-
import org.apache.myfaces.trinidad.context.RenderingContext;
+
abstract public class FormInputRenderer extends FormElementRenderer
{
- protected FormInputRenderer(FacesBean.Type type)
+ protected FormInputRenderer(
+ FacesBean.Type type)
{
super(type);
}
-
+
@Override
- protected void findTypeConstants(FacesBean.Type type)
+ protected void findTypeConstants(
+ FacesBean.Type type)
{
super.findTypeConstants(type);
_showRequiredKey = type.findKey("showRequired");
_simpleKey = type.findKey("simple");
}
-
+
/**
* Render the client ID as both an "id" and a "name"
*/
@Override
protected void renderId(
FacesContext context,
- UIComponent component) throws IOException
+ UIComponent component
+ ) throws IOException
{
String clientId = getClientId(context, component);
context.getResponseWriter().writeAttribute("id", clientId, "id");
@@ -72,28 +73,29 @@
UIComponent component)
{
FacesBean bean = getFacesBean(component);
- return !getReadOnly(context, bean);
+ return !getReadOnly(context, component, bean);
}
-
protected void renderDisabledAttribute(
- FacesContext context,
- RenderingContext arc,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
-
- if (getDisabled(bean))
+
+ if (getDisabled(component, bean))
{
context.getResponseWriter().writeAttribute("disabled",
Boolean.TRUE,
"disabled");
}
}
-
+
/**
* used in the form input components for the 'content' piece.
* @param context
- * @param arc
+ * @param rc
* @param bean
* @param renderStyleAttrs, whether to render the styleClass/inlineStyle
* attribute values on the 'content' piece. This is usually false.
@@ -102,17 +104,21 @@
@Override
protected void renderAllAttributes(
FacesContext context,
- RenderingContext arc,
+ RenderingContext rc,
+ UIComponent component,
FacesBean bean,
- boolean renderStyleAttrs) throws IOException
+ boolean renderStyleAttrs
+ ) throws IOException
{
- super.renderAllAttributes(context, arc, bean, renderStyleAttrs);
- renderDisabledAttribute(context, arc, bean);
- renderStyleClass(context, arc, getContentStyleClass(bean));
- renderInlineStyleAttribute(context, arc, getContentStyle(bean));
+ super.renderAllAttributes(context, rc, component, bean, renderStyleAttrs);
+ renderDisabledAttribute(context, rc, component, bean);
+ renderStyleClass(context, rc, getContentStyleClass(component, bean));
+ renderInlineStyleAttribute(context, rc, component, getContentStyle(component, bean));
}
-
- protected boolean getSimple(FacesBean bean)
+
+ protected boolean getSimple(
+ UIComponent component,
+ FacesBean bean)
{
Object o = bean.getProperty(_simpleKey);
if (o == null)
@@ -120,7 +126,7 @@
return !Boolean.FALSE.equals(o);
}
-
+
/**
* Render the styles and style classes that should go on the root dom element.
* (called from LabelAndMessageRenderer, the superclass)
@@ -129,36 +135,36 @@
* @param component
* @param bean
* @throws IOException
- */
+ */
protected void renderRootDomElementStyles(
FacesContext context,
RenderingContext arc,
UIComponent component,
FacesBean bean) throws IOException
{
- // get the style classes that I want to render on the root dom element here.
- String styleClass = getStyleClass(bean);
- String contentStyleClass = getRootStyleClass(bean);
+ // get the style classes that I want to render on the root dom element here.
+ String styleClass = getStyleClass(component, bean);
+ String contentStyleClass = getRootStyleClass(component, bean);
String disabledStyleClass = null;
String readOnlyStyleClass = null;
String requiredStyleClass = null;
-
- // readOnly takes precedence over disabled for the state.
+
+ // readOnly takes precedence over disabled for the state.
// -= Simon =- Why?
- if(getReadOnly(context, bean))
+ if (getReadOnly(context, component, bean))
{
readOnlyStyleClass = SkinSelectors.STATE_READ_ONLY;
}
- else if (getDisabled(bean))
+ else if (getDisabled(component, bean))
{
disabledStyleClass = SkinSelectors.STATE_DISABLED;
}
-
- if(_isConsideredRequired(bean))
+
+ if(_isConsideredRequired(component, bean))
{
requiredStyleClass = SkinSelectors.STATE_REQUIRED;
}
-
+
List<String> parsedStyleClasses =
OutputUtils.parseStyleClassList(styleClass);
int userStyleClassCount;
@@ -188,38 +194,43 @@
styleClasses[i++] = requiredStyleClass;
renderStyleClasses(context, arc, styleClasses);
- renderInlineStyle(context, arc, bean);
+ renderInlineStyle(context, arc, component, bean);
}
-
+
/*
* override to return the content style class, like af|inputText::content
* if component is tr:inputText.
*/
- protected String getContentStyleClass(FacesBean bean)
+ protected String getContentStyleClass(
+ UIComponent component,
+ FacesBean bean)
{
- String styleClass = getRootStyleClass(bean);
+ String styleClass = getRootStyleClass(component, bean);
if(styleClass != null)
{
styleClass = styleClass + _CONTENT_PSEUDO_ELEMENT;
}
-
+
return styleClass;
}
-
-
+
/*
* override to return the root style class, like af|inputText
* if component is tr:inputText.
- */
- abstract protected String getRootStyleClass(FacesBean bean);
-
- protected boolean getShowRequired(FacesBean bean)
+ */
+ abstract protected String getRootStyleClass(
+ UIComponent component,
+ FacesBean bean);
+
+ protected boolean getShowRequired(
+ UIComponent component,
+ FacesBean bean)
{
if(_showRequiredKey == null)
{ // showRequired is not supporte on the element
return false;
}
-
+
Object o = bean.getProperty(_showRequiredKey);
if (o == null)
{
@@ -228,12 +239,14 @@
return Boolean.TRUE.equals(o);
}
-
- private boolean _isConsideredRequired(FacesBean bean)
+
+ private boolean _isConsideredRequired(
+ UIComponent component,
+ FacesBean bean)
{
- return getRequired(bean) || getShowRequired(bean);
+ return getRequired(component, bean) || getShowRequired(component, bean);
}
-
+
private static final String _CONTENT_PSEUDO_ELEMENT = "::content";
private PropertyKey _showRequiredKey;