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 [12/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/o...
Modified: myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SelectRangeChoiceBarRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SelectRangeChoiceBarRenderer.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/SelectRangeChoiceBarRenderer.java (original)
+++ myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SelectRangeChoiceBarRenderer.java Thu Dec 10 17:46:13 2009
@@ -19,6 +19,7 @@
package org.apache.myfaces.trinidadinternal.renderkit.core.xhtml;
import java.io.IOException;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -46,6 +47,7 @@
import org.apache.myfaces.trinidad.util.IntegerUtils;
import org.apache.myfaces.trinidadinternal.util.Range;
+
public class SelectRangeChoiceBarRenderer extends XhtmlRenderer
{
public SelectRangeChoiceBarRenderer()
@@ -53,13 +55,15 @@
this(CoreSelectRangeChoiceBar.TYPE);
}
- public SelectRangeChoiceBarRenderer(FacesBean.Type type)
+ public SelectRangeChoiceBarRenderer(
+ FacesBean.Type type)
{
super(type);
}
@Override
- protected void findTypeConstants(FacesBean.Type type)
+ protected void findTypeConstants(
+ FacesBean.Type type)
{
super.findTypeConstants(type);
_rowsKey = type.findKey("rows");
@@ -71,7 +75,9 @@
@SuppressWarnings("unchecked")
@Override
- public void decode(FacesContext context, UIComponent component)
+ public void decode(
+ FacesContext context,
+ UIComponent component)
{
Map<String, String> parameters =
context.getExternalContext().getRequestParameterMap();
@@ -108,7 +114,7 @@
int rows = choiceBar.getRows();
FacesBean bean = getFacesBean(choiceBar);
- boolean isShowAll = getShowAll(bean);
+ boolean isShowAll = getShowAll(choiceBar, bean);
// calculate oldStart and oldEnd
int increment = (isShowAll && rowCount > -1) ? rowCount : rows;
@@ -175,7 +181,9 @@
return true;
}
- protected int getRows(UIComponent component, FacesBean bean)
+ protected int getRows(
+ UIComponent component,
+ FacesBean bean)
{
Object o = bean.getProperty(_rowsKey);
if (o == null)
@@ -184,9 +192,9 @@
return toInt(o);
}
-
-
- protected int getFirst(UIComponent component, FacesBean bean)
+ protected int getFirst(
+ UIComponent component,
+ FacesBean bean)
{
Object o = bean.getProperty(_firstKey);
if (o == null)
@@ -195,8 +203,9 @@
return toInt(o);
}
-
- protected boolean getShowAll(FacesBean bean)
+ protected boolean getShowAll(
+ UIComponent component,
+ FacesBean bean)
{
Object o = bean.getProperty(_showAllKey);
if (o == null)
@@ -205,8 +214,9 @@
return Boolean.TRUE.equals(o);
}
-
- protected boolean getImmediate(FacesBean bean)
+ protected boolean getImmediate(
+ UIComponent component,
+ FacesBean bean)
{
Object o = bean.getProperty(_immediateKey);
if (o == null)
@@ -215,12 +225,15 @@
return Boolean.TRUE.equals(o);
}
- protected String getVar(FacesBean bean)
+ protected String getVar(
+ UIComponent component,
+ FacesBean bean)
{
return toString(bean.getProperty(_varKey));
}
- protected UIComponent getRangeLabel(UIComponent component)
+ protected UIComponent getRangeLabel(
+ UIComponent component)
{
return getFacet(component, CoreSelectRangeChoiceBar.RANGE_LABEL_FACET);
}
@@ -229,32 +242,40 @@
// HOOKS FOR SUBCLASSES
// These methods exist entirely for subclasses to override behavior.
//
- protected int getRowCount(UIComponent component)
+ protected int getRowCount(
+ UIComponent component)
{
return ((UIXSelectRange) component).getRowCount();
}
- protected int getRowIndex(UIComponent component)
+ protected int getRowIndex(
+ UIComponent component)
{
return ((UIXSelectRange) component).getRowIndex();
}
- protected void setRowIndex(UIComponent component, int index)
+ protected void setRowIndex(
+ UIComponent component,
+ int index)
{
((UIXSelectRange) component).setRowIndex(index);
}
- protected boolean isRowAvailable(UIComponent component)
+ protected boolean isRowAvailable(
+ UIComponent component)
{
return ((UIXSelectRange) component).isRowAvailable();
}
- protected boolean isRowAvailable(UIComponent component, int rowIndex)
+ protected boolean isRowAvailable(
+ UIComponent component,
+ int rowIndex)
{
return ((UIXSelectRange) component).isRowAvailable(rowIndex);
}
- protected Object getRowData(UIComponent component)
+ protected Object getRowData(
+ UIComponent component)
{
return ((UIXSelectRange) component).getRowData();
}
@@ -277,10 +298,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
{
int rowIndex = getRowIndex(component);
try
@@ -311,10 +333,10 @@
if (source == null)
source = id;
- if (arc.getFormData() == null)
+ if (rc.getFormData() == null)
return;
- String formName = arc.getFormData().getName();
+ String formName = rc.getFormData().getName();
if (formName == null)
return;
@@ -363,7 +385,7 @@
}
- boolean validate = !getImmediate(bean);
+ boolean validate = !getImmediate(component, bean);
boolean showDisabledNavigation = disabledNavigationShown();
boolean hasBackRecords = (prevRecords > 0);
@@ -377,13 +399,13 @@
boolean showBackButton = hasBackRecords || showDisabledNavigation;
boolean showNextButton = hasNextRecords || showDisabledNavigation;
- if (!supportsNavigation(arc))
+ if (!supportsNavigation(rc))
{
showBackButton = false;
showNextButton = false;
}
- boolean showAllActive = getShowAll(bean);
+ boolean showAllActive = getShowAll(component, bean);
if (showAllActive)
{
@@ -397,14 +419,14 @@
if (hasBackRecords || hasNextRecords)
{
- addHiddenFields(arc);
+ addHiddenFields(rc);
// Render script submission code.
- ProcessUtils.renderNavSubmitScript(context, arc);
- ProcessUtils.renderNavChoiceSubmitScript(context, arc);
+ ProcessUtils.renderNavSubmitScript(context, rc);
+ ProcessUtils.renderNavChoiceSubmitScript(context, rc);
}
// use form submit
- if (supportsScripting(arc))
+ if (supportsScripting(rc))
{
if (hasBackRecords && !showAllActive)
{
@@ -448,7 +470,7 @@
// our layout problems.
String iconID = null;
if (PartialPageUtils.isPPRActive(context) &&
- isIE(arc))
+ isIE(rc))
{
iconID = id + "-i";
}
@@ -464,7 +486,7 @@
// if we need to render standalone, create a table and table row...
if (renderAsTable)
{
- isDesktop = (arc.getAgent().getType().equals(Agent.TYPE_DESKTOP));
+ isDesktop = (rc.getAgent().getType().equals(Agent.TYPE_DESKTOP));
// Few mobile browsers doesn't support PPR for Table element
// so lets wrap it up with a div tag
if(!isDesktop )
@@ -473,11 +495,11 @@
writer.writeAttribute("id", id, "id");
}
writer.startElement("table", component);
- OutputUtils.renderLayoutTableAttributes(context, arc, "0", null);
+ OutputUtils.renderLayoutTableAttributes(context, rc, "0", null);
// =-=AEW Where do these attrs get written out when
// we're inside a PanelPageButton?
- renderAllAttributes(context, arc, bean);
+ renderAllAttributes(context, rc, component, bean);
// We should always render the ID, but we particularly need
// to make sure that the ID is rendered if the NavBar is being
@@ -491,14 +513,14 @@
writer.startElement("tr", null);
}
-
- boolean narrowScreen = supportsNarrowScreen(arc);
-
+
+ boolean narrowScreen = supportsNarrowScreen(rc);
+
// skip rendering back button for narrow-screen PDAs to reduce the
// overall width of selectRangeChoiceBar.
if (showBackButton && !narrowScreen)
{
- Icon prevIcon = getIcon(arc, false, (prevOnClick != null));
+ Icon prevIcon = getIcon(rc, false, (prevOnClick != null));
if (!prevIcon.isNull())
{
@@ -513,7 +535,7 @@
// is included in a partial page response, add the icon
// id to the list of partial targets.
// =-=AEW Not sure this is still necessary
- PartialPageContext pprContext = arc.getPartialPageContext();
+ PartialPageContext pprContext = rc.getPartialPageContext();
if ((pprContext != null) &&
pprContext.isInsidePartialTarget())
{
@@ -529,28 +551,28 @@
writer.writeAttribute("valign", "middle", null);
- _renderArrow(context, arc, prevIcon, false, prevOnClick);
+ _renderArrow(context, rc, prevIcon, false, prevOnClick);
writer.endElement("td");
- _renderSpacerCell(context, arc);
+ _renderSpacerCell(context, rc);
}
_renderStartTableCell(writer, id, renderedId);
renderedId = true;
writer.writeAttribute("valign", "middle", null);
writer.writeAttribute("nowrap", Boolean.TRUE, null);
-
+
_renderLink(context,
- arc,
- false,
+ rc,
+ false,
prevOnClick,
- prevRecords,
- id,
- source,
+ prevRecords,
+ id,
+ source,
backValue);
-
+
writer.endElement("td");
- _renderSpacerCell(context, arc);
+ _renderSpacerCell(context, rc);
}
_renderStartTableCell(writer, id, renderedId);
@@ -559,7 +581,7 @@
writer.writeAttribute("nowrap", Boolean.TRUE, null);
_renderChoice(context,
- arc,
+ rc,
component,
id,
source,
@@ -571,36 +593,36 @@
validate);
writer.endElement("td");
-
+
// skip rendering back button for narrow-screen PDAs to reduce the
// overall width of selectRangeChoiceBar.
if (showNextButton && !narrowScreen)
{
- _renderSpacerCell(context, arc);
+ _renderSpacerCell(context, rc);
_renderStartTableCell(writer, id, true);
writer.writeAttribute("valign", "middle", null);
writer.writeAttribute("nowrap", Boolean.TRUE, null);
-
+
_renderLink(context,
- arc,
- true,
+ rc,
+ true,
nextOnClick,
- nextRecords,
+ nextRecords,
id,
source,
nextValue);
-
+
writer.endElement("td");
- Icon nextIcon = getIcon(arc, true, (nextOnClick != null));
+ Icon nextIcon = getIcon(rc, true, (nextOnClick != null));
if (!nextIcon.isNull())
{
- _renderSpacerCell(context, arc);
+ _renderSpacerCell(context, rc);
_renderStartTableCell(writer, id, true);
writer.writeAttribute("valign", "middle", null);
- _renderArrow(context, arc, nextIcon, true, nextOnClick);
+ _renderArrow(context, rc, nextIcon, true, nextOnClick);
writer.endElement("td");
}
}
@@ -624,13 +646,13 @@
}
}
-
/**
* render form value needed values and javascript code.
*/
- public static void addHiddenFields(RenderingContext arc)
+ public static void addHiddenFields(
+ RenderingContext rc)
{
- FormData fData = arc.getFormData();
+ FormData fData = rc.getFormData();
fData.addNeededValue(XhtmlConstants.EVENT_PARAM);
fData.addNeededValue(XhtmlConstants.SOURCE_PARAM);
fData.addNeededValue(XhtmlConstants.PARTIAL_PARAM);
@@ -638,17 +660,18 @@
}
private void _renderChoice(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- String id,
- String source,
- String form,
- long minValue,
- long currentValue,
- int blockSize,
- long maxValue,
- boolean validate) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ String id,
+ String source,
+ String form,
+ long minValue,
+ long currentValue,
+ int blockSize,
+ long maxValue,
+ boolean validate
+ ) throws IOException
{
UIComponent rangeLabel = getRangeLabel(component);
boolean firstRowAvailable = isRowAvailable(component, 0);
@@ -667,24 +690,24 @@
List<SelectItem> items =
new ArrayList<SelectItem>((int) _MAX_VISIBLE_OPTIONS);
- int selectedIndex = _getItems(context, arc, component, items,
+ int selectedIndex = _getItems(context, rc, component, items,
minValue, maxValue, currentValue,
blockSize, rangeLabel);
int count = items.size();
if (count > 1)
{
- String choiceTip = arc.getTranslatedString(_CHOICE_TIP_KEY);
+ String choiceTip = rc.getTranslatedString(_CHOICE_TIP_KEY);
String choiceId = XhtmlUtils.getCompositeId(id, _CHOICE_ID_SUFFIX);
String onChange = ProcessUtils.getChoiceOnChangeFormSubmitted(
form, source, validate);
- boolean javaScriptSupport = supportsScripting(arc);
+ boolean javaScriptSupport = supportsScripting(rc);
writer.startElement("select", null);
writer.writeAttribute("title", choiceTip, null);
- renderStyleClass(context, arc,
+ renderStyleClass(context, rc,
SkinSelectors.AF_FIELD_TEXT_STYLE_CLASS);
-
+
if (onChange != null && javaScriptSupport)
{
// set the onchange handler
@@ -694,11 +717,11 @@
}
writer.writeAttribute("id", choiceId, null);
-
+
// For Non-JavaScript browsers, render the name attribute thus it
- // would enable the browsers to include the name and value of this
+ // would enable the browsers to include the name and value of this
// element in its payLoad.
-
+
if (!javaScriptSupport)
{
writer.writeAttribute("name", choiceId, null);
@@ -708,21 +731,21 @@
writer.endElement("select");
- if (HiddenLabelUtils.supportsHiddenLabels(arc))
+ if (HiddenLabelUtils.supportsHiddenLabels(rc))
{
HiddenLabelUtils.outputHiddenLabelIfNeeded(context,
- arc,
+ rc,
choiceId,
choiceTip,
null);
}
-
-
- // For Non-JavaScript browsers, render a input element(type= submit) to
- // submit the page. Encode the name attribute with the parameter name
- // and value thus it would enable the browsers to include the name of
+
+
+ // For Non-JavaScript browsers, render a input element(type= submit) to
+ // submit the page. 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 (!javaScriptSupport)
{
String nameAttri = XhtmlUtils.getEncodedParameter
@@ -734,9 +757,9 @@
+ XhtmlUtils.getEncodedParameter
(XhtmlConstants.EVENT_PARAM)
+ XhtmlConstants.GOTO_EVENT;
-
+
renderSubmitButtonNonJSBrowser(context,
- arc,
+ rc,
XhtmlConstants.
NO_JS_PARAMETER_KEY_BUTTON,
nameAttri);
@@ -745,8 +768,8 @@
else
{
writer.startElement("script", null);
- renderScriptDeferAttribute(context, arc);
- renderScriptTypeAttribute(context, arc);
+ renderScriptDeferAttribute(context, rc);
+ renderScriptTypeAttribute(context, rc);
writer.writeText("_setSelectIndexById(\"", null);
writer.writeText(choiceId, null);
writer.writeText("\",", null);
@@ -758,7 +781,7 @@
else if (count == 1)
{
writer.startElement("span", null);
- renderStyleClass(context, arc,
+ renderStyleClass(context, rc,
SkinSelectors.AF_FIELD_TEXT_STYLE_CLASS);
writer.writeText(items.get(0).getLabel(), null);
writer.endElement("span");
@@ -769,7 +792,8 @@
private void _writeSelectItems(
FacesContext context,
List<SelectItem> items,
- int selectedIndex) throws IOException
+ int selectedIndex
+ ) throws IOException
{
ResponseWriter writer = context.getResponseWriter();
int count = items.size();
@@ -790,13 +814,15 @@
* @return the number of options added
*/
private int _getItems(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- List<SelectItem> items,
- long minValue, long maxValue, long value,
- int blockSize,
- UIComponent rangeLabel)
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ List<SelectItem> items,
+ long minValue,
+ long maxValue,
+ long value,
+ int blockSize,
+ UIComponent rangeLabel)
{
int selectedIndex = -1;
@@ -844,7 +870,7 @@
if (lastBlockIndex > maxBlockIndex)
lastBlockIndex = maxBlockIndex;
- boolean showAllActive = getShowAll(getFacesBean(component));
+ boolean showAllActive = getShowAll(component, getFacesBean(component));
// Add "Show All" option if showAll was set to true OR
// when there are less than 30 groups (maxBlockIndex
@@ -858,7 +884,7 @@
// Omit show all if it's not supported
if (showAllSupported())
{
- items.add(_createShowAllSelectItem(arc,
+ items.add(_createShowAllSelectItem(rc,
maxValue));
if (showAllActive)
selectedIndex = 0;
@@ -904,7 +930,7 @@
if ((blockIndex == firstBlockIndex) &&
(blockIndex != 0))
{
- text = arc.getTranslatedString(_PREVIOUS_TEXT_KEY);
+ text = rc.getTranslatedString(_PREVIOUS_TEXT_KEY);
}
// Need "More..." (on the last block, either 'cause
@@ -915,7 +941,7 @@
else if ((blockIndex == lastBlockIndex) &&
(maxUnknown || (lastBlockIndex < maxBlockIndex)))
{
- text = arc.getTranslatedString(_MORE_TEXT_KEY);
+ text = rc.getTranslatedString(_MORE_TEXT_KEY);
}
else
{
@@ -926,7 +952,7 @@
long currValue = showAllActive ? minValue - 1 : value;// Don't select
SelectItem item = _createNavigationItem(context,
- arc,
+ rc,
component,
blockStart,
currentRecordSize,
@@ -960,9 +986,9 @@
// create a choice option when max value is known
private SelectItem _createNavigationItem(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
long blockStart,
int blockSize,
long maxValue,
@@ -973,7 +999,7 @@
// if text isn't null, it is More or Previous.
if (text == null)
text = _getRangeString(context,
- arc,
+ rc,
component,
blockStart,
blockSize,
@@ -984,7 +1010,6 @@
text);
}
-
/**
* Returns true if disabled navigation items should be shown
*/
@@ -993,24 +1018,23 @@
return true;
}
-
-
// create one of the text links for navigation
private void _renderLink(
- FacesContext context,
- RenderingContext arc,
- boolean isNext,
- String onclick,
- int records,
- String id,
- String source,
- long value ) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ boolean isNext,
+ String onclick,
+ int records,
+ String id,
+ String source,
+ long value
+ ) throws IOException
{
- String text = getBlockString(arc, isNext, records);
+ String text = getBlockString(rc, isNext, records);
boolean isEnabled = ((onclick != null) && (records > 0));
ResponseWriter writer = context.getResponseWriter();
-
+
// if we have more than one record and browser is js capable then
// render as a link
if (isEnabled)
@@ -1025,11 +1049,11 @@
// initial focus, the Next button does not have an id on it)
if (isNext)
{
- String linkID = _getIDForFocus(arc, id);
+ String linkID = _getIDForFocus(rc, id);
writer.writeAttribute("id", linkID, null);
}
- renderStyleClass(context, arc, SkinSelectors.NAV_BAR_ALINK_STYLE_CLASS);
+ renderStyleClass(context, rc, SkinSelectors.NAV_BAR_ALINK_STYLE_CLASS);
writer.writeText(text, null);
writer.endElement("a");
}
@@ -1037,16 +1061,16 @@
else if (records < 1)
{
writer.startElement("span", null);
- renderStyleClass(context, arc, SkinSelectors.NAV_BAR_ILINK_STYLE_CLASS);
+ renderStyleClass(context, rc, SkinSelectors.NAV_BAR_ILINK_STYLE_CLASS);
writer.writeText(text, null);
writer.endElement("span");
}
-
+
// For Non-JavaScript browsers, render a submit element
- // (<input type = "submit"/> ). Encode the the name attribute with the
- // parameter name and value thus it would enable the browsers to
+ // (<input type = "submit"/> ). Encode the 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
-
+
else
{
String nameAttri = XhtmlUtils.getEncodedParameter
@@ -1064,9 +1088,9 @@
writer.writeAttribute("type", "submit", null);
writer.writeAttribute("name", nameAttri, null);
writer.writeAttribute("value", text, "text");
- renderStyleClass(context, arc,
+ renderStyleClass(context, rc,
SkinSelectors.AF_COMMAND_BUTTON_STYLE_CLASS);
-
+
// This style makes a button to appear as a link
writer.writeAttribute("style",
"border:none;background:inherit;text-decoration:underline;",null);
@@ -1079,9 +1103,9 @@
/**
*/
protected Icon getIcon(
- RenderingContext arc,
- boolean isNext,
- boolean isEnabled
+ RenderingContext rc,
+ boolean isNext,
+ boolean isEnabled
)
{
// get the image location
@@ -1110,12 +1134,12 @@
}
}
- return arc.getIcon(iconName);
+ return rc.getIcon(iconName);
}
protected String getIconTitleKey(
- boolean isNext,
- boolean isEnabled
+ boolean isNext,
+ boolean isEnabled
)
{
if (isNext)
@@ -1134,11 +1158,12 @@
* renderkit tests.
*/
private void _renderArrow(
- FacesContext context,
- RenderingContext arc,
- Icon icon,
- boolean isNext,
- String onclick) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ Icon icon,
+ boolean isNext,
+ String onclick
+ ) throws IOException
{
ResponseWriter writer = context.getResponseWriter();
if (onclick != null)
@@ -1150,8 +1175,8 @@
boolean isEnabled = (onclick != null);
String titleKey = getIconTitleKey(isNext, isEnabled);
- String title = arc.getTranslatedString(titleKey);
- OutputUtils.renderIcon(context, arc, icon, title, null);
+ String title = rc.getTranslatedString(titleKey);
+ OutputUtils.renderIcon(context, rc, icon, title, null);
if (onclick != null)
writer.endElement("a");
@@ -1163,17 +1188,17 @@
* in a table navigation bar.
*/
protected String getBlockString(
- RenderingContext arc,
- boolean isNext,
- int numRecords
+ RenderingContext rc,
+ boolean isNext,
+ int numRecords
)
{
// check to make sure that we have some records in this direction:
if (numRecords > 0)
{
String pattern = (isNext)
- ? arc.getTranslatedString("af_selectRangeChoiceBar.NEXT")
- : arc.getTranslatedString("af_selectRangeChoiceBar.PREVIOUS");
+ ? rc.getTranslatedString("af_selectRangeChoiceBar.NEXT")
+ : rc.getTranslatedString("af_selectRangeChoiceBar.PREVIOUS");
String value = IntegerUtils.getString(numRecords);
return XhtmlUtils.getFormattedString(pattern, new String[]{value});
@@ -1183,8 +1208,8 @@
// since we don't have any records, we are going to display some
// disabled text. see bug 1740486.
String text = (isNext)
- ? arc.getTranslatedString("af_selectRangeChoiceBar.DISABLED_NEXT")
- : arc.getTranslatedString("af_selectRangeChoiceBar.DISABLED_PREVIOUS");
+ ? rc.getTranslatedString("af_selectRangeChoiceBar.DISABLED_NEXT")
+ : rc.getTranslatedString("af_selectRangeChoiceBar.DISABLED_PREVIOUS");
return text;
}
}
@@ -1200,8 +1225,8 @@
*/
@SuppressWarnings("unchecked")
private String _getRangeString(
- FacesContext context,
- RenderingContext arc,
+ FacesContext context,
+ RenderingContext rc,
UIComponent component,
long start,
int visibleItemCount,
@@ -1242,7 +1267,7 @@
range.setEnd(getRowData(component));
Object old = null;
- String var = getVar(getFacesBean(component));
+ String var = getVar(component, getFacesBean(component));
if (var != null)
{
Map<String, Object> requestMap =
@@ -1282,7 +1307,7 @@
if ((total == XhtmlConstants.MAX_VALUE_UNKNOWN))
{
- pattern = arc.getTranslatedString(_MULTI_RANGE_NO_TOTAL_FORMAT_STRING);
+ pattern = rc.getTranslatedString(_MULTI_RANGE_NO_TOTAL_FORMAT_STRING);
parameters = new String[]
{
startParam,
@@ -1293,7 +1318,7 @@
else
{
- pattern = arc.getTranslatedString(_MULTI_RANGE_TOTAL_FORMAT_STRING);
+ pattern = rc.getTranslatedString(_MULTI_RANGE_TOTAL_FORMAT_STRING);
parameters = new String[]
{
startParam,
@@ -1317,9 +1342,9 @@
* @return the index of the highest end row that exists.
*/
private int _setToExistingEndRow(
- UIComponent component,
- int startRowIndex,
- int endRowIndex )
+ UIComponent component,
+ int startRowIndex,
+ int endRowIndex )
{
boolean rowAvailable = isRowAvailable(component, endRowIndex);
@@ -1356,16 +1381,17 @@
* Writes the separator between two elements
*/
protected void renderItemSpacer(
- FacesContext context,
- RenderingContext arc) throws IOException
+ FacesContext context,
+ RenderingContext rc
+ ) throws IOException
{
- if (isPDA(arc))
+ if (isPDA(rc))
{
context.getResponseWriter().writeText(XhtmlConstants.NBSP_STRING, null);
}
else
{
- renderSpacer(context, arc, "5", "1");
+ renderSpacer(context, rc, "5", "1");
}
}
@@ -1374,14 +1400,14 @@
* Writes the separator between two elements
*/
private void _renderSpacerCell(
- FacesContext context,
- RenderingContext arc
+ FacesContext context,
+ RenderingContext rc
) throws IOException
{
ResponseWriter writer = context.getResponseWriter();
writer.startElement("td", null);
- renderItemSpacer(context, arc);
+ renderItemSpacer(context, rc);
writer.endElement("td");
}
@@ -1391,7 +1417,8 @@
private void _renderStartTableCell(
ResponseWriter writer,
String id,
- boolean alreadyRenderedId) throws IOException
+ boolean alreadyRenderedId
+ ) throws IOException
{
writer.startElement("td", null);
if (!alreadyRenderedId)
@@ -1401,8 +1428,8 @@
}
private String _getIDForFocus(
- RenderingContext arc,
- String baseId
+ RenderingContext rc,
+ String baseId
)
{
// The navBar needs its initial focus to be on the Next button,
@@ -1414,7 +1441,7 @@
// for the Next button.
Object initialFocusID =
- arc.getProperties().get(XhtmlConstants.INITIAL_FOCUS_CONTEXT_PROPERTY);
+ rc.getProperties().get(XhtmlConstants.INITIAL_FOCUS_CONTEXT_PROPERTY);
String id = null;
if ((initialFocusID != null) && initialFocusID.equals(baseId))
@@ -1430,7 +1457,7 @@
// renderer can write it out to a script variable.
// A side-effect is that the initialFocusID in subsequent calls will
// never equal the navBar's id.
- arc.getProperties().put(XhtmlConstants.INITIAL_FOCUS_CONTEXT_PROPERTY, id);
+ rc.getProperties().put(XhtmlConstants.INITIAL_FOCUS_CONTEXT_PROPERTY, id);
}
@@ -1441,7 +1468,6 @@
// Private variables
//
-
private PropertyKey _rowsKey;
private PropertyKey _firstKey;
private PropertyKey _showAllKey;
Modified: myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SeparatorRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SeparatorRenderer.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/SeparatorRenderer.java (original)
+++ myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SeparatorRenderer.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
@@ -28,46 +28,52 @@
import org.apache.myfaces.trinidad.component.core.output.CoreSeparator;
import org.apache.myfaces.trinidad.context.RenderingContext;
+
public class SeparatorRenderer extends XhtmlRenderer
{
public SeparatorRenderer()
{
super(CoreSeparator.TYPE);
}
-
+
@Override
protected void encodeBegin(
- FacesContext context,
- RenderingContext arc,
- UIComponent comp,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent comp,
+ FacesBean bean
+ ) throws IOException
{
ResponseWriter rw = context.getResponseWriter();
rw.startElement("hr", comp);
renderId(context, comp);
- renderAllAttributes(context, arc, bean);
+ renderAllAttributes(context, rc, comp, bean);
rw.endElement("hr");
}
@Override
protected void renderAllAttributes(
- FacesContext context,
- RenderingContext arc,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
ResponseWriter rw = context.getResponseWriter();
- renderAllAttributes(context, arc, bean, false);
- renderStyleAttributes(context, arc, bean);
+ renderAllAttributes(context, rc, component, bean, false);
+ renderStyleAttributes(context, rc, component, bean);
// Old PDA renderer rule
- if (isPDA(arc))
+ if (isPDA(rc))
rw.writeAttribute("size", "1", null);
}
@Override
- protected String getDefaultStyleClass(FacesBean bean)
+ protected String getDefaultStyleClass(
+ UIComponent component,
+ FacesBean bean)
{
return SkinSelectors.AF_SEPARATOR_STYLE_CLASS;
}
Modified: myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ShowDetailHeaderRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ShowDetailHeaderRenderer.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/ShowDetailHeaderRenderer.java (original)
+++ myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ShowDetailHeaderRenderer.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,10 +29,10 @@
import org.apache.myfaces.trinidad.bean.FacesBean;
import org.apache.myfaces.trinidad.bean.PropertyKey;
import org.apache.myfaces.trinidad.component.core.layout.CoreShowDetailHeader;
-
import org.apache.myfaces.trinidad.context.RenderingContext;
import org.apache.myfaces.trinidad.render.CoreRenderer;
+
public class ShowDetailHeaderRenderer
extends PanelHeaderRenderer
{
@@ -40,9 +40,10 @@
{
super(CoreShowDetailHeader.TYPE);
}
-
+
@Override
- protected void findTypeConstants(FacesBean.Type type)
+ protected void findTypeConstants(
+ FacesBean.Type type)
{
super.findTypeConstants(type);
_detailRenderer = new DetailRenderer(type);
@@ -50,7 +51,9 @@
}
@Override
- public void decode(FacesContext context, UIComponent component)
+ public void decode(
+ FacesContext context,
+ UIComponent component)
{
// Delegate decoding to the showDetail renderer
_detailRenderer.decode(context, component);
@@ -58,46 +61,55 @@
@Override
protected void encodeAll(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
// map the resource value keys that are used in showDetail and header
// to the keys we need to use in this renderer.
- Map<String, String> originalResourceKeyMap = arc.getSkinResourceKeyMap();
+ Map<String, String> originalResourceKeyMap = rc.getSkinResourceKeyMap();
try
{
- arc.setSkinResourceKeyMap(_RESOURCE_KEY_MAP);
- super.encodeAll(context, arc, component, bean);
+ rc.setSkinResourceKeyMap(_RESOURCE_KEY_MAP);
+ super.encodeAll(context, rc, component, bean);
}
finally
{
//restore original map
- arc.setSkinResourceKeyMap(originalResourceKeyMap);
+ rc.setSkinResourceKeyMap(originalResourceKeyMap);
}
}
@Override
- protected void renderIcon(FacesContext context, RenderingContext arc,
- UIComponent component, FacesBean bean, String messageType)
- throws IOException
+ protected void renderIcon(
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean,
+ String messageType
+ ) throws IOException
{
- delegateRenderer(context, arc, component, bean, _detailRenderer);
+ delegateRenderer(context, rc, component, bean, _detailRenderer);
//render the showDetailHeader icon. It uses skinning key af|panelHeader::icon-style
//we can introduce new skinning key af|showDetailHeader::icon-style, if needed.
- super.renderIcon(context, arc, component, bean, messageType);
+ super.renderIcon(context, rc, component, bean, messageType);
}
@Override
- protected String getMessageType(FacesBean bean)
+ protected String getMessageType(
+ UIComponent component,
+ FacesBean bean)
{
// Not currently supported
return null;
}
- protected boolean getDisclosed(FacesBean bean)
+ protected boolean getDisclosed(
+ UIComponent component,
+ FacesBean bean)
{
Object o = bean.getProperty(_disclosedKey);
if (o == null)
@@ -107,29 +119,35 @@
}
@Override
- protected boolean shouldRenderChildren(FacesBean bean)
+ protected boolean shouldRenderChildren(
+ UIComponent component,
+ FacesBean bean)
{
- return getDisclosed(bean);
+ return getDisclosed(component, bean);
}
-
static private class DetailRenderer extends ShowDetailRenderer
{
- public DetailRenderer(FacesBean.Type type)
+ public DetailRenderer(
+ FacesBean.Type type)
{
super(type);
}
-
+
@Override
- protected void renderId(FacesContext context, UIComponent component)
- throws IOException
+ protected void renderId(
+ FacesContext context,
+ UIComponent component
+ ) throws IOException
{
}
@Override
- protected void renderAllAttributes(FacesContext context,
- RenderingContext arc,
- FacesBean bean)
+ protected void renderAllAttributes(
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean)
throws IOException
{
}
@@ -141,21 +159,24 @@
}
@Override
- protected String getDisclosureText(RenderingContext arc,
- FacesBean bean, boolean disclosed)
+ protected String getDisclosureText(
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean,
+ boolean disclosed)
{
return null;
}
}
-
+
private CoreRenderer _detailRenderer;
private PropertyKey _disclosedKey;
-
+
private static final Map<String, String> _RESOURCE_KEY_MAP;
static
{
_RESOURCE_KEY_MAP = new HashMap<String, String>();
-
+
_RESOURCE_KEY_MAP.put("af_showDetail.DISCLOSED" ,
"af_showDetailHeader.DISCLOSED");
_RESOURCE_KEY_MAP.put("af_showDetail.UNDISCLOSED" ,
Modified: myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ShowDetailItemRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ShowDetailItemRenderer.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/ShowDetailItemRenderer.java (original)
+++ myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ShowDetailItemRenderer.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
@@ -30,10 +30,10 @@
import org.apache.myfaces.trinidad.bean.PropertyKey;
import org.apache.myfaces.trinidad.component.UIXShowOne;
import org.apache.myfaces.trinidad.component.core.layout.CoreShowDetailItem;
-
import org.apache.myfaces.trinidad.context.RenderingContext;
-import org.apache.myfaces.trinidad.event.DisclosureEvent;
import org.apache.myfaces.trinidad.context.RequestContext;
+import org.apache.myfaces.trinidad.event.DisclosureEvent;
+
public class ShowDetailItemRenderer extends XhtmlRenderer
{
@@ -41,14 +41,16 @@
{
this(CoreShowDetailItem.TYPE);
}
-
- protected ShowDetailItemRenderer(FacesBean.Type type)
+
+ protected ShowDetailItemRenderer(
+ FacesBean.Type type)
{
super(type);
}
-
+
@Override
- protected void findTypeConstants(FacesBean.Type type)
+ protected void findTypeConstants(
+ FacesBean.Type type)
{
super.findTypeConstants(type);
_disclosedKey = type.findKey("disclosed");
@@ -56,23 +58,25 @@
@SuppressWarnings("unchecked")
@Override
- public void decode(FacesContext context, UIComponent component)
+ public void decode(
+ FacesContext context,
+ UIComponent component)
{
- Map<String, String> parameters =
+ Map<String, String> parameters =
context.getExternalContext().getRequestParameterMap();
-
+
Object event = parameters.get(XhtmlConstants.EVENT_PARAM);
if (XhtmlConstants.HIDE_EVENT.equals(event) ||
XhtmlConstants.SHOW_EVENT.equals(event))
{
Object source = parameters.get(XhtmlConstants.SOURCE_PARAM);
String id = component.getClientId(context);
-
+
if (id.equals(source))
{
boolean isDisclosed = XhtmlConstants.SHOW_EVENT.equals(event);
(new DisclosureEvent(component, isDisclosed)).queue();
- // Add ourselves as a PPR target - except, if we're in a
+ // Add ourselves as a PPR target - except, if we're in a
// ShowOne, then really the whole parent has to get
// repainted
UIComponent pprComponent;
@@ -92,7 +96,9 @@
return true;
}
- protected boolean getDisclosed(FacesBean bean)
+ protected boolean getDisclosed(
+ UIComponent component,
+ FacesBean bean)
{
Object o = bean.getProperty(_disclosedKey);
if (o == null)
@@ -103,22 +109,23 @@
@Override
protected void encodeAll(
- 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);
- renderAllAttributes(context, arc, bean);
-
- if (getDisclosed(bean))
+ renderAllAttributes(context, rc, component, bean);
+
+ if (getDisclosed(component, bean))
{
encodeAllChildren(context, component);
}
rw.endElement("span");
}
-
+
private PropertyKey _disclosedKey;
}
Modified: myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ShowDetailRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ShowDetailRenderer.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/ShowDetailRenderer.java (original)
+++ myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/ShowDetailRenderer.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
@@ -27,11 +27,12 @@
import org.apache.myfaces.trinidad.bean.FacesBean;
import org.apache.myfaces.trinidad.bean.PropertyKey;
import org.apache.myfaces.trinidad.component.core.layout.CoreShowDetail;
-import org.apache.myfaces.trinidad.logging.TrinidadLogger;
import org.apache.myfaces.trinidad.context.FormData;
import org.apache.myfaces.trinidad.context.RenderingContext;
+import org.apache.myfaces.trinidad.logging.TrinidadLogger;
import org.apache.myfaces.trinidad.skin.Icon;
+
/**
* This needs to be massively cleaned up...
* @todo TEST NON-PPR! I removed the non-PPR case from the
@@ -44,13 +45,15 @@
this(CoreShowDetail.TYPE);
}
- protected ShowDetailRenderer(FacesBean.Type type)
+ protected ShowDetailRenderer(
+ 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");
@@ -62,66 +65,66 @@
*/
@Override
protected void encodeAll(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
- {
-
- boolean javaScriptSupport = supportsScripting(arc);
- boolean disclosed = getDisclosed(bean);
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
+ {
+ boolean javaScriptSupport = supportsScripting(rc);
+ boolean disclosed = getDisclosed(component, bean);
ResponseWriter rw = context.getResponseWriter();
rw.startElement("span", component);
if (!isTableAllDisclosure() && !isTableDetailDisclosure())
renderId(context, component);
- renderPromptStart(context, arc, component, bean);
+ renderPromptStart(context, rc, component, bean);
String sourceValue = getClientId(context, component);
String linkId = getLinkId(sourceValue, disclosed);
-
+
String parameterString;
if (javaScriptSupport)
{
- _renderScripts(context, arc, component);
- parameterString = _generateOnClickString(context,
- arc,
- component,
- bean,
+ _renderScripts(context, rc, component);
+ parameterString = _generateOnClickString(context,
+ rc,
+ component,
+ bean,
disclosed);
}
else
- {
- parameterString = _encodedParam(context,
- arc,
- component,
- bean,
+ {
+ parameterString = _encodedParam(context,
+ rc,
+ component,
+ bean,
disclosed);
}
-
- _renderLinkStart(context, arc, bean, parameterString);
+
+ _renderLinkStart(context, rc, component, bean, parameterString);
if (linkId != null)
rw.writeAttribute("id", linkId, null);
if (!isTableAllDisclosure())
{
- renderStyleClasses(context, arc, getDisclosureIconLinkStyleClasses());
- renderDisclosureIcon(context, arc, disclosed);
- _renderLinkEnd(context, arc);
+ renderStyleClasses(context, rc, getDisclosureIconLinkStyleClasses());
+ renderDisclosureIcon(context, rc, disclosed);
+ _renderLinkEnd(context, rc);
}
UIComponent prompt = getFacet(component,
CoreShowDetail.PROMPT_FACET);
if (prompt == null)
{
- String text = getDisclosureText(arc, bean, disclosed);
+ String text = getDisclosureText(rc, component, bean, disclosed);
if (text != null)
{
if (!isTableAllDisclosure())
- _renderLinkStart(context, arc, bean, parameterString);
- renderStyleClasses(context, arc, getLinkStyleClasses());
+ _renderLinkStart(context, rc, component, bean, parameterString);
+ renderStyleClasses(context, rc, getLinkStyleClasses());
if (javaScriptSupport)
{
rw.writeText(text,
@@ -129,17 +132,17 @@
}
else
{
- // Since for Non-JavaScript browsers we render an input tag, set the
+ // Since for Non-JavaScript browsers we render an input tag, set the
// value attribute to text
- rw.writeAttribute("value", text,
+ rw.writeAttribute("value", text,
disclosed ? "disclosedText" : "undisclosedText");
}
- _renderLinkEnd(context, arc);
+ _renderLinkEnd(context, rc);
}
}
if (isTableAllDisclosure() && prompt != null)
- _renderLinkEnd(context, arc);
+ _renderLinkEnd(context, rc);
if (prompt != null)
{
@@ -163,10 +166,11 @@
}
protected void renderPromptStart(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
ResponseWriter writer = context.getResponseWriter();
@@ -177,11 +181,12 @@
else
writer.startElement("div", component);
- renderAllAttributes(context, arc, bean);
+ renderAllAttributes(context, rc, component, bean);
}
protected void renderPromptEnd(
- FacesContext context) throws IOException
+ FacesContext context
+ ) throws IOException
{
ResponseWriter writer = context.getResponseWriter();
@@ -193,23 +198,24 @@
static public void renderDisclosureIcon(
- FacesContext context,
- RenderingContext arc,
- boolean disclosed,
- String disclosedAltTextKey,
- String undisclosedAltTextKey) throws IOException
- {
+ FacesContext context,
+ RenderingContext rc,
+ boolean disclosed,
+ String disclosedAltTextKey,
+ String undisclosedAltTextKey
+ ) throws IOException
+ {
String key = disclosed ? disclosedAltTextKey : undisclosedAltTextKey;
// Get the alt text
- String altText = arc.getTranslatedString(key);
+ String altText = rc.getTranslatedString(key);
// Since we render input element for Non-JavaScript browsers, we cannot
- // render image element as its child. So set the value attribute of
- // input element to the icon symbol
- if (!supportsScripting(arc))
+ // render image element as its child. So set the value attribute of
+ // input element to the icon symbol
+ if (!supportsScripting(rc))
{
ResponseWriter rw = context.getResponseWriter();
String icon = disclosed ? XhtmlConstants.NON_JS_DETAIL_DISCLOSED_ICON :
- XhtmlConstants.NON_JS_DETAIL_UNDISCLOSED_ICON;
+ XhtmlConstants.NON_JS_DETAIL_UNDISCLOSED_ICON;
rw.writeAttribute("title", altText, null);
rw.writeAttribute("value", icon, null);
String linkConverter = "border: none; background: inherit;";
@@ -217,24 +223,25 @@
}
else
{
- Icon icon = _getDisclosureIcon(arc, disclosed);
+ Icon icon = _getDisclosureIcon(rc, disclosed);
if (icon != null)
{
// Get the align
- String align = OutputUtils.getMiddleIconAlignment(arc);
+ String align = OutputUtils.getMiddleIconAlignment(rc);
// Render the icon with the specified attrs
- OutputUtils.renderIcon(context, arc, icon, altText, align);
+ OutputUtils.renderIcon(context, rc, icon, altText, align);
}
}
}
protected void renderDisclosureIcon(
- FacesContext context,
- RenderingContext arc,
- boolean disclosed) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ boolean disclosed
+ ) throws IOException
{
- renderDisclosureIcon(context, arc, disclosed,
+ renderDisclosureIcon(context, rc, disclosed,
_DISCLOSED_TIP_KEY, _UNDISCLOSED_TIP_KEY);
}
@@ -249,49 +256,49 @@
return true;
}
-
// Returns the disclosure Icon
private static Icon _getDisclosureIcon(
- RenderingContext arc,
- boolean disclosed
+ RenderingContext rc,
+ boolean disclosed
)
{
String iconName = (disclosed
? SkinSelectors.AF_SHOW_DETAIL_DISCLOSED_ICON_NAME
: SkinSelectors.AF_SHOW_DETAIL_UNDISCLOSED_ICON_NAME);
- return arc.getIcon(iconName);
+ return rc.getIcon(iconName);
}
protected String getDisclosureText(
- RenderingContext arc,
- FacesBean bean,
- boolean disclosed)
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean,
+ boolean disclosed)
{
String text;
if (disclosed)
{
- text = getDisclosedText(bean);
+ text = getDisclosedText(component, bean);
if (text == null)
{
//smo: This functionality was added durring API Merge. If getDisclosedText is not present
//we'll render undislosedText text if it's present before rendering the defaults
- text = getUndisclosedText(bean);
+ text = getUndisclosedText(component, bean);
if(text == null)
{
- text = arc.getTranslatedString(_DISCLOSED_KEY);
+ text = rc.getTranslatedString(_DISCLOSED_KEY);
}
}
}
else
{
- text = getUndisclosedText(bean);
+ text = getUndisclosedText(component, bean);
if (text == null)
{
- text = getDisclosedText(bean);
+ text = getDisclosedText(component, bean);
if(text == null)
{
- text = arc.getTranslatedString(_UNDISCLOSED_KEY);
+ text = rc.getTranslatedString(_UNDISCLOSED_KEY);
}
}
}
@@ -300,14 +307,15 @@
}
private void _renderScripts(
- FacesContext context,
- RenderingContext arc,
- UIComponent component) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component
+ ) throws IOException
{
- if (!supportsNavigation(arc))
+ if (!supportsNavigation(rc))
return;
- FormData fData = arc.getFormData();
+ FormData fData = rc.getFormData();
if (fData == null)
{
_LOG.warning("SHOWDETAIL_NOT_IN_FORM_WILLNOT_FUNCTION_PROPERLY");
@@ -321,9 +329,9 @@
boolean partial = PartialPageUtils.isPPRActive(context);
// the first time, render the necessary Javascript
- if (arc.getProperties().get(_SHOW_DETAIL_SUBMIT_JS_RENDERED) == null)
+ if (rc.getProperties().get(_SHOW_DETAIL_SUBMIT_JS_RENDERED) == null)
{
- arc.getProperties().put(_SHOW_DETAIL_SUBMIT_JS_RENDERED,
+ rc.getProperties().put(_SHOW_DETAIL_SUBMIT_JS_RENDERED,
Boolean.TRUE);
// write the submit function
@@ -365,8 +373,8 @@
// write the submit function
rw.startElement("script", null);
- renderScriptDeferAttribute(context, arc);
- renderScriptTypeAttribute(context, arc);
+ renderScriptDeferAttribute(context, rc);
+ renderScriptTypeAttribute(context, rc);
rw.writeText(js, null);
rw.endElement("script");
@@ -381,30 +389,31 @@
// And add this needed value if it ever comes up
if (valueValue != null)
fData.addNeededValue(XhtmlConstants.VALUE_PARAM);
-
}
private void _renderLinkStart(
- FacesContext context,
- RenderingContext arc,
- FacesBean bean,
- String parameterString ) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean,
+ String parameterString
+ ) throws IOException
{
ResponseWriter rw = context.getResponseWriter();
- if (!supportsNavigation(arc)) {
+ if (!supportsNavigation(rc)) {
rw.startElement("span", null);
}
- else if (supportsScripting(arc))
+ else if (supportsScripting(rc))
{
- String onclick = getOnclick(bean);
+ String onclick = getOnclick(component, bean);
rw.startElement("a", null);
onclick = XhtmlUtils.getChainedJS(onclick, parameterString, true);
rw.writeAttribute("onclick", onclick, null);
rw.writeURIAttribute("href", "#", null);
}
- // For Non-JavaScript browsers, render an input element(type=submit) to
- // submit the page. Encode the name attribute with the parameter name
- // and value thus it would enable the browsers to include the name of
+ // For Non-JavaScript browsers, render an input element(type=submit) to
+ // submit the page. 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.
else
{
@@ -415,13 +424,13 @@
}
private String _generateOnClickString(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean,
- boolean disclosed)
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean,
+ boolean disclosed)
{
- FormData fData = arc.getFormData();
+ FormData fData = rc.getFormData();
if (fData == null)
return null;
@@ -448,7 +457,7 @@
linkBuffer.append("return _submitHideShow('");
linkBuffer.append(formName);
linkBuffer.append("',");
- linkBuffer.append(getImmediate(bean) ? '0' : '1');
+ linkBuffer.append(getImmediate(component, bean) ? '0' : '1');
linkBuffer.append(",'");
linkBuffer.append(eventValue);
linkBuffer.append("','");
@@ -467,43 +476,43 @@
return linkBuffer.toString();
}
-
private void _renderLinkEnd(
- FacesContext context,
- RenderingContext arc) throws IOException
+ FacesContext context,
+ RenderingContext rc
+ ) throws IOException
{
ResponseWriter rw = context.getResponseWriter();
- if (!supportsNavigation(arc))
+ if (!supportsNavigation(rc))
rw.endElement("span");
- else if (supportsScripting(arc))
+ else if (supportsScripting(rc))
rw.endElement("a");
else
rw.endElement("input");
}
-
+
/**
* @return encoded parameter name and value pairs for Non-JavaScript
- * browsers
+ * browsers
*/
private String _encodedParam(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean,
- boolean disclosed)
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean,
+ boolean disclosed)
{
- FormData fData = arc.getFormData();
+ FormData fData = rc.getFormData();
if (fData == null)
return null;
-
+
String sourceValue = getClientId(context, component);
String eventValue = (disclosed
? XhtmlConstants.HIDE_EVENT
: XhtmlConstants.SHOW_EVENT);
-
+
String valueValue = getValueParameter(component);
String linkId = getLinkId(sourceValue, disclosed);
-
+
String nameAttri = XhtmlUtils.getEncodedParameter
(XhtmlConstants.SOURCE_PARAM)
+ XhtmlUtils.getEncodedParameter(sourceValue)
@@ -512,7 +521,7 @@
+ XhtmlUtils.getEncodedParameter(eventValue)
+ XhtmlUtils.getEncodedParameter
(XhtmlConstants.VALUE_PARAM)
- + valueValue;
+ + valueValue;
return nameAttri;
}
@@ -541,7 +550,8 @@
return false;
}
- protected String getValueParameter(UIComponent component)
+ protected String getValueParameter(
+ UIComponent component)
{
return null;
}
@@ -557,12 +567,16 @@
/**
*/
- protected String getLinkId(String rootId, boolean disclosed)
+ protected String getLinkId(
+ String rootId,
+ boolean disclosed)
{
return XhtmlUtils.getCompositeId(rootId, null);
}
- protected boolean getImmediate(FacesBean bean)
+ protected boolean getImmediate(
+ UIComponent component,
+ FacesBean bean)
{
Object o = bean.getProperty(_immediateKey);
if (o == null)
@@ -572,7 +586,9 @@
}
- protected String getDisclosedText(FacesBean bean)
+ protected String getDisclosedText(
+ UIComponent component,
+ FacesBean bean)
{
// It can be null in the table...
if (_disclosedTextKey == null)
@@ -581,7 +597,9 @@
return toString(bean.getProperty(_disclosedTextKey));
}
- protected String getUndisclosedText(FacesBean bean)
+ protected String getUndisclosedText(
+ UIComponent component,
+ FacesBean bean)
{
// It can be null in the table...
if (_undisclosedTextKey == null)
@@ -594,14 +612,18 @@
return DISCLOSURE_ICON_LINK_STYLE_CLASSES;
}
- protected String getPromptStyleClass(boolean disclosed) {
+ protected String getPromptStyleClass(
+ boolean disclosed) {
return disclosed
? SkinSelectors.AF_SHOW_DETAIL_PROMPT_DISCLOSED_STYLE_CLASS
: SkinSelectors.AF_SHOW_DETAIL_PROMPT_UNDISCLOSED_STYLE_CLASS;
}
- protected String getDefaultStyleClass(FacesBean bean) {
- return getPromptStyleClass(getDisclosed(bean));
+ protected String getDefaultStyleClass(
+ UIComponent component,
+ FacesBean bean)
+ {
+ return getPromptStyleClass(getDisclosed(component, bean));
}
private PropertyKey _immediateKey;
Modified: myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputColorRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputColorRenderer.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/SimpleInputColorRenderer.java (original)
+++ myfaces/trinidad/branches/ar_clientBehaviors/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputColorRenderer.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,7 +19,9 @@
package org.apache.myfaces.trinidadinternal.renderkit.core.xhtml;
import java.awt.Color;
+
import java.io.IOException;
+
import java.util.HashMap;
import java.util.Map;
@@ -59,13 +61,15 @@
this(CoreInputColor.TYPE);
}
- public SimpleInputColorRenderer(FacesBean.Type type)
+ public SimpleInputColorRenderer(
+ FacesBean.Type type)
{
super(type);
}
@Override
- protected void findTypeConstants(FacesBean.Type type)
+ protected void findTypeConstants(
+ FacesBean.Type type)
{
super.findTypeConstants(type);
_compactKey = type.findKey("compact");
@@ -73,11 +77,13 @@
}
@Override
- protected void queueActionEvent(FacesContext context, UIComponent component)
+ protected void queueActionEvent(
+ FacesContext context,
+ UIComponent component)
{
FacesBean bean = getFacesBean(component);
// If there's a non-default action, then just launch away
- if (getActionExpression(bean) != null)
+ if (getActionExpression(component, bean) != null)
{
super.queueActionEvent(context, component);
}
@@ -87,7 +93,7 @@
// a calendar window with the _ldp JS function)
else
{
- Object submittedValue = getSubmittedValue(bean);
+ Object submittedValue = getSubmittedValue(component, bean);
try
{
getConvertedValue(context, component, submittedValue);
@@ -129,9 +135,9 @@
if (returnValue instanceof Color)
{
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)
{
@@ -154,55 +160,57 @@
@Override
protected void encodeAllAsElement(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
- if (!_colorScriptletsRegistered)
+ if (!_colorScriptletsRegistered)
{
ColorFieldInfoScriptlet.sharedInstance().registerSelf();
(new AliasedScriptlet(_COLOR_FIELD_LIB, null,
new String[]{"openWindow()",
"_getColorFieldFormat()",
ColorFieldInfoScriptlet.COLOR_FIELD_INFO_KEY
- })).registerSelf();
- _colorScriptletsRegistered = true;
+ })).registerSelf();
+ _colorScriptletsRegistered = true;
}
String chooseId = _computeChooseId(context, component, bean);
- arc.getProperties().put(_CACHED_CHOOSE_ID, chooseId);
+ rc.getProperties().put(_CACHED_CHOOSE_ID, chooseId);
// Add the scriptlets required by the color field
- XhtmlUtils.addLib(context, arc, "_fixCFF()");
- XhtmlUtils.addLib(context, arc, _COLOR_FIELD_LIB);
- super.encodeAllAsElement(context, arc, component, bean);
+ XhtmlUtils.addLib(context, rc, "_fixCFF()");
+ XhtmlUtils.addLib(context, rc, _COLOR_FIELD_LIB);
+ super.encodeAllAsElement(context, rc, component, bean);
- if (!getDisabled(bean))
+ if (!getDisabled(component, bean))
{
// =-=AEW addOnSubmitConverterValidators() when compact???
- _renderFirstColorFieldScript(context, arc, component, _getChooseId(arc));
+ _renderFirstColorFieldScript(context, rc, component, _getChooseId(rc));
}
- arc.getProperties().remove(_CACHED_CHOOSE_ID);
+ rc.getProperties().remove(_CACHED_CHOOSE_ID);
}
@Override
protected void renderTextField(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
- if (!isCompact(bean) ||
- !_supportsSwatchAndChooser(arc))
+ if (!isCompact(component, bean) ||
+ !_supportsSwatchAndChooser(rc))
{
- super.renderTextField(context, arc, component, bean);
+ super.renderTextField(context, rc, component, bean);
}
else
{
- if (isAutoSubmit(bean))
- AutoSubmitUtils.writeDependencies(context, arc);
- addOnSubmitConverterValidators(context, arc, component, bean);
+ if (isAutoSubmit(component, bean))
+ AutoSubmitUtils.writeDependencies(context, rc);
+ addOnSubmitConverterValidators(context, rc, component, bean);
// In compact mode, write out a hidden field that is
// the stub
@@ -214,7 +222,7 @@
component,
bean),
"value");
- String id = arc.getCurrentClientId();
+ String id = rc.getCurrentClientId();
writer.writeAttribute("id", id, null);
writer.writeAttribute("name", id, null);
writer.endElement("input");
@@ -223,63 +231,66 @@
@Override
protected void renderContent(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean,
- boolean renderAsElement,
- boolean isTextArea) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean,
+ boolean renderAsElement,
+ boolean isTextArea
+ ) throws IOException
{
// Hook here to make sure we're inside the <span>
assert(!isTextArea);
- super.renderContent(context, arc, component, bean,
+ super.renderContent(context, rc, component, bean,
renderAsElement, isTextArea);
if (!renderAsElement)
{
- renderAfterTextField(context, arc, component, bean);
+ renderAfterTextField(context, rc, component, bean);
}
}
@Override
protected void renderAfterTextField(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
- if (!_supportsSwatchAndChooser(arc))
+ if (!_supportsSwatchAndChooser(rc))
return;
- if (!isCompact(bean))
+ if (!isCompact(component, bean))
{
// =-=AEW TODO: Make spacer a property?
- renderSpacer(context, arc, "8", "1");
- renderIcon(context, arc, component, bean);
+ renderSpacer(context, rc, "8", "1");
+ renderIcon(context, rc, component, bean);
}
else
{
- renderIcon(context, arc, component, bean);
+ renderIcon(context, rc, component, bean);
}
}
@Override
protected void renderIcon(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
- {
- boolean isEditable = ((_getChooseId(arc) == null) &&
- !getDisabled(bean) &&
- !getReadOnly(context, bean));
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
+ {
+ boolean isEditable = ((_getChooseId(rc) == null) &&
+ !getDisabled(component, bean) &&
+ !getReadOnly(context, component, bean));
if (isEditable)
{
XhtmlUtils.addLib(context,
- arc,
+ rc,
ConfigurationScriptlet.sharedInstance().getScriptletKey());
}
- _renderColorSwatch(context, arc, component, bean, isEditable);
+ _renderColorSwatch(context, rc, component, bean, isEditable);
}
/**
@@ -288,6 +299,7 @@
@Override
protected Converter getDefaultConverter(
FacesContext context,
+ UIComponent component,
FacesBean bean)
{
return _DEFAULT_CONVERTER;
@@ -295,28 +307,29 @@
@Override
protected String getLaunchOnclick(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
// If the field has an action, use the default behavior. Or,
// if the field doesn't support launching a window at all,
// use the default behavior.
- if ((getActionExpression(bean) != null) ||
+ if ((getActionExpression(component, bean) != null) ||
!Boolean.TRUE.equals(
- arc.getAgent().getCapabilities().get(TrinidadAgent.CAP_MULTIPLE_WINDOWS)))
- return super.getLaunchOnclick(context, arc, component, bean);
+ rc.getAgent().getCapabilities().get(TrinidadAgent.CAP_MULTIPLE_WINDOWS)))
+ return super.getLaunchOnclick(context, rc, component, bean);
- String id = arc.getCurrentClientId();
- if ((id == null) || (arc.getFormData() == null))
+ String id = rc.getCurrentClientId();
+ if ((id == null) || (rc.getFormData() == null))
return null;
// we want something big enough
StringBuffer onClickBuffer = new StringBuffer(100);
onClickBuffer.append("_lcp('");
- onClickBuffer.append(arc.getFormData().getName());
+ onClickBuffer.append(rc.getFormData().getName());
onClickBuffer.append("','");
onClickBuffer.append(id);
@@ -326,9 +339,11 @@
}
@Override
- protected String getOnfocus(FacesBean bean)
+ protected String getOnfocus(
+ UIComponent component,
+ FacesBean bean)
{
- String onfocus = super.getOnfocus(bean);
+ String onfocus = super.getOnfocus(component, bean);
RenderingContext arc = RenderingContext.getCurrentInstance();
if (!_supportsSwatchAndChooser(arc))
return onfocus;
@@ -354,9 +369,11 @@
}
@Override
- protected String getOnblur(FacesBean bean)
+ protected String getOnblur(
+ UIComponent component,
+ FacesBean bean)
{
- String onblur = super.getOnblur(bean);
+ String onblur = super.getOnblur(component, bean);
if (!_supportsSwatchAndChooser(RenderingContext.getCurrentInstance()))
return XhtmlUtils.getChainedJS(_AUTO_FORMAT_SCRIPT,
onblur, false);
@@ -367,11 +384,14 @@
}
@Override
- protected Integer getDefaultColumns(RenderingContext arc, FacesBean bean)
+ protected Integer getDefaultColumns(
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean)
{
Integer columnsInteger = null;
-
- Converter converter = getConverter(bean);
+
+ Converter converter = getConverter(component, bean);
// Ignoring the "default" converter code is intentional; we'll just
// fall through to _DEFAULT_COLUMNS here to save time
@@ -384,12 +404,14 @@
{
columnsInteger = _DEFAULT_COLUMNS;
}
-
+
return columnsInteger;
}
@Override
- protected Number getMaximumLength(FacesBean bean)
+ protected Number getMaximumLength(
+ UIComponent component,
+ FacesBean bean)
{
// Not supported for selectInputColor
// =-=AEW We could have a good default
@@ -402,12 +424,16 @@
return SkinSelectors.AF_SELECT_INPUT_COLOR_LAUNCH_ICON_NAME;
}
- protected String getChooseId(FacesBean bean)
+ protected String getChooseId(
+ UIComponent component,
+ FacesBean bean)
{
return toString(bean.getProperty(_chooseIdKey));
}
- protected boolean isCompact(FacesBean bean)
+ protected boolean isCompact(
+ UIComponent component,
+ FacesBean bean)
{
Object o = bean.getProperty(_compactKey);
if (o == null)
@@ -417,20 +443,25 @@
}
@Override
- protected String getRootStyleClass(FacesBean bean)
+ protected String getRootStyleClass(
+ UIComponent component,
+ FacesBean bean)
{
return "af|inputColor";
}
@Override
- protected String getContentStyleClass(FacesBean bean)
+ protected String getContentStyleClass(
+ UIComponent component,
+ FacesBean bean)
{
return "af|inputColor::content";
}
- private String _getChooseId(RenderingContext arc)
+ private String _getChooseId(
+ RenderingContext rc)
{
- return (String) arc.getProperties().get(_CACHED_CHOOSE_ID);
+ return (String) rc.getProperties().get(_CACHED_CHOOSE_ID);
}
private String _computeChooseId(
@@ -440,18 +471,21 @@
{
return RenderUtils.getRelativeId(context,
component,
- getChooseId(bean));
+ getChooseId(component, bean));
}
// On PDAs, we only support a simple text field
- private boolean _supportsSwatchAndChooser(RenderingContext arc)
+ private boolean _supportsSwatchAndChooser(
+ RenderingContext rc)
{
- return (!isPDA(arc));
+ return (!isPDA(rc));
}
@Override
- protected String getSearchDesc(FacesBean bean)
+ protected String getSearchDesc(
+ UIComponent component,
+ FacesBean bean)
{
RenderingContext arc = RenderingContext.getCurrentInstance();
if (isInaccessibleMode(arc))
@@ -460,96 +494,99 @@
return arc.getTranslatedString(_LAUNCH_PICKER_TIP_KEY);
}
- private String _getColorSwatchId(RenderingContext arc)
+ private String _getColorSwatchId(
+ RenderingContext rc)
{
- return arc.getCurrentClientId() + "$sw";
+ return rc.getCurrentClientId() + "$sw";
}
-
private void _renderColorSwatch(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean,
- boolean editable) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean,
+ boolean editable
+ ) throws IOException
{
ResponseWriter writer = context.getResponseWriter();
if (editable)
{
writer.startElement("a", component);
writer.writeAttribute("onclick",
- getLaunchOnclick(context, arc, component, bean),
+ getLaunchOnclick(context, rc, component, bean),
null);
writer.writeURIAttribute("href", "#", null);
}
writer.startElement("img", component);
- String id = _getColorSwatchId(arc);
+ String id = _getColorSwatchId(rc);
// Render the ID directly on the swatch image.
writer.writeAttribute("id", id, null);
// Render other image attrs
writer.writeAttribute("align",
- isScreenReaderMode(arc) ? "middle" : "absmiddle",
+ isScreenReaderMode(rc) ? "middle" : "absmiddle",
null);
writer.writeAttribute("width", _CELL_SIZE, null);
writer.writeAttribute("height", _CELL_SIZE, null);
- Color color = _getColorValue(bean);
+ Color color = _getColorValue(component, bean);
// Render the style attributes
String inlineStyle = _getInlineStyleForColor(color);
- renderStyleClass(context, arc, SkinSelectors.COLOR_FIELD_SWATCH_STYLE_CLASS);
+ renderStyleClass(context, rc, SkinSelectors.COLOR_FIELD_SWATCH_STYLE_CLASS);
writer.writeAttribute("style", inlineStyle, null);
Object altText = null;
if (color != null && color.getAlpha() == 0)
{
- Icon icon = arc.getIcon(XhtmlConstants.COLOR_PALETTE_TRANSPARENT_ICON_NAME);
+ Icon icon = rc.getIcon(XhtmlConstants.COLOR_PALETTE_TRANSPARENT_ICON_NAME);
if (icon != null)
{
// FIXME: this should happen with just rendering the Icon, *not*
// by extracting the URI
- renderEncodedResourceURI(context, "src", icon.getImageURI(context, arc));
+ renderEncodedResourceURI(context, "src", icon.getImageURI(context, rc));
}
String key = editable ?
"af_inputColor.LAUNCH_PICKER_TIP" :
"af_chooseColor.TRANSPARENT";
- altText = arc.getTranslatedString(key);
+ altText = rc.getTranslatedString(key);
}
else
{
- String transparentURI = getBaseImageUri(context, arc) + TRANSPARENT_GIF;
+ String transparentURI = getBaseImageUri(context, rc) + TRANSPARENT_GIF;
renderEncodedResourceURI(context, "src", transparentURI);
if (editable)
- altText = arc.getTranslatedString("af_inputColor.LAUNCH_PICKER_TIP");
+ altText = rc.getTranslatedString("af_inputColor.LAUNCH_PICKER_TIP");
else
altText = "";
}
- OutputUtils.renderAltAndTooltipForImage(context, arc, altText);
+ OutputUtils.renderAltAndTooltipForImage(context, rc, altText);
writer.endElement("img");
if (editable)
{
- Icon overlay = arc.getIcon(SkinSelectors.AF_SELECT_INPUT_COLOR_SWATCH_OVERLAY_ICON_NAME);
+ Icon overlay = rc.getIcon(SkinSelectors.AF_SELECT_INPUT_COLOR_SWATCH_OVERLAY_ICON_NAME);
if (overlay != null)
- OutputUtils.renderIcon(context, arc, overlay, "", "middle");
+ OutputUtils.renderIcon(context, rc, overlay, "", "middle");
writer.endElement("a");
}
}
// @todo Should this deal with submittedValue, and String values?
- private Color _getColorValue(FacesBean bean)
+ private Color _getColorValue(
+ UIComponent component,
+ FacesBean bean)
{
- Object value = getValue(bean);
+ Object value = getValue(component, bean);
if (value instanceof Color)
return ((Color) value);
return null;
@@ -557,33 +594,32 @@
// Checks to see whether this is the first color field for
// a given chooseId, and if so renders a script
- @SuppressWarnings("unchecked")
private void _renderFirstColorFieldScript(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- String chooseId
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ String chooseId
) throws IOException
{
if (chooseId == null)
return;
- if (!_supportsSwatchAndChooser(arc))
+ if (!_supportsSwatchAndChooser(rc))
return;
- if (arc.getFormData() == null)
+ if (rc.getFormData() == null)
return;
String id = getClientId(context, component);
-
+ @SuppressWarnings("unchecked")
Map<String, Boolean> chooseColorIds = (Map<String, Boolean>)
- arc.getProperties().get(_CHOOSE_COLOR_IDS_KEY);
+ rc.getProperties().get(_CHOOSE_COLOR_IDS_KEY);
if (chooseColorIds == null)
{
chooseColorIds = new HashMap<String, Boolean>();
- arc.getProperties().put(_CHOOSE_COLOR_IDS_KEY, chooseColorIds);
+ rc.getProperties().put(_CHOOSE_COLOR_IDS_KEY, chooseColorIds);
}
// The first dateField that is rendered for each inlineDatePicker
@@ -596,13 +632,13 @@
// this selectInputColor.
ResponseWriter writer = context.getResponseWriter();
writer.startElement("script", component);
- renderScriptTypeAttribute(context, arc);
- renderScriptDeferAttribute(context, arc);
+ renderScriptTypeAttribute(context, rc);
+ renderScriptDeferAttribute(context, rc);
writer.writeText("_cfBus['", null);
writer.writeText(chooseId, null);
writer.writeText("']=document.forms['", null);
- writer.writeText(arc.getFormData().getName(), null);
+ writer.writeText(rc.getFormData().getName(), null);
writer.writeText("']['", null);
writer.writeText(id, null);
writer.writeText("'];", null);
@@ -613,7 +649,8 @@
}
}
- private static String _getInlineStyleForColor(Color color)
+ private static String _getInlineStyleForColor(
+ Color color)
{
if (color != null && color.getAlpha() > 0)
return "background-color:" + CSSUtils.getColorValue(color);
@@ -652,5 +689,4 @@
private static final TrinidadLogger _LOG =
TrinidadLogger.createTrinidadLogger(SimpleInputColorRenderer.class);
-
-}
+}
\ No newline at end of file