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/17 03:33:11 UTC
svn commit: r891522 [15/28] - in /myfaces/trinidad/branches/trinidad-2.0.x:
./ trinidad-api/ trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/
trinidad-api/src/main/java/org/apache/myfaces/trinidad/bean/util/
trinidad-api/src/main/java/org/a...
Modified: myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputDateRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputDateRenderer.java?rev=891522&r1=891521&r2=891522&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputDateRenderer.java (original)
+++ myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputDateRenderer.java Thu Dec 17 02:33:05 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.Calendar;
import java.util.Date;
import java.util.HashMap;
@@ -62,24 +63,28 @@
this(CoreInputDate.TYPE);
}
- public SimpleInputDateRenderer(FacesBean.Type type)
+ public SimpleInputDateRenderer(
+ FacesBean.Type type)
{
super(type);
}
@Override
- protected void findTypeConstants(FacesBean.Type type)
+ protected void findTypeConstants(
+ FacesBean.Type type)
{
super.findTypeConstants(type);
_chooseIdKey = type.findKey("chooseId");
}
@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);
}
@@ -89,7 +94,7 @@
// a calendar window with the _ldp JS function)
else
{
- Object submittedValue = getSubmittedValue(bean);
+ Object submittedValue = getSubmittedValue(component, bean);
Date date = null;
try
{
@@ -113,7 +118,7 @@
}
RequestContext afContext = RequestContext.getCurrentInstance();
- DateTimeRangeValidator dtrv = _findDateTimeRangeValidator(bean);
+ DateTimeRangeValidator dtrv = _findDateTimeRangeValidator(component, bean);
if (date == null)
date = new Date();
@@ -137,7 +142,6 @@
}
}
-
/**
* Give subclasses a chance to override the ReturnEvent.
*/
@@ -155,9 +159,9 @@
if ((returnValue instanceof Date) || fac.isConvertible(returnValue, Date.class))
{
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)
{
@@ -180,45 +184,47 @@
@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 (!_dateScriptletsRegistered)
+ if (!_dateScriptletsRegistered)
{
// Register our scriptlet
DateTimeZoneOffsetScriptlet.sharedInstance().registerSelf();
_dateScriptletsRegistered = 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 date field
// =-=AEW What's this one?
- XhtmlUtils.addLib(context, arc, "_dfsv()");
- XhtmlUtils.addLib(context, arc, "_fixDFF()");
- XhtmlUtils.addLib(context, arc, _DATE_TIME_ZONE_OFFSET_KEY);
- super.encodeAllAsElement(context, arc, component, bean);
+ XhtmlUtils.addLib(context, rc, "_dfsv()");
+ XhtmlUtils.addLib(context, rc, "_fixDFF()");
+ XhtmlUtils.addLib(context, rc, _DATE_TIME_ZONE_OFFSET_KEY);
+ super.encodeAllAsElement(context, rc, component, bean);
- if (!getDisabled(bean))
+ if (!getDisabled(component, bean))
{
- _checkIfActive(context, arc, component, _getChooseId(arc));
+ _checkIfActive(context, rc, component, _getChooseId(rc));
}
}
@Override
protected void renderIcon(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
// Add the two scriptlets required by the icon
XhtmlUtils.addLib(context,
- arc,
+ rc,
ConfigurationScriptlet.sharedInstance().getScriptletKey());
// XhtmlUtils.addLib(context,
// arc,
@@ -228,24 +234,25 @@
if (CoreRenderKit.usePopupForDialog(context, RequestContext.getCurrentInstance()))
{
XhtmlUtils.addLib(context,
- arc,
+ rc,
DialogStyleScriptlet.sharedInstance().getScriptletKey());
}
-
- super.renderIcon(context, arc, component, bean);
+
+ super.renderIcon(context, rc, component, bean);
}
- @Override
+ @Override
protected void renderAfterTextField(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
// ADFFACES-317: don't bother rendering the icon if there's
// an attached chooser
- if (_getChooseId(arc) == null)
- super.renderAfterTextField(context, arc, component, bean);
+ if (_getChooseId(rc) == null)
+ super.renderAfterTextField(context, rc, component, bean);
}
/**
@@ -256,6 +263,7 @@
@Override
protected Converter getDefaultConverter(
FacesContext context,
+ UIComponent component,
FacesBean bean)
{
Converter converter = context.getApplication().
@@ -267,16 +275,16 @@
if (converter instanceof DateTimeConverter)
{
DateTimeConverter dtc = (DateTimeConverter) converter;
-
+
boolean trinidadDTC = _isTrinidadDateTimeConverter(converter);
-
+
if (!trinidadDTC)
{
// if it is not the Trinidad DateTimeConverter, set the date style to
// short
dtc.setDateStyle("short");
}
-
+
// if it is not the Trinidad DateTimeConverter or (it is AND
// no time zone is set) then we want to set the
// time zone to the one in the faces context or use
@@ -284,25 +292,27 @@
if (!trinidadDTC || dtc.getTimeZone() == null)
{
TimeZone tz = null;
-
+
RequestContext requestContext = RequestContext.getCurrentInstance();
tz = requestContext.getTimeZone();
if(tz == null)
{
tz = TimeZone.getDefault();
}
-
+
dtc.setTimeZone(tz);
}
}
-
+
return converter;
}
@Override
- protected String getOnblur(FacesBean bean)
+ protected String getOnblur(
+ UIComponent component,
+ FacesBean bean)
{
- String onblur = super.getOnblur(bean);
+ String onblur = super.getOnblur(component, bean);
RenderingContext arc = RenderingContext.getCurrentInstance();
String chooseId = _getChooseId(arc);
@@ -326,9 +336,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();
String chooseId = _getChooseId(arc);
@@ -358,39 +370,40 @@
@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
StringBuilder onClickBuffer = new StringBuilder(100);
onClickBuffer.append("_ldp('");
- onClickBuffer.append(arc.getFormData().getName());
+ onClickBuffer.append(rc.getFormData().getName());
onClickBuffer.append("','");
onClickBuffer.append(id);
onClickBuffer.append('\'');
-
+
// Decide if we should display the picker in a popup or window
onClickBuffer.append(',');
- onClickBuffer.append(CoreRenderKit.usePopupForDialog(context,
- RequestContext.getCurrentInstance()));
+ onClickBuffer.append(CoreRenderKit.usePopupForDialog(context,
+ RequestContext.getCurrentInstance()));
- DateTimeRangeValidator dtrv = _findDateTimeRangeValidator(bean);
+ DateTimeRangeValidator dtrv = _findDateTimeRangeValidator(component, bean);
if (dtrv != null)
{
String minTime = _getDateAsString(dtrv.getMinimum());
@@ -424,12 +437,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
@@ -444,7 +459,7 @@
{
columnsInteger = _DEFAULT_COLUMNS;
}
-
+
return columnsInteger;
}
@@ -452,21 +467,25 @@
protected String getButtonIconName()
{
// Currently, date picker is not working for any PDA devices. An issue
- // (TRINIDAD-1203) was created to fix this problem, so until it is fixed
- // let's skip date picker rendering for PDA.
+ // (TRINIDAD-1203) was created to fix this problem, so until it is fixed
+ // let's skip date picker rendering for PDA.
if (isPDA(RenderingContext.getCurrentInstance()))
return null;
-
+
return SkinSelectors.AF_SELECT_INPUT_DATE_LAUNCH_ICON_NAME;
}
- protected String getChooseId(FacesBean bean)
+ protected String getChooseId(
+ UIComponent component,
+ FacesBean bean)
{
return toString(bean.getProperty(_chooseIdKey));
}
@Override
- protected String getSearchDesc(FacesBean bean)
+ protected String getSearchDesc(
+ UIComponent component,
+ FacesBean bean)
{
RenderingContext arc = RenderingContext.getCurrentInstance();
if (isInaccessibleMode(arc))
@@ -476,20 +495,25 @@
}
@Override
- protected String getRootStyleClass(FacesBean bean)
+ protected String getRootStyleClass(
+ UIComponent component,
+ FacesBean bean)
{
return "af|inputDate";
}
@Override
- protected String getContentStyleClass(FacesBean bean)
+ protected String getContentStyleClass(
+ UIComponent component,
+ FacesBean bean)
{
return "af|inputDate::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(
@@ -499,8 +523,8 @@
{
return RenderUtils.getRelativeId(context,
component,
- getChooseId(bean));
-
+ getChooseId(component, bean));
+
}
// Checks to see whether the current dateField should
@@ -508,10 +532,10 @@
// it.
@SuppressWarnings("unchecked")
private void _checkIfActive(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- String chooseId
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ String chooseId
) throws IOException
{
if (chooseId == null)
@@ -520,12 +544,12 @@
String id = getClientId(context, component);
Map<String, Boolean> activeDateFields = (Map<String, Boolean>)
- arc.getProperties().get(_ACTIVE_DATE_FIELDS_KEY);
+ rc.getProperties().get(_ACTIVE_DATE_FIELDS_KEY);
if (activeDateFields == null)
{
activeDateFields = new HashMap<String, Boolean>();
- arc.getProperties().put(_ACTIVE_DATE_FIELDS_KEY, activeDateFields);
+ rc.getProperties().put(_ACTIVE_DATE_FIELDS_KEY, activeDateFields);
}
// The first dateField that is rendered for each inlineDatePicker
@@ -538,8 +562,8 @@
// the dateField.
ResponseWriter writer = context.getResponseWriter();
writer.startElement("script", component);
- renderScriptTypeAttribute(context, arc);
- renderScriptDeferAttribute(context, arc);
+ renderScriptTypeAttribute(context, rc);
+ renderScriptDeferAttribute(context, rc);
writer.writeText("_dfa('", null);
writer.writeText(id, null);
@@ -557,9 +581,11 @@
// Find a DateTimeRangeValidator for use in setting up a
// minimum and maximum value
//
- private DateTimeRangeValidator _findDateTimeRangeValidator(FacesBean bean)
+ private DateTimeRangeValidator _findDateTimeRangeValidator(
+ UIComponent component,
+ FacesBean bean)
{
- Iterator<Validator> validators = getValidators(bean);
+ Iterator<Validator> validators = getValidators(component, bean);
while (validators.hasNext())
{
Object validator = validators.next();
@@ -570,19 +596,19 @@
return null;
}
-
- private static boolean _isTrinidadDateTimeConverter(Converter converter)
+ private static boolean _isTrinidadDateTimeConverter(
+ Converter converter)
{
return (converter instanceof
org.apache.myfaces.trinidad.convert.DateTimeConverter);
}
-
/**
* Stringify the date into canonical form; we currently
* use the long integer date.getTime().
*/
- private static String _getDateAsString(Date date)
+ private static String _getDateAsString(
+ Date date)
{
if (date == null)
return null;
@@ -595,7 +621,8 @@
* found in RequestContext and return the new date long value.
*/
@SuppressWarnings("cast")
- private static long _adjustTimeZone(Date date)
+ private static long _adjustTimeZone(
+ Date date)
{
// get the current date of the server
Calendar calendar = Calendar.getInstance();
@@ -624,13 +651,13 @@
if (tzOffset < 0)
{
// Cast to (float) has a purpose
- tzOffset = (long)Math.max((float)tzOffset,
+ tzOffset = (long)Math.max((float)tzOffset,
(float)Long.MIN_VALUE - (float)dateValueInMs);
}
else
{
// Cast to (float) has a purpose
- tzOffset = (long)Math.min((float)tzOffset,
+ tzOffset = (long)Math.min((float)tzOffset,
(float)Long.MAX_VALUE - (float)dateValueInMs);
}
@@ -644,7 +671,6 @@
// we format the date field with time values.
private static class DateTimeZoneOffsetScriptlet extends Scriptlet
{
-
static public Scriptlet sharedInstance()
{
return _sInstance;
@@ -681,7 +707,6 @@
private static final Scriptlet _sInstance =
new DateTimeZoneOffsetScriptlet();
-
}
private PropertyKey _chooseIdKey;
@@ -703,8 +728,7 @@
// name for our scriptlet
private static final String _DATE_TIME_ZONE_OFFSET_KEY = "dateTimeZoneOffset";
private static boolean _dateScriptletsRegistered = false;
-
+
private static final TrinidadLogger _LOG =
TrinidadLogger.createTrinidadLogger(SimpleInputDateRenderer.class);
-
-}
+}
\ No newline at end of file
Modified: myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputFileRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputFileRenderer.java?rev=891522&r1=891521&r2=891522&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputFileRenderer.java (original)
+++ myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputFileRenderer.java Thu Dec 17 02:33:05 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,17 +31,15 @@
import javax.faces.convert.ConverterException;
import org.apache.myfaces.trinidad.bean.FacesBean;
-
import org.apache.myfaces.trinidad.component.core.input.CoreInputFile;
import org.apache.myfaces.trinidad.component.core.input.CoreInputText;
-
import org.apache.myfaces.trinidad.context.RenderingContext;
import org.apache.myfaces.trinidad.context.RequestContext;
import org.apache.myfaces.trinidad.model.UploadedFile;
import org.apache.myfaces.trinidad.util.MessageFactory;
import org.apache.myfaces.trinidad.webapp.UploadedFileProcessor;
import org.apache.myfaces.trinidadinternal.config.upload.UploadedFiles;
-import org.apache.myfaces.trinidadinternal.context.RequestContextBean;
+
/**
*/
@@ -52,14 +50,15 @@
this(CoreInputFile.TYPE);
}
- public SimpleInputFileRenderer(FacesBean.Type type)
+ public SimpleInputFileRenderer(
+ FacesBean.Type type)
{
super(type);
}
//
// DECODE BEHAVIOR
- //
+ //
@Override
protected Object getSubmittedValue(
FacesContext context,
@@ -90,12 +89,13 @@
return result;
}
- protected String getAutoComplete(FacesBean bean)
+ protected String getAutoComplete(
+ UIComponent component,
+ FacesBean bean)
{
return CoreInputText.AUTO_COMPLETE_ON;
}
-
@Override
public Object getConvertedValue(
FacesContext context,
@@ -109,12 +109,12 @@
UploadedFile file = (UploadedFile) submittedValue;
if(file.getLength() == -1)
{
- FacesMessage fm = MessageFactory.getMessage(context, "org.apache.myfaces.trinidad.UPLOAD");
+ FacesMessage fm = MessageFactory.getMessage(context, "org.apache.myfaces.trinidad.UPLOAD");
throw new ConverterException(fm);
}
FacesBean bean = getFacesBean(component);
- Converter converter = getConverter(bean);
+ Converter converter = getConverter(component, bean);
// support converter for the <inputFile> component
if(converter != null)
{
@@ -122,7 +122,7 @@
// key to add the actual uploaded file to the requestMap
String fileNameKey = component.getClass().getName() + "." + file.getFilename();
context.getExternalContext().getRequestMap().put(fileNameKey, file);
-
+
// applying the above convention. The String here is just the
// unique key which the converter has to use to look for the
// actual uploaded file.
@@ -134,28 +134,28 @@
}
}
-
//
// ENCODE BEHAVIOR
- //
+ //
@Override
protected void encodeAllAsElement(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
// call super...
- super.encodeAllAsElement(context, arc, component, bean);
+ super.encodeAllAsElement(context, rc, component, bean);
// now evaluate the EL
// We need to evaluate it here and store it on the sessionMap because
// during UploadedFileProcessor.processFile() there is no FacesContext
- RequestContext rc = RequestContext.getCurrentInstance();
- Object maxMemory = rc.getUploadedFileMaxMemory();
- Object maxDiskSpace = rc.getUploadedFileMaxDiskSpace();
- Object tempDir = rc.getUploadedFileTempDir();
+ RequestContext requestContext = RequestContext.getCurrentInstance();
+ Object maxMemory = requestContext.getUploadedFileMaxMemory();
+ Object maxDiskSpace = requestContext.getUploadedFileMaxDiskSpace();
+ Object tempDir = requestContext.getUploadedFileTempDir();
ExternalContext external = context.getExternalContext();
Map<String, Object> sessionMap = external.getSessionMap();
sessionMap.put(UploadedFileProcessor.MAX_MEMORY_PARAM_NAME, maxMemory);
@@ -181,58 +181,73 @@
return "file";
}
-
//
// Overrides disabling all the things you can't do on
// an inputFile
- //
+ //
@Override
public boolean isTextArea(
- FacesBean bean)
+ UIComponent component,
+ FacesBean bean)
{
return false;
}
@Override
protected boolean isAutoSubmit(
- FacesBean bean)
+ UIComponent component,
+ FacesBean bean)
{
return false;
}
@Override
- protected boolean getSecret(FacesBean bean)
+ protected boolean getSecret(
+ UIComponent component,
+ FacesBean bean)
{
return false;
}
@Override
- protected Number getMaximumLength(FacesBean bean)
+ protected Number getMaximumLength(
+ UIComponent component,
+ FacesBean bean)
{
return null;
}
@Override
- protected boolean getReadOnly(FacesContext context, FacesBean bean)
+ protected boolean getReadOnly(
+ FacesContext context,
+ UIComponent component,
+ FacesBean bean)
{
return false;
}
-
+
@Override
- protected String getRootStyleClass(FacesBean bean)
+ protected String getRootStyleClass(
+ UIComponent component,
+ FacesBean bean)
{
return "af|inputFile";
}
@Override
- protected String getContentStyleClass(FacesBean bean)
+ protected String getContentStyleClass(
+ UIComponent component,
+ FacesBean bean)
{
return "af|inputFile::content";
}
@Override
- protected Integer getDefaultColumns(RenderingContext arc, FacesBean bean)
+ protected Integer getDefaultColumns(
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean)
{
return null;
}
Modified: myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputListOfValuesRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputListOfValuesRenderer.java?rev=891522&r1=891521&r2=891522&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputListOfValuesRenderer.java (original)
+++ myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputListOfValuesRenderer.java Thu Dec 17 02:33:05 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,36 +29,34 @@
import org.apache.myfaces.trinidad.bean.FacesBean;
import org.apache.myfaces.trinidad.bean.PropertyKey;
-
import org.apache.myfaces.trinidad.component.core.input.CoreInputListOfValues;
-
-import org.apache.myfaces.trinidad.context.RequestContext;
-
-import org.apache.myfaces.trinidad.event.ReturnEvent;
-
-import org.apache.myfaces.trinidadinternal.agent.TrinidadAgent;
-import org.apache.myfaces.trinidadinternal.agent.AgentUtil;
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.skin.Icon;
+import org.apache.myfaces.trinidadinternal.agent.AgentUtil;
+import org.apache.myfaces.trinidadinternal.agent.TrinidadAgent;
+
/**
*/
public class SimpleInputListOfValuesRenderer extends SimpleInputTextRenderer
{
-
public SimpleInputListOfValuesRenderer()
{
this(CoreInputListOfValues.TYPE);
}
-
- public SimpleInputListOfValuesRenderer(FacesBean.Type type)
+
+ public SimpleInputListOfValuesRenderer(
+ FacesBean.Type type)
{
super(type);
}
-
+
@Override
- protected void findTypeConstants(FacesBean.Type type)
+ protected void findTypeConstants(
+ FacesBean.Type type)
{
super.findTypeConstants(type);
_searchDescKey = type.findKey("searchDesc");
@@ -72,14 +70,16 @@
@SuppressWarnings("unchecked")
@Override
- public void decode(FacesContext context, UIComponent component)
+ public void decode(
+ FacesContext context,
+ UIComponent component)
{
super.decode(context, component);
RequestContext afContext = RequestContext.getCurrentInstance();
// See if a ReturnEvent is waiting for us. We don't deliver
// the ReturnEvent - we just use its value
- ReturnEvent returnEvent =
+ ReturnEvent returnEvent =
afContext.getDialogService().getReturnEvent(component);
if (returnEvent != null)
{
@@ -88,9 +88,9 @@
}
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))
@@ -125,7 +125,7 @@
protected void queueActionEvent(
FacesContext context,
- UIComponent component)
+ UIComponent component)
{
(new ActionEvent(component)).queue();
}
@@ -136,94 +136,102 @@
@Override
protected void encodeAllAsElement(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
ResponseWriter rw = context.getResponseWriter();
- boolean simple = getSimple(bean);
+ boolean simple = getSimple(component, bean);
if (simple)
{
rw.startElement("span", component);
// put the outer style class here, like af_selectManyRadio, styleClass,
// inlineStyle, 'state' styles like p_AFDisabled, etc.
- renderRootDomElementStyles(context, arc, component, bean);
+ renderRootDomElementStyles(context, rc, component, bean);
}
// =-=AEW Write out an ID???
- renderTextField(context, arc, component, bean);
- renderAfterTextField(context, arc, component, bean);
+ renderTextField(context, rc, component, bean);
+ renderAfterTextField(context, rc, component, bean);
if (simple)
rw.endElement("span");
}
-
+
@Override
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();
- boolean simple = getSimple(bean);
+ boolean simple = getSimple(component, bean);
if (simple)
{
rw.startElement("span", component);
// put the outer style class here, like af_selectManyRadio, styleClass,
// inlineStyle, 'state' styles like p_AFDisabled, etc.
- renderRootDomElementStyles(context, arc, component, bean);
+ renderRootDomElementStyles(context, rc, component, bean);
}
- super.encodeAllAsNonElement(context, arc, component, bean);
+ super.encodeAllAsNonElement(context, rc, component, bean);
if (simple)
- rw.endElement("span");
+ rw.endElement("span");
}
+
/*
* This is called from our super class to determine if we need to render
- * the span and root dom element styles on the text field, which we
+ * the span and root dom element styles on the text field, which we
* don't, since we do it ourselves on our root dom element.
*/
@Override
- protected boolean isSimpleInputText(FacesBean bean)
+ protected boolean isSimpleInputText(
+ UIComponent component,
+ FacesBean bean)
{
return false;
}
-
+
protected void renderTextField(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
- super.encodeAllAsElement(context, arc, component, bean);
+ super.encodeAllAsElement(context, rc, component, bean);
}
protected void renderAfterTextField(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
- if (!getDisabled(bean))
+ if (!getDisabled(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);
}
}
protected void renderIcon(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
- String iconUri = getIcon(bean);
+ String iconUri = getIcon(component, bean);
Icon icon;
if (iconUri == null)
{
- icon = arc.getIcon(getButtonIconName());
+ icon = rc.getIcon(getButtonIconName());
if ((icon == null) || icon.isNull())
return;
}
@@ -233,12 +241,12 @@
}
String onclick = getLaunchOnclick(context,
- arc,
+ rc,
component,
bean);
- String buttonOnclick = getButtonOnclick(bean);
+ String buttonOnclick = getButtonOnclick(component, bean);
if (buttonOnclick != null)
{
onclick = XhtmlUtils.getChainedJS(buttonOnclick, onclick, true);
@@ -249,25 +257,25 @@
rw.writeURIAttribute("href", "#", null);
rw.writeAttribute("onclick", onclick, null);
- String align = OutputUtils.getMiddleIconAlignment(arc);
- String title = getSearchDesc(bean);
+ String align = OutputUtils.getMiddleIconAlignment(rc);
+ String title = getSearchDesc(component, bean);
if (iconUri != null)
{
rw.startElement("img", null);
rw.writeAttribute("border", "0", null);
renderEncodedResourceURI(context, "src", iconUri);
- OutputUtils.renderAltAndTooltipForImage(context, arc, title);
+ OutputUtils.renderAltAndTooltipForImage(context, rc, title);
rw.writeAttribute("align", align, null);
rw.endElement("img");
}
else
{
- OutputUtils.renderIcon(context, arc, icon,
+ OutputUtils.renderIcon(context, rc, icon,
title, align);
}
rw.endElement("a");
-
+
}
protected String getButtonIconName()
@@ -275,41 +283,44 @@
return SkinSelectors.AF_SELECT_INPUT_TEXT_BUTTON_ICON_NAME;
}
- protected String getButtonOnclick(FacesBean bean)
+ protected String getButtonOnclick(
+ UIComponent component,
+ FacesBean bean)
{
- return super.getOnclick(bean);
+ return super.getOnclick(component, bean);
}
-
+
/**
* Must be called <em>before</em> starting an element!!!
*/
protected String getLaunchOnclick(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
- FormData fd = arc.getFormData();
+ FormData fd = rc.getFormData();
if (fd == null)
return null;
-
+
fd.addNeededValue("part");
// this is added for bug 4482982; when the selectInputDate or
// selectInputText icon is selected in PocketIE, the script requires
// the source hidden element to exist
- fd.addNeededValue(XhtmlConstants.SOURCE_PARAM);
+ fd.addNeededValue(XhtmlConstants.SOURCE_PARAM);
// Use a PPR autosubmit to launch the dialog only if we know
// that we can use a separate window; otherwise, just
// use an ordinary request (since we're going to have to
// refresh the whole window anyway)
- if (supportsSeparateWindow(arc))
+ if (supportsSeparateWindow(rc))
{
- AutoSubmitUtils.writeDependencies(context, arc);
+ AutoSubmitUtils.writeDependencies(context, rc);
return AutoSubmitUtils.getSubmitScript(
- arc,
+ rc,
getClientId(context, component),
true,
false,
@@ -320,7 +331,7 @@
else
{
return AutoSubmitUtils.getFullPageSubmitScript(
- arc,
+ rc,
getClientId(context, component),
true,
null, //event
@@ -331,28 +342,33 @@
@Override
public boolean isTextArea(
- FacesBean bean)
+ UIComponent component,
+ FacesBean bean)
{
return false;
}
@Override
- protected boolean getSecret(FacesBean bean)
+ protected boolean getSecret(
+ UIComponent component,
+ FacesBean bean)
{
return false;
}
-
+
/**
* We want onclick to move from the input field to the button;
* @see #getButtonOnclick
*/
@Override
- protected String getOnclick(FacesBean bean)
+ protected String getOnclick(
+ UIComponent component,
+ FacesBean bean)
{
if (shouldRenderInputOnclick())
return null;
else
- return super.getOnclick(bean);
+ return super.getOnclick(component, bean);
}
protected boolean shouldRenderInputOnclick()
@@ -360,21 +376,23 @@
return true;
}
- protected Object getActionExpression(FacesBean bean)
+ protected Object getActionExpression(
+ UIComponent component,
+ FacesBean bean)
{
return bean.getProperty(_actionExpressionKey);
}
protected String getSearchDesc(
- FacesBean bean
- )
+ UIComponent component,
+ FacesBean bean)
{
return toString(bean.getProperty(_searchDescKey));
}
protected String getIcon(
- FacesBean bean
- )
+ UIComponent component,
+ FacesBean bean)
{
// Support subclasses without support for overriding the icon
if (_iconKey == null)
@@ -384,13 +402,17 @@
}
@Override
- protected String getRootStyleClass(FacesBean bean)
+ protected String getRootStyleClass(
+ UIComponent component,
+ FacesBean bean)
{
return "af|inputListOfValues";
}
@Override
- protected String getContentStyleClass(FacesBean bean)
+ protected String getContentStyleClass(
+ UIComponent component,
+ FacesBean bean)
{
return "af|inputListOfValues::content";
}
@@ -401,9 +423,6 @@
static private final String _BUTTON_PART = "b";
static private final String _PART_PARAMETER = "part";
- static private final String _BUTTON_AND_PART_PARAMETER =
+ static private final String _BUTTON_AND_PART_PARAMETER =
_PART_PARAMETER + ":'" + _BUTTON_PART + "'";
-
-
-}
-
+}
\ No newline at end of file
Modified: myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputNumberSpinboxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputNumberSpinboxRenderer.java?rev=891522&r1=891521&r2=891522&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputNumberSpinboxRenderer.java (original)
+++ myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputNumberSpinboxRenderer.java Thu Dec 17 02:33:05 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,6 +30,7 @@
import org.apache.myfaces.trinidad.context.RenderingContext;
import org.apache.myfaces.trinidad.skin.Icon;
+
/**
* overrides SimpleInputListOfValuesRenderer because like that class,
* we need an 'icon' after the text field. --
@@ -42,21 +43,21 @@
this(CoreInputNumberSpinbox.TYPE);
}
- public SimpleInputNumberSpinboxRenderer(FacesBean.Type type)
+ public SimpleInputNumberSpinboxRenderer(
+ FacesBean.Type type)
{
super(type);
}
@Override
- protected void findTypeConstants(FacesBean.Type type)
+ protected void findTypeConstants(
+ FacesBean.Type type)
{
super.findTypeConstants(type);
_minimumKey = type.findKey("minimum");
_maximumKey = type.findKey("maximum");
_stepSizeKey = type.findKey("stepSize");
}
- //
-
//
// ENCODE BEHAVIOR
@@ -69,19 +70,24 @@
@Override
public boolean isTextArea(
- FacesBean bean)
+ UIComponent component,
+ FacesBean bean)
{
return false;
}
@Override
- protected boolean getSecret(FacesBean bean)
+ protected boolean getSecret(
+ UIComponent component,
+ FacesBean bean)
{
return false;
}
@Override
- protected Number getMaximumLength(FacesBean bean)
+ protected Number getMaximumLength(
+ UIComponent component,
+ FacesBean bean)
{
return null;
}
@@ -94,41 +100,47 @@
}
@Override
- protected String getRootStyleClass(FacesBean bean)
+ protected String getRootStyleClass(
+ UIComponent component,
+ FacesBean bean)
{
return "af|inputNumberSpinbox";
}
@Override
- protected String getContentStyleClass(FacesBean bean)
+ protected String getContentStyleClass(
+ UIComponent component,
+ FacesBean bean)
{
return "af|inputNumberSpinbox::content";
}
@Override
protected Integer getDefaultColumns(
- RenderingContext arc,
- FacesBean bean)
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean)
{
return _DEFAULT_COLUMNS;
}
@Override
protected void renderTextField(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
// render <table><tr><td>, then text field, </td>
ResponseWriter rw = context.getResponseWriter();
rw.startElement("table", component);
- OutputUtils.renderLayoutTableAttributes(context, arc, "0", "0", "0", null);
+ OutputUtils.renderLayoutTableAttributes(context, rc, "0", "0", "0", null);
rw.startElement("tr", component);
rw.startElement("td", component);
// this renders the inputText. This will call getContentStyleClass to put
// our styleclass on it. (af|inputNumberSpinbox::content)
- super.renderTextField(context, arc, component, bean);
+ super.renderTextField(context, rc, component, bean);
rw.endElement("td");
}
@@ -136,31 +148,30 @@
* render the spinboxes after the text field. Render these even if
* they are disabled.
* @param context
- * @param arc
+ * @param rc
* @param component
* @param bean
* @throws IOException
*/
@Override
protected void renderAfterTextField(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
- {
-
- ResponseWriter rw = context.getResponseWriter();
- rw.startElement("td", component);
- rw.writeAttribute("align", "center", null);
- rw.writeAttribute("valign", "middle", null);
-
- renderStyleClass(context, arc, "af|inputNumberSpinbox::spinbox-cell");
- // use css to put in a space.???
- renderIcon(context, arc, component, bean);
- rw.endElement("td");
- rw.endElement("tr");
- rw.endElement("table");
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
+ {
+ ResponseWriter rw = context.getResponseWriter();
+ rw.startElement("td", component);
+ rw.writeAttribute("align", "center", null);
+ rw.writeAttribute("valign", "middle", null);
+ renderStyleClass(context, rc, "af|inputNumberSpinbox::spinbox-cell");
+ // use css to put in a space.???
+ renderIcon(context, rc, component, bean);
+ rw.endElement("td");
+ rw.endElement("tr");
+ rw.endElement("table");
}
/**
@@ -168,22 +179,22 @@
*/
@Override
protected void renderIcon(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
ResponseWriter rw = context.getResponseWriter();
// render increment spinbox image
rw.startElement("div", component);
- _renderSpinboxIcon(context, arc, component, bean, rw, true);
+ _renderSpinboxIcon(context, rc, component, bean, rw, true);
rw.endElement("div");
// render decrement spinbox image
rw.startElement("div", component);
- _renderSpinboxIcon(context, arc, component, bean, rw, false);
+ _renderSpinboxIcon(context, rc, component, bean, rw, false);
rw.endElement("div");
-
}
/**
@@ -193,20 +204,21 @@
* value. If disabled, then do not render the <a> tags.
*/
private void _renderSpinboxIcon(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean,
- ResponseWriter rw,
- boolean increment) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean,
+ ResponseWriter rw,
+ boolean increment
+ ) throws IOException
{
- boolean disabled = getDisabled(bean);
+ boolean disabled = getDisabled(component, bean);
String styleClass =
(increment) ?
SkinSelectors.AF_INPUT_NUMBER_SPINBOX_INCREMENT_CELL :
SkinSelectors.AF_INPUT_NUMBER_SPINBOX_DECREMENT_CELL;
- renderStyleClass(context, arc, styleClass);
+ renderStyleClass(context, rc, styleClass);
String iconName;
@@ -225,7 +237,7 @@
SkinSelectors.AF_INPUT_NUMBER_SPINBOX_DECREMENT_DISABLED_ICON_NAME;
}
- Icon icon = arc.getIcon(iconName);
+ Icon icon = rc.getIcon(iconName);
if ((icon != null) && !icon.isNull())
{
// Render Link with onmousedown and onmouseup event handlers
@@ -251,7 +263,7 @@
altText = (increment) ? "increment" : "decrement";
else
altText = (increment) ? "increment disabled" : "decrement disabled";
- OutputUtils.renderIcon(context, arc, icon, altText, null);
+ OutputUtils.renderIcon(context, rc, icon, altText, null);
if (!disabled)
rw.endElement("a");
@@ -259,10 +271,10 @@
}
private String _getSpinboxScript(
- FacesContext context,
- UIComponent component,
- FacesBean bean,
- boolean increment)
+ FacesContext context,
+ UIComponent component,
+ FacesBean bean,
+ boolean increment)
{
StringBuffer js = new StringBuffer();
js.append(_SPINBOX_REPEAT_JS);
@@ -271,26 +283,30 @@
js.append("',");
js.append(increment);
js.append(",");
- js.append(_getStepSizeOrDefault(bean));
+ js.append(_getStepSizeOrDefault(component, bean));
js.append(",");
- js.append(_getMinimumOrDefault(bean));
+ js.append(_getMinimumOrDefault(component, bean));
js.append(",");
- js.append(_getMaximumOrDefault(bean));
+ js.append(_getMaximumOrDefault(component, bean));
js.append(");");
return js.toString();
}
- private int _getMinimumOrDefault(FacesBean bean)
- {
- Number minimum = (Number) bean.getProperty(_minimumKey);
- if (minimum == null)
- minimum = (Number)_minimumKey.getDefault();
- assert(minimum != null);
- return minimum.intValue();
+ private int _getMinimumOrDefault(
+ UIComponent component,
+ FacesBean bean)
+ {
+ Number minimum = (Number) bean.getProperty(_minimumKey);
+ if (minimum == null)
+ minimum = (Number)_minimumKey.getDefault();
+ assert(minimum != null);
+ return minimum.intValue();
}
- private int _getMaximumOrDefault(FacesBean bean)
+ private int _getMaximumOrDefault(
+ UIComponent component,
+ FacesBean bean)
{
Number maximum = (Number) bean.getProperty(_maximumKey);
if (maximum == null)
@@ -299,7 +315,9 @@
return maximum.intValue();
}
- private int _getStepSizeOrDefault(FacesBean bean)
+ private int _getStepSizeOrDefault(
+ UIComponent component,
+ FacesBean bean)
{
Number stepSize = (Number) bean.getProperty(_stepSizeKey);
if (stepSize == null)
@@ -312,9 +330,8 @@
private PropertyKey _maximumKey;
private PropertyKey _stepSizeKey;
-
private static String _SPINBOX_REPEAT_JS = "_spinboxRepeat";
private static String _CLEAR_SPINBOX_JS = "_clearSpinbox();";
-
+
private static Integer _DEFAULT_COLUMNS = Integer.valueOf(1);
}
Modified: myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputTextRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputTextRenderer.java?rev=891522&r1=891521&r2=891522&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputTextRenderer.java (original)
+++ myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleInputTextRenderer.java Thu Dec 17 02:33:05 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,12 +28,11 @@
import org.apache.myfaces.trinidad.bean.FacesBean;
import org.apache.myfaces.trinidad.bean.PropertyKey;
-
import org.apache.myfaces.trinidad.component.core.input.CoreInputText;
-
import org.apache.myfaces.trinidad.context.RenderingContext;
import org.apache.myfaces.trinidad.util.IntegerUtils;
+
/**
* @todo Do we need to incorporate bug 2669974???
*/
@@ -44,13 +43,15 @@
this(CoreInputText.TYPE);
}
- public SimpleInputTextRenderer(FacesBean.Type type)
+ public SimpleInputTextRenderer(
+ FacesBean.Type type)
{
super(type);
}
@Override
- protected void findTypeConstants(FacesBean.Type type)
+ protected void findTypeConstants(
+ FacesBean.Type type)
{
super.findTypeConstants(type);
_columnsKey = type.findKey("columns");
@@ -74,16 +75,16 @@
return submitted;
FacesBean bean = getFacesBean(component);
- if (getSecret(bean))
+ if (getSecret(component, bean))
{
if (XhtmlConstants.SECRET_FIELD_DEFAULT_VALUE.equals(submitted))
{
// if there was a previously submitted value then return it.
// otherwise, this will return null which means the value is unchanged.
- return getSubmittedValue(bean);
+ return getSubmittedValue(component, bean);
}
}
- else if (isTextArea(bean))
+ else if (isTextArea(component, bean))
{
submitted = _normalizeWhitespace((String) submitted);
}
@@ -93,41 +94,42 @@
@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 (isAutoSubmit(bean))
- AutoSubmitUtils.writeDependencies(context, arc);
+ if (isAutoSubmit(component, bean))
+ AutoSubmitUtils.writeDependencies(context, rc);
ResponseWriter rw = context.getResponseWriter();
- addOnSubmitConverterValidators(context, arc, component, bean);
+ addOnSubmitConverterValidators(context, rc, component, bean);
// if simple, render the root dom element and its style classes
- if (isSimpleInputText(bean))
+ if (isSimpleInputText(component, bean))
{
rw.startElement("span", component);
// put the outer style class here, like af_inputText, styleClass,
// inlineStyle, 'state' styles like p_AFDisabled, etc.
- renderRootDomElementStyles(context, arc, component, bean);
+ renderRootDomElementStyles(context, rc, component, bean);
}
-
- if (isTextArea(bean))
+
+ if (isTextArea(component, bean))
{
rw.startElement("textarea", component);
renderId(context, component);
- renderAllAttributes(context, arc, bean, false);
+ renderAllAttributes(context, rc, component, bean, false);
/* renderAsElement == true, isTextArea == true */
- renderContent(context, arc, component, bean, true, true);
+ renderContent(context, rc, component, bean, true, true);
rw.endElement("textarea");
}
else
{
rw.startElement("input", component);
renderId(context, component);
- renderAllAttributes(context, arc, bean, false);
+ renderAllAttributes(context, rc, component, bean, false);
String value = getConvertedString(context, component, bean);
- boolean secret = getSecret(bean);
+ boolean secret = getSecret(component, bean);
if (secret)
{
rw.writeAttribute("type", "password", "secret");
@@ -147,33 +149,34 @@
rw.endElement("input");
}
-
+
// see bug 2880407 we dont need to render hidden label when wrapped with
// fieldset and legend
- if (isHiddenLabelRequired(arc))
- renderShortDescAsHiddenLabel(context, arc, component, bean);
- if (isSimpleInputText(bean))
+ if (isHiddenLabelRequired(rc))
+ renderShortDescAsHiddenLabel(context, rc, component, bean);
+ if (isSimpleInputText(component, bean))
rw.endElement("span");
+ }
- }
-
@Override
protected void renderAllAttributes(
- FacesContext context,
- RenderingContext rc,
- FacesBean bean,
- boolean renderStyleAttrs) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean,
+ boolean renderStyleAttrs
+ ) throws IOException
{
- super.renderAllAttributes(context, rc, bean, false);
+ super.renderAllAttributes(context, rc, component, bean, false);
ResponseWriter rw = context.getResponseWriter();
- boolean isTextArea = isTextArea(bean);
- Object columns = getColumns(bean);
+ boolean isTextArea = isTextArea(component, bean);
+ Object columns = getColumns(component, bean);
if (columns == null)
{
- columns = getDefaultColumns(rc, bean);
+ columns = getDefaultColumns(rc, component, bean);
}
else
{
@@ -200,7 +203,7 @@
// element (because we're read-only or disabled)
if (isTextArea)
{
- Object rows = getRows(bean);
+ Object rows = getRows(component, bean);
if (rows == null)
rows = getDefaultRows();
else
@@ -218,10 +221,10 @@
}
rw.writeAttribute("rows", rows, "rows");
- rw.writeAttribute("wrap", getWrap(bean), "wrap");
+ rw.writeAttribute("wrap", getWrap(component, bean), "wrap");
// render the readonly attribute
- if ((getReadOnly(context, bean) ||
+ if ((getReadOnly(context, component, bean) ||
!supportsEditing(rc)) &&
supportsReadonlyFormElements(rc))
rw.writeAttribute("readonly", Boolean.TRUE, "readOnly");
@@ -232,22 +235,24 @@
if (supportsAutoCompleteFormElements(rc))
{
// TODO: check for CoreForm...
- String autocomplete = getAutoComplete(bean);
+ String autocomplete = getAutoComplete(component, bean);
if (autocomplete.equalsIgnoreCase(CoreInputText.AUTO_COMPLETE_OFF))
{
rw.writeAttribute("autocomplete", "off", "autoComplete");
}
}
-
- Number maximumLength = getMaximumLength(bean);
+
+ Number maximumLength = getMaximumLength(component, bean);
if(maximumLength != null && maximumLength.intValue()> 0)
rw.writeAttribute("maxlength", maximumLength, "maximumLength");
}
}
-
+
@Override
- protected String getRootStyleClass(FacesBean bean)
+ protected String getRootStyleClass(
+ UIComponent component,
+ FacesBean bean)
{
return "af|inputText";
}
@@ -267,9 +272,12 @@
* their own defaults.
* =-=AEW MOVE ONTO BEAN TYPE?
*/
- protected Integer getDefaultColumns(RenderingContext arc, FacesBean bean)
+ protected Integer getDefaultColumns(
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean)
{
- if (isPDA(arc))
+ if (isPDA(rc))
{
return _DEFAULT_PDA_COLUMNS;
}
@@ -282,42 +290,44 @@
return "text";
}
-
/**
* Renders event handlers for the node.
*/
@Override
protected void renderEventHandlers(
FacesContext context,
- FacesBean bean) throws IOException
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
- super.renderEventHandlers(context, bean);
+ super.renderEventHandlers(context, component, bean);
ResponseWriter rw = context.getResponseWriter();
- rw.writeAttribute("onselect", getOnselect(bean), "onselect");
- rw.writeAttribute("onpaste", getOnpaste(bean), "onpaste");
+ rw.writeAttribute("onselect", getOnselect(component, bean), "onselect");
+ rw.writeAttribute("onpaste", getOnpaste(component, bean), "onpaste");
}
@Override
protected void encodeAllAsNonElement(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
- if (isTextArea(bean))
+ if (isTextArea(component, bean))
{
/* renderAsElement == false, isTextArea == true */
- renderContent(context, arc, component, bean, false, true);
+ renderContent(context, rc, component, bean, false, true);
}
else
{
ResponseWriter rw = context.getResponseWriter();
- boolean isSimple = isSimpleInputText(bean);
+ boolean isSimple = isSimpleInputText(component, bean);
if (isSimple)
{
rw.startElement("span", component);
- renderRootDomElementStyles(context, arc, component, bean);
+ renderRootDomElementStyles(context, rc, component, bean);
renderId(context, component);
}
@@ -326,13 +336,13 @@
if (!isSimple)
renderId(context, component);
- renderStyleClass(context, arc, getContentStyleClass(bean));
- renderInlineStyleAttribute(context, arc, getContentStyle(bean));
- rw.writeAttribute("title", getShortDesc(bean), "shortDesc");
+ renderStyleClass(context, rc, getContentStyleClass(component, bean));
+ renderInlineStyleAttribute(context, rc, component, getContentStyle(component, bean));
+ rw.writeAttribute("title", getShortDesc(component, bean), "shortDesc");
/* renderAsElement == false, isTextArea == false */
- renderContent(context, arc, component, bean, false, false);
+ renderContent(context, rc, component, bean, false, false);
rw.endElement("div");
- if (isSimpleInputText(bean))
+ if (isSimpleInputText(component, bean))
rw.endElement("span");
}
}
@@ -343,22 +353,24 @@
*/
@Override
protected void renderNonElementContent(
- FacesContext context,
- RenderingContext arc,
- UIComponent component,
- FacesBean bean) throws IOException
+ FacesContext context,
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
// Verify that this hook isn't accidentally getting called.
throw new IllegalStateException("UNUSED");
}
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
{
// render the element text here
String textValue = getConvertedString(context, component, bean);
@@ -378,13 +390,14 @@
rw.startElement("pre", null);
renderId(context, component);
- rw.writeAttribute("title", getShortDesc(bean), "shortDesc");
+ rw.writeAttribute("title", getShortDesc(component, bean), "shortDesc");
// =-=AEW TEST STYLE ATTRIBUTE SUPPORT?
// if (supportsStyleAttributes(context) &&
// doRenderStyleAttrs(context, node))
{
- renderStyleAttributes(context, arc, bean, getContentStyleClass(bean));
+ renderStyleAttributes(context, rc, component, bean,
+ getContentStyleClass(component, bean));
}
// And, for a read-only text input - we also want to wrap
@@ -396,14 +409,14 @@
if (textLength > 0)
{
- Object wrap = getWrap(bean);
+ Object wrap = getWrap(component, bean);
// Only wrap if "wrap" is set to SOFT or HARD
if (CoreInputText.WRAP_SOFT.equals(wrap) ||
CoreInputText.WRAP_HARD.equals(wrap))
{
- Number columnsObj = getColumns(bean);
+ Number columnsObj = getColumns(component, bean);
if (columnsObj == null)
- columnsObj = getDefaultColumns(arc, bean);
+ columnsObj = getDefaultColumns(rc, component, bean);
int columns = ((columnsObj == null) ? 0 : columnsObj.intValue());
@@ -442,7 +455,7 @@
else
{
// Don't render anything for disabled password fields
- if (!getSecret(bean))
+ if (!getSecret(component, bean))
{
if (textValue != null)
rw.writeText(textValue, "value");
@@ -451,10 +464,11 @@
}
private void _writeTextWithBreaks(
- FacesContext context,
- BreakIterator breaks,
- String textString,
- int columns) throws IOException
+ FacesContext context,
+ BreakIterator breaks,
+ String textString,
+ int columns
+ ) throws IOException
{
int start = 0;
while (true)
@@ -478,10 +492,11 @@
}
private void _writeTextLineWithBreaks(
- FacesContext context,
- BreakIterator breaks,
- String textString,
- int columns) throws IOException
+ FacesContext context,
+ BreakIterator breaks,
+ String textString,
+ int columns
+ ) throws IOException
{
if (textString.length() < columns)
{
@@ -524,13 +539,13 @@
@Override
protected String getOnkeyup(
- FacesBean bean
- )
+ UIComponent component,
+ FacesBean bean)
{
- String onKeyUp = super.getOnkeyup(bean);
- if (isTextArea(bean))
+ String onKeyUp = super.getOnkeyup(component, bean);
+ if (isTextArea(component, bean))
{
- Number maximumLength = getMaximumLength(bean);
+ Number maximumLength = getMaximumLength(component, bean);
if(maximumLength != null && maximumLength.intValue()> 0)
{
onKeyUp = _getMaxLengthFunction(onKeyUp,
@@ -542,31 +557,34 @@
}
@Override
- protected String getOnkeydown(FacesBean bean)
+ protected String getOnkeydown(
+ UIComponent component,
+ FacesBean bean)
{
- String onKeydown = super.getOnkeydown(bean);
- if (getSecret(bean))
+ String onKeydown = super.getOnkeydown(component, bean);
+ if (getSecret(component, bean))
{
onKeydown = XhtmlUtils.getChainedJS(_SECRET_KEYDOWN_SCRIPT,
onKeydown, false);
}
-
+
return onKeydown;
}
-
/**
* @todo We have to "getCurrentInstance()" *twice*. UGH!
*/
@Override
- protected String getOnfocus(FacesBean bean)
+ protected String getOnfocus(
+ UIComponent component,
+ FacesBean bean)
{
- String onfocus = super.getOnfocus(bean);
+ String onfocus = super.getOnfocus(component, bean);
// If it's a read-only text area, and the agent doesn't actually
// support read-only text areas, then render an "onfocus" that
// redirects the user away from the field.
- if (isTextArea(bean) &&
- getReadOnly(FacesContext.getCurrentInstance(), bean))
+ if (isTextArea(component, bean) &&
+ getReadOnly(FacesContext.getCurrentInstance(), component, bean))
{
RenderingContext arc = RenderingContext.getCurrentInstance();
if (!supportsReadonlyFormElements(arc))
@@ -582,25 +600,26 @@
@Override
protected String getOnchange(
- FacesBean bean
- )
+ UIComponent component,
+ FacesBean bean)
{
- String onchange = super.getOnchange(bean);
- if (isAutoSubmit(bean))
+ String onchange = super.getOnchange(component, bean);
+ if (isAutoSubmit(component, bean))
{
- RenderingContext arc = RenderingContext.getCurrentInstance();
- String source = LabelAndMessageRenderer.__getCachedClientId(arc);
- boolean immediate = isImmediate(bean);
- String auto = AutoSubmitUtils.getSubmitScript(arc, source, XhtmlConstants.AUTOSUBMIT_EVENT, immediate);
+ RenderingContext rc = RenderingContext.getCurrentInstance();
+ String source = LabelAndMessageRenderer.__getCachedClientId(rc);
+ boolean immediate = isImmediate(component, bean);
+ String auto = AutoSubmitUtils.getSubmitScript(rc, source, XhtmlConstants.AUTOSUBMIT_EVENT,
+ immediate);
if (onchange == null)
onchange = auto;
else if (auto != null)
onchange = XhtmlUtils.getChainedJS(onchange, auto, true);
}
- if (isTextArea(bean))
+ if (isTextArea(component, bean))
{
- Number maxLength = getMaximumLength(bean);
+ Number maxLength = getMaximumLength(component, bean);
if (maxLength != null && maxLength.intValue()> 0)
{
onchange = _getMaxLengthFunction(onchange,
@@ -612,55 +631,68 @@
}
protected String getOnpaste(
- FacesBean bean
- )
+ UIComponent component,
+ FacesBean bean)
{
String onpaste = null;
- if (isTextArea(bean))
+ if (isTextArea(component, bean))
{
- Number maximumLength = getMaximumLength(bean);
+ Number maximumLength = getMaximumLength(component, bean);
if(maximumLength != null && maximumLength.intValue()> 0)
{
onpaste = _getMaxLengthFunction(null,
maximumLength.intValue());
}
}
- return onpaste;
+
+ return XhtmlUtils.getClientEventHandler(FacesContext.getCurrentInstance(), component,
+ "paste", null, null, onpaste);
}
protected String getOnselect(
- FacesBean bean
- )
+ UIComponent component,
+ FacesBean bean)
{
// Not all components that subclass selectInputText will
// necessarily have onselect
if (_onselectKey == null)
return null;
- return toString(bean.getProperty(_onselectKey));
+ return XhtmlUtils.getClientEventHandler(FacesContext.getCurrentInstance(), component,
+ "select", null, toString(bean.getProperty(_onselectKey)), null);
}
- protected Number getColumns(FacesBean bean)
+ protected Number getColumns(
+ UIComponent component,
+ FacesBean bean)
{
return (Number) bean.getProperty(_columnsKey);
}
- protected Number getRows(FacesBean bean)
+ protected Number getRows(
+ UIComponent component,
+ FacesBean bean)
{
return (Number) bean.getProperty(_rowsKey);
}
- protected Number getMaximumLength(FacesBean bean)
+ protected Number getMaximumLength(
+ UIComponent component,
+ FacesBean bean)
{
return (Number) bean.getProperty(_maximumLengthKey);
}
- protected Object getWrap(FacesBean bean)
+ protected Object getWrap(
+ UIComponent component,
+ FacesBean bean)
{
return bean.getProperty(_wrapKey);
}
- protected boolean getSecret(FacesBean bean)
+ protected boolean getSecret(
+ UIComponent component,
+ FacesBean bean)
{
Object o = bean.getProperty(_secretKey);
if (o == null)
@@ -669,26 +701,13 @@
return !Boolean.FALSE.equals(o);
}
- /**
- * @todo - Find a efficient way to identify that this is a numeric field
- */
- //-= Simon Lessard =-
- //TODO: This method is not even used locally
- @SuppressWarnings("unused")
- private boolean _isNumericField(
-// FacesBean bean
- )
- {
- return false;
- }
-
-
// map this node to <input type="text"> or <textarea>?
public boolean isTextArea(
- FacesBean bean)
+ UIComponent component,
+ FacesBean bean)
{
// if the node has rows > 1, it's a textarea
- Number rows = getRows(bean);
+ Number rows = getRows(component, bean);
if ((rows != null) && (rows.intValue() > 1))
return true;
@@ -700,16 +719,17 @@
*/
@Override
protected boolean renderReadOnlyAsElement(
- RenderingContext arc,
- FacesBean bean)
+ RenderingContext rc,
+ UIComponent component,
+ FacesBean bean)
{
// We render read-only single-line input fields as plain text
- if (!isTextArea(bean))
+ if (!isTextArea(component, bean))
return false;
// Otherwise, if we can render "readonly" on this platform,
// do it.
- if (supportsReadonlyFormElements(arc))
+ if (supportsReadonlyFormElements(rc))
return true;
// But otherwise, if we support scripting, we'll use a little
@@ -724,7 +744,9 @@
return false;
}
- protected String getAutoComplete(FacesBean bean)
+ protected String getAutoComplete(
+ UIComponent component,
+ FacesBean bean)
{
Object o = bean.getProperty(_autoCompleteKey);
if (o == null)
@@ -736,9 +758,11 @@
* Is this a simple input text component? We need to know so that subclasses
* that contain a inputText won't wrap the input in a span.
*/
- protected boolean isSimpleInputText(FacesBean bean)
+ protected boolean isSimpleInputText(
+ UIComponent component,
+ FacesBean bean)
{
- return getSimple(bean);
+ return getSimple(component, bean);
}
static private String _getMaxLengthFunction(
@@ -760,7 +784,8 @@
* Browsers can submit all sorts of whitespace endings.
* Transform anything we see into a plain "\n".
*/
- static private final String _normalizeWhitespace(String str)
+ static private final String _normalizeWhitespace(
+ String str)
{
int from = 0;
int length = str.length();
@@ -809,8 +834,6 @@
return buffer.toString();
}
-
-
private PropertyKey _columnsKey;
private PropertyKey _rowsKey;
private PropertyKey _wrapKey;
@@ -821,7 +844,7 @@
static private final Integer _DEFAULT_PDA_COLUMNS = Integer.valueOf(11);
static private final Integer _DEFAULT_COLUMNS = Integer.valueOf(30);
- static private final String _SECRET_KEYDOWN_SCRIPT =
+ static private final String _SECRET_KEYDOWN_SCRIPT =
"return _clearPassword(this, event);";
static private final int _MAX_COLUMNS = 500;
static private final int _MAX_ROWS = 500;
Modified: myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleSelectBooleanCheckboxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleSelectBooleanCheckboxRenderer.java?rev=891522&r1=891521&r2=891522&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleSelectBooleanCheckboxRenderer.java (original)
+++ myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleSelectBooleanCheckboxRenderer.java Thu Dec 17 02:33:05 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,6 +25,7 @@
import org.apache.myfaces.trinidad.component.core.input.CoreSelectBooleanCheckbox;
import org.apache.myfaces.trinidad.context.RenderingContext;
+
/**
*/
public class SimpleSelectBooleanCheckboxRenderer extends SimpleSelectBooleanRenderer
@@ -34,15 +35,16 @@
this(CoreSelectBooleanCheckbox.TYPE);
}
- public SimpleSelectBooleanCheckboxRenderer(FacesBean.Type type)
+ public SimpleSelectBooleanCheckboxRenderer(
+ FacesBean.Type type)
{
super(type);
}
-
+
//**********************
//decode
//**********************
-
+
@Override
protected Object getSubmittedValue(
FacesContext context,
@@ -55,13 +57,14 @@
return Boolean.TRUE;
}
-
+
//**********************
//encode
//**********************
@Override
- protected Object getValueAttr(RenderingContext arc)
+ protected Object getValueAttr(
+ RenderingContext rc)
{
// HTML 3.2 specification, default value for checkboxes
return "t";
@@ -79,10 +82,10 @@
)
{
return (selected
- ? "af_selectBooleanCheckbox.READONLY_CHECKED_TIP"
+ ? "af_selectBooleanCheckbox.READONLY_CHECKED_TIP"
: "af_selectBooleanCheckbox.READONLY_NOT_CHECKED_TIP");
}
-
+
@Override
protected String getIconName(
boolean selected,
@@ -92,29 +95,29 @@
final String iconName;
if (disabled)
{
- iconName = (selected ?
- SkinSelectors.AF_SELECT_BOOLEAN_CHECKBOX_DISABLED_CHECKED_ICON_NAME :
+ iconName = (selected ?
+ SkinSelectors.AF_SELECT_BOOLEAN_CHECKBOX_DISABLED_CHECKED_ICON_NAME :
SkinSelectors.AF_SELECT_BOOLEAN_CHECKBOX_DISABLED_UNCHECKED_ICON_NAME);
}
else
{
- iconName = (selected ?
- SkinSelectors.AF_SELECT_BOOLEAN_CHECKBOX_READONLY_CHECKED_ICON_NAME :
+ iconName = (selected ?
+ SkinSelectors.AF_SELECT_BOOLEAN_CHECKBOX_READONLY_CHECKED_ICON_NAME :
SkinSelectors.AF_SELECT_BOOLEAN_CHECKBOX_READONLY_UNCHECKED_ICON_NAME);
}
-
- return iconName;
+
+ return iconName;
}
-
+
@Override
protected String getOnclick(
- FacesBean bean
- )
+ UIComponent component,
+ FacesBean bean)
{
- String onClick = super.getOnclick(bean);
- if (isAutoSubmit(bean))
+ String onClick = super.getOnclick(component, bean);
+ if (isAutoSubmit(component, bean))
{
- String auto = getAutoSubmitScript(bean);
+ String auto = getAutoSubmitScript(component, bean);
if (onClick == null)
onClick = auto;
else if (auto != null)
@@ -122,17 +125,21 @@
}
return onClick;
- }
-
+ }
+
@Override
- protected String getContentStyleClass(FacesBean bean)
+ protected String getContentStyleClass(
+ UIComponent component,
+ FacesBean bean)
{
return "af|selectBooleanCheckbox::content";
}
-
+
@Override
- protected String getRootStyleClass(FacesBean bean)
+ protected String getRootStyleClass(
+ UIComponent component,
+ FacesBean bean)
{
return "af|selectBooleanCheckbox";
- }
-}
+ }
+}
\ No newline at end of file
Modified: myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleSelectBooleanRadioRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleSelectBooleanRadioRenderer.java?rev=891522&r1=891521&r2=891522&view=diff
==============================================================================
--- myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleSelectBooleanRadioRenderer.java (original)
+++ myfaces/trinidad/branches/trinidad-2.0.x/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/SimpleSelectBooleanRadioRenderer.java Thu Dec 17 02:33:05 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,15 +19,17 @@
package org.apache.myfaces.trinidadinternal.renderkit.core.xhtml;
import java.io.IOException;
+
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-
import javax.faces.context.ResponseWriter;
+
import org.apache.myfaces.trinidad.bean.FacesBean;
import org.apache.myfaces.trinidad.bean.PropertyKey;
import org.apache.myfaces.trinidad.component.core.input.CoreSelectBooleanRadio;
import org.apache.myfaces.trinidad.context.RenderingContext;
+
/**
*/
public class SimpleSelectBooleanRadioRenderer extends SimpleSelectBooleanRenderer
@@ -37,22 +39,24 @@
this(CoreSelectBooleanRadio.TYPE);
}
- public SimpleSelectBooleanRadioRenderer(FacesBean.Type type)
+ public SimpleSelectBooleanRadioRenderer(
+ FacesBean.Type type)
{
super(type);
}
-
+
@Override
- protected void findTypeConstants(FacesBean.Type type)
+ protected void findTypeConstants(
+ FacesBean.Type type)
{
super.findTypeConstants(type);
_groupKey = type.findKey("group");
}
-
+
//**********************
//decode
//**********************
-
+
@Override
public Object getSubmittedValue(
FacesContext context,
@@ -71,19 +75,19 @@
if (clientId.equals(newValue))
return Boolean.TRUE;
}
-
+
return Boolean.FALSE;
}
-
//**********************
//encode
//**********************
@Override
- protected Object getValueAttr(RenderingContext arc)
+ protected Object getValueAttr(
+ RenderingContext rc)
{
- return arc.getCurrentClientId();
+ return rc.getCurrentClientId();
}
@Override
@@ -98,10 +102,10 @@
)
{
return (selected
- ? "af_selectBooleanRadio.READONLY_CHECKED_TIP"
+ ? "af_selectBooleanRadio.READONLY_CHECKED_TIP"
: "af_selectBooleanRadio.READONLY_NOT_CHECKED_TIP");
}
-
+
@Override
protected String getIconName(
boolean selected,
@@ -112,18 +116,18 @@
if (disabled)
{
- iconName = (selected ?
- SkinSelectors.AF_SELECT_BOOLEAN_RADIO_DISABLED_SELECTED_ICON_NAME :
+ iconName = (selected ?
+ SkinSelectors.AF_SELECT_BOOLEAN_RADIO_DISABLED_SELECTED_ICON_NAME :
SkinSelectors.AF_SELECT_BOOLEAN_RADIO_DISABLED_UNSELECTED_ICON_NAME);
}
else
{
- iconName = (selected ?
- SkinSelectors.AF_SELECT_BOOLEAN_RADIO_READONLY_SELECTED_ICON_NAME :
+ iconName = (selected ?
+ SkinSelectors.AF_SELECT_BOOLEAN_RADIO_READONLY_SELECTED_ICON_NAME :
SkinSelectors.AF_SELECT_BOOLEAN_RADIO_READONLY_UNSELECTED_ICON_NAME);
}
-
- return iconName;
+
+ return iconName;
}
@Override
@@ -152,7 +156,7 @@
{
return false;
}
-
+
@Override
protected boolean isRadio()
{
@@ -160,90 +164,99 @@
}
@Override
- protected String getCompositeId(String clientId)
+ protected String getCompositeId(
+ String clientId)
{
- return clientId + XhtmlConstants.COMPOSITE_ID_EXTENSION + "r";
+ return clientId + XhtmlConstants.COMPOSITE_ID_EXTENSION + "r";
}
-
+
@Override
protected void renderSpanEventHandlers(
- FacesContext context,
- FacesBean bean) throws IOException
+ FacesContext context,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
ResponseWriter rw = context.getResponseWriter();
-
- // PH: This condition is needed to set onclick on radio rather than on
- // enclosing span in an IE Mobile and PIE since these browsers don't have
- // onclick support on a span.
-
+
+ // PH: This condition is needed to set onclick on radio rather than on
+ // enclosing span in an IE Mobile and PIE since these browsers don't have
+ // onclick support on a span.
+
if(!isPDA(RenderingContext.getCurrentInstance()))
{
- if ( isAutoSubmit(bean))
- rw.writeAttribute("onclick", getAutoSubmitScript(bean) , null);
+ if ( isAutoSubmit(component, bean))
+ rw.writeAttribute("onclick", getAutoSubmitScript(component, bean) , null);
}
- rw.writeAttribute("ondblclick", getOndblclick(bean), "ondblclick");
- rw.writeAttribute("onkeydown", getOnkeydown(bean), "onkeydown");
- rw.writeAttribute("onkeyup", getOnkeyup(bean), "onkeyup");
- rw.writeAttribute("onkeypress", getOnkeypress(bean), "onkeypress");
- rw.writeAttribute("onmousedown", getOnmousedown(bean), "onmousedown");
- rw.writeAttribute("onmousemove", getOnmousemove(bean), "onmousemove");
- rw.writeAttribute("onmouseout", getOnmouseout(bean), "onmouseout");
- rw.writeAttribute("onmouseover", getOnmouseover(bean), "onmouseover");
- rw.writeAttribute("onmouseup", getOnmouseup(bean), "onmouseup");
+ rw.writeAttribute("ondblclick", getOndblclick(component, bean), "ondblclick");
+ rw.writeAttribute("onkeydown", getOnkeydown(component, bean), "onkeydown");
+ rw.writeAttribute("onkeyup", getOnkeyup(component, bean), "onkeyup");
+ rw.writeAttribute("onkeypress", getOnkeypress(component, bean), "onkeypress");
+ rw.writeAttribute("onmousedown", getOnmousedown(component, bean), "onmousedown");
+ rw.writeAttribute("onmousemove", getOnmousemove(component, bean), "onmousemove");
+ rw.writeAttribute("onmouseout", getOnmouseout(component, bean), "onmouseout");
+ rw.writeAttribute("onmouseover", getOnmouseover(component, bean), "onmouseover");
+ rw.writeAttribute("onmouseup", getOnmouseup(component, bean), "onmouseup");
}
-
+
@Override
protected void renderInputEventHandlers(
- FacesContext context,
- FacesBean bean) throws IOException
+ FacesContext context,
+ UIComponent component,
+ FacesBean bean
+ ) throws IOException
{
ResponseWriter writer = context.getResponseWriter();
- String onClick = getOnclick(bean);
-
- //PH: this condition is needed to set onclick on radio rather than on
- // enclosing span in an IE Mobile and PIE since these browsers don't have
- // onclick support on a span.
+ String onClick = getOnclick(component, bean);
+
+ //PH: this condition is needed to set onclick on radio rather than on
+ // enclosing span in an IE Mobile and PIE since these browsers don't have
+ // onclick support on a span.
if(isPDA(RenderingContext.getCurrentInstance()))
- {
- if ( isAutoSubmit(bean))
- {
- String auto = getAutoSubmitScript(bean);
-
+ {
+ if (isAutoSubmit(component, bean))
+ {
+ String auto = getAutoSubmitScript(component, bean);
+
if (onClick == null)
{
onClick = auto;
}
else
{
- // Since we have both onClick script and autosubmit script to execute,
+ // Since we have both onClick script and autosubmit script to execute,
// we need to chain the execution of these scripts.
onClick = XhtmlUtils.getChainedJS(onClick, auto, true);
}
}
}
-
+
writer.writeAttribute("onclick", onClick, "onclick");
- writer.writeAttribute("onblur", getOnblur(bean), "onblur");
- writer.writeAttribute("onfocus", getOnfocus(bean), "onfocus");
- writer.writeAttribute("onchange", getOnchange(bean), "onchange");
+ writer.writeAttribute("onblur", getOnblur(component, bean), "onblur");
+ writer.writeAttribute("onfocus", getOnfocus(component, bean), "onfocus");
+ writer.writeAttribute("onchange", getOnchange(component, bean), "onchange");
}
-
+
protected String getGroup(FacesBean bean)
{
return toString(bean.getProperty(_groupKey));
}
-
+
@Override
- protected String getContentStyleClass(FacesBean bean)
+ protected String getContentStyleClass(
+ UIComponent component,
+ FacesBean bean)
{
return "af|selectBooleanRadio::content";
}
-
+
@Override
- protected String getRootStyleClass(FacesBean bean)
+ protected String getRootStyleClass(
+ UIComponent component,
+ FacesBean bean)
{
return "af|selectBooleanRadio";
}
-
+
private PropertyKey _groupKey;
}