You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mm...@apache.org on 2005/05/16 02:44:39 UTC
svn commit: r170291 - in /myfaces/trunk: build/develop/ conf/
src/components/org/apache/myfaces/renderkit/html/ext/
src/share/org/apache/myfaces/renderkit/html/ tlds/ webapps/examples/
Author: mmarinschek
Date: Sun May 15 17:44:39 2005
New Revision: 170291
URL: http://svn.apache.org/viewcvs?rev=170291&view=rev
Log:
Promoted several components to extended state.
Implemented displayValueOnly-attributes - except for panel-grid
Modified:
myfaces/trunk/build/develop/build.xml
myfaces/trunk/conf/faces-config.xml
myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlCheckboxRenderer.java
myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlListboxRenderer.java
myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlMenuRenderer.java
myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlRadioRenderer.java
myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlTextRenderer.java
myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlTextareaRenderer.java
myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HtmlRadioRendererBase.java
myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HtmlRendererUtils.java
myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HtmlTextareaRendererBase.java
myfaces/trunk/tlds/myfaces_ext.tld
myfaces/trunk/tlds/myfaces_html.tld
myfaces/trunk/webapps/examples/sample2.jsp
Modified: myfaces/trunk/build/develop/build.xml
URL: http://svn.apache.org/viewcvs/myfaces/trunk/build/develop/build.xml?rev=170291&r1=170290&r2=170291&view=diff
==============================================================================
--- myfaces/trunk/build/develop/build.xml (original)
+++ myfaces/trunk/build/develop/build.xml Sun May 15 17:44:39 2005
@@ -92,10 +92,10 @@
<copy todir="${web-inf.lib.dir}">
<fileset file="${jstl.jar}"/>
- <fileset file="${jsp-2.0.jar}"/>
+ <!--fileset file="${jsp-2.0.jar}"/-->
<fileset file="${commons-codec.jar}"/>
<fileset file="${commons-logging.jar}"/>
- <fileset file="${commons-el.jar}"/>
+ <!--fileset file="${commons-el.jar}"/-->
<fileset file="${log4j.jar}"/>
<fileset file="${commons-fileupload.jar}"/>
<fileset file="${commons-validator.jar}"/>
Modified: myfaces/trunk/conf/faces-config.xml
URL: http://svn.apache.org/viewcvs/myfaces/trunk/conf/faces-config.xml?rev=170291&r1=170290&r2=170291&view=diff
==============================================================================
--- myfaces/trunk/conf/faces-config.xml (original)
+++ myfaces/trunk/conf/faces-config.xml Sun May 15 17:44:39 2005
@@ -84,6 +84,31 @@
</component>
<component>
+ <component-type>org.apache.myfaces.HtmlSelectBooleanCheckbox</component-type>
+ <component-class>org.apache.myfaces.component.html.ext.HtmlSelectBooleanCheckbox</component-class>
+ </component>
+
+ <component>
+ <component-type>org.apache.myfaces.HtmlSelectManyCheckbox</component-type>
+ <component-class>org.apache.myfaces.component.html.ext.HtmlSelectManyCheckbox</component-class>
+ </component>
+
+ <component>
+ <component-type>org.apache.myfaces.HtmlSelectManyListbox</component-type>
+ <component-class>org.apache.myfaces.component.html.ext.HtmlSelectManyListbox</component-class>
+ </component>
+
+ <component>
+ <component-type>org.apache.myfaces.HtmlSelectManyMenu</component-type>
+ <component-class>org.apache.myfaces.component.html.ext.HtmlSelectManyMenu</component-class>
+ </component>
+
+ <component>
+ <component-type>org.apache.myfaces.HtmlSelectOneListbox</component-type>
+ <component-class>org.apache.myfaces.component.html.ext.HtmlSelectOneListbox</component-class>
+ </component>
+
+ <component>
<component-type>org.apache.myfaces.HtmlSelectOneMenu</component-type>
<component-class>org.apache.myfaces.component.html.ext.HtmlSelectOneMenu</component-class>
</component>
@@ -93,10 +118,6 @@
<component-class>org.apache.myfaces.component.html.ext.HtmlSelectOneRadio</component-class>
</component>
- <component>
- <component-type>org.apache.myfaces.HtmlSelectManyCheckbox</component-type>
- <component-class>org.apache.myfaces.component.html.ext.HtmlSelectManyCheckbox</component-class>
- </component>
<!-- MyFaces custom components (in alphabetical order) -->
@@ -379,6 +400,12 @@
</renderer>
<renderer>
+ <component-family>javax.faces.SelectBoolean</component-family>
+ <renderer-type>org.apache.myfaces.Checkbox</renderer-type>
+ <renderer-class>org.apache.myfaces.renderkit.html.ext.HtmlCheckboxRenderer</renderer-class>
+ </renderer>
+
+ <renderer>
<component-family>javax.faces.SelectMany</component-family>
<renderer-type>org.apache.myfaces.Checkbox</renderer-type>
<renderer-class>org.apache.myfaces.renderkit.html.ext.HtmlCheckboxRenderer</renderer-class>
@@ -388,6 +415,24 @@
<component-family>javax.faces.SelectOne</component-family>
<renderer-type>org.apache.myfaces.Menu</renderer-type>
<renderer-class>org.apache.myfaces.renderkit.html.ext.HtmlMenuRenderer</renderer-class>
+ </renderer>
+
+ <renderer>
+ <component-family>javax.faces.SelectMany</component-family>
+ <renderer-type>org.apache.myfaces.Menu</renderer-type>
+ <renderer-class>org.apache.myfaces.renderkit.html.ext.HtmlMenuRenderer</renderer-class>
+ </renderer>
+
+ <renderer>
+ <component-family>javax.faces.SelectOne</component-family>
+ <renderer-type>org.apache.myfaces.Listbox</renderer-type>
+ <renderer-class>org.apache.myfaces.renderkit.html.ext.HtmlListboxRenderer</renderer-class>
+ </renderer>
+
+ <renderer>
+ <component-family>javax.faces.SelectMany</component-family>
+ <renderer-type>org.apache.myfaces.Listbox</renderer-type>
+ <renderer-class>org.apache.myfaces.renderkit.html.ext.HtmlListboxRenderer</renderer-class>
</renderer>
<renderer>
Modified: myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlCheckboxRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlCheckboxRenderer.java?rev=170291&r1=170290&r2=170291&view=diff
==============================================================================
--- myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlCheckboxRenderer.java (original)
+++ myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlCheckboxRenderer.java Sun May 15 17:44:39 2005
@@ -16,12 +16,10 @@
package org.apache.myfaces.renderkit.html.ext;
import org.apache.myfaces.component.UserRoleUtils;
-import org.apache.myfaces.component.html.ext.HtmlSelectManyCheckbox;
+import org.apache.myfaces.component.DisplayValueOnlyCapable;
import org.apache.myfaces.custom.checkbox.HtmlCheckbox;
import org.apache.myfaces.renderkit.RendererUtils;
-import org.apache.myfaces.renderkit.JSFAttr;
import org.apache.myfaces.renderkit.html.HtmlCheckboxRendererBase;
-import org.apache.myfaces.renderkit.html.HTML;
import org.apache.myfaces.renderkit.html.HtmlRendererUtils;
import javax.faces.FacesException;
@@ -29,13 +27,11 @@
import javax.faces.component.UISelectMany;
import javax.faces.component.UISelectBoolean;
import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
import javax.faces.model.SelectItem;
import java.io.IOException;
import java.util.List;
import java.util.Set;
-import java.util.Iterator;
/**
@@ -47,12 +43,6 @@
{
//private static final Log log = LogFactory.getLog(HtmlRadioRenderer.class);
- private static final String PAGE_DIRECTION = "pageDirection";
-
- private static final String LINE_DIRECTION = "lineDirection";
-
- private static final String EXTERNAL_TRUE_VALUE = "true";
-
private static final String LAYOUT_SPREAD = "spread";
public void encodeEnd(FacesContext context, UIComponent component) throws IOException
@@ -64,6 +54,10 @@
{
renderSingleCheckbox(context, (HtmlCheckbox)component);
}
+ else if (component instanceof DisplayValueOnlyCapable && ((DisplayValueOnlyCapable) component).isDisplayValueOnly())
+ {
+ HtmlRendererUtils.renderDisplayValueOnly(context, component);
+ }
else if (component instanceof UISelectMany)
{
String layout = getLayout((UISelectMany)component);
@@ -73,144 +67,17 @@
}
else
{
- //super.encodeEnd(context, component);
- chooseRenderMode(context, component);
+ super.encodeEnd(context, component);
}
}
- else
- {
- throw new IllegalArgumentException("Unsupported component class " + component.getClass().getName());
- }
- }
-
- private void chooseRenderMode(FacesContext facesContext, UIComponent uiComponent)
- throws IOException
- {
- RendererUtils.checkParamValidity(facesContext, uiComponent, null);
- if (uiComponent instanceof UISelectBoolean)
- {
- Boolean value = RendererUtils.getBooleanValue( uiComponent );
- boolean isChecked = value != null ? value.booleanValue() : false;
- renderCheckbox(facesContext, uiComponent, EXTERNAL_TRUE_VALUE,
- null, isChecked, true);
- }
- else if (uiComponent instanceof UISelectMany)
+ else if(component instanceof UISelectBoolean)
{
- renderCheckboxList(facesContext, (UISelectMany) uiComponent);
+ super.encodeEnd(context,component);
}
else
{
- throw new IllegalArgumentException("Unsupported component class "
- + uiComponent.getClass().getName());
- }
- }
-
- public void renderCheckboxList(FacesContext facesContext,
- UISelectMany selectMany) throws IOException
- {
-
- String layout = getLayout(selectMany);
- boolean pageDirectionLayout = false; //Default to lineDirection
- if (layout != null)
- {
- if (layout.equals(PAGE_DIRECTION))
- {
- pageDirectionLayout = true;
- }
- else if (layout.equals(LINE_DIRECTION))
- {
- pageDirectionLayout = false;
- }
- //else
- //{
- // log.error("Wrong layout attribute for component "
- // + selectMany.getClientId(facesContext) + ": " + layout);
- //}
- }
-
- ResponseWriter writer = facesContext.getResponseWriter();
-
- writer.startElement(HTML.TABLE_ELEM, selectMany);
- HtmlRendererUtils.renderHTMLAttributes(writer, selectMany,
- HTML.SELECT_TABLE_PASSTHROUGH_ATTRIBUTES);
- HtmlRendererUtils.writeIdIfNecessary(writer, selectMany, facesContext);
-
- if (!pageDirectionLayout)
- writer.startElement(HTML.TR_ELEM, selectMany);
-
- Converter converter;
- try
- {
- converter = RendererUtils.findUISelectManyConverter(facesContext,
- selectMany);
- }
- catch (FacesException e)
- {
- //log.error("Error finding Converter for component with id "
- // + selectMany.getClientId(facesContext));
- converter = null;
- }
-
- Set lookupSet = RendererUtils.getSubmittedValuesAsSet(facesContext, selectMany, converter, selectMany);
- boolean useSubmittedValues = lookupSet != null;
-
- if (!useSubmittedValues) {
- lookupSet = RendererUtils.getSelectedValuesAsSet(facesContext, selectMany, converter, selectMany);
- }
-
- for (Iterator it = RendererUtils.getSelectItemList(selectMany)
- .iterator(); it.hasNext();) {
- SelectItem selectItem = (SelectItem) it.next();
- Object itemValue = selectItem.getValue(); // TODO : Check here for getSubmittedValue. Look at RendererUtils.getValue
-
- String itemStrValue;
- if (converter == null) {
- itemStrValue = itemValue.toString();
- } else {
- itemStrValue = converter.getAsString(facesContext, selectMany,
- itemValue);
- }
-
- writer.write("\t\t");
- if (pageDirectionLayout)
- writer.startElement(HTML.TR_ELEM, selectMany);
- writer.startElement(HTML.TD_ELEM, selectMany);
- writer.startElement(HTML.LABEL_ELEM, selectMany);
-
- boolean checked = (useSubmittedValues && lookupSet
- .contains(itemStrValue))
- || (!useSubmittedValues && lookupSet.contains(itemValue));
-
- if(selectMany instanceof HtmlSelectManyCheckbox)
- {
- if(((HtmlSelectManyCheckbox)selectMany).isDisplayValueOnly())
- {
- renderCheckboxValueOnly(facesContext,
- (HtmlSelectManyCheckbox)selectMany,
- itemStrValue,
- selectItem.getLabel(),
- lookupSet.contains(itemStrValue),
- true);
- }
- else
- {
- renderCheckbox(facesContext,
- selectMany,
- itemStrValue,
- selectItem.getLabel(),
- checked,
- false);
- }
- }
- writer.endElement(HTML.LABEL_ELEM);
- writer.endElement(HTML.TD_ELEM);
- if (pageDirectionLayout)
- writer.endElement(HTML.TR_ELEM);
+ throw new IllegalArgumentException("Unsupported component class " + component.getClass().getName());
}
-
- if (!pageDirectionLayout)
- writer.endElement(HTML.TR_ELEM);
- writer.endElement(HTML.TABLE_ELEM);
}
private void renderSingleCheckbox(FacesContext facesContext, HtmlCheckbox checkbox) throws IOException
@@ -268,124 +135,13 @@
//TODO: we must cache this Set!
Set lookupSet = RendererUtils.getSelectedValuesAsSet(facesContext, uiComponent, converter, uiSelectMany);
- if(uiSelectMany instanceof HtmlSelectManyCheckbox &&
- ((HtmlSelectManyCheckbox)uiSelectMany).isDisplayValueOnly())
- {
- renderCheckboxValueOnly(facesContext,
- (HtmlSelectManyCheckbox)uiSelectMany,
- itemStrValue,
- selectItem.getLabel(),
- lookupSet.contains(itemStrValue),
- true);
- }
- else
- {
- renderCheckbox(facesContext,
- uiSelectMany,
- itemStrValue,
- selectItem.getLabel(),
- lookupSet.contains(itemStrValue),
- true);
- }
+ renderCheckbox(facesContext,
+ uiSelectMany,
+ itemStrValue,
+ selectItem.getLabel(),
+ lookupSet.contains(itemStrValue), true);
}
- protected void renderCheckboxValueOnly(FacesContext facesContext,
- HtmlSelectManyCheckbox checkbox,
- String value,
- String label,
- boolean checked,
- boolean renderId)
- throws IOException
- {
- String clientId = checkbox.getClientId(facesContext);
-
- ResponseWriter writer = facesContext.getResponseWriter();
-
- writer.startElement(HTML.SPAN_ELEM, checkbox);
- writer.writeAttribute(HTML.NAME_ATTR, clientId, null);
- if (renderId)
- {
- HtmlRendererUtils.writeIdIfNecessary(writer, checkbox, facesContext);
- }
-
- if (checked)
- {
- writer.writeAttribute(HTML.CHECKED_ATTR, HTML.CHECKED_ATTR, null);
- }
-
-// if ((value != null) && (value.length() > 0))
-// {
-// writer.writeAttribute(HTML.VALUE_ATTR, value, null);
-// }
-
- HtmlRendererUtils.renderHTMLAttributes(writer, checkbox,
- HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
-
- if(checkbox.getDisplayValueOnlyStyle() != null)
- writer.writeAttribute(HTML.STYLE_ATTR, checkbox.getDisplayValueOnlyStyle(), null);
- if(checkbox.getDisplayValueOnlyStyleClass() != null)
- writer.writeAttribute(HTML.STYLE_CLASS_ATTR, checkbox.getDisplayValueOnlyStyleClass(), null);
-
- String strValue = RendererUtils.getStringValue(facesContext, checkbox);
- writer.writeText(strValue, JSFAttr.VALUE_ATTR);
- //writer.writeText("", null); // close input
- if ((label != null) && (label.length() > 0))
- {
- writer.write(HTML.NBSP_ENTITY);
- writer.writeText(label, null);
- }
- //writer.endElement(HTML.SPAN_ELEM);
- }
-
- protected void renderCheckbox(FacesContext facesContext,
- HtmlSelectManyCheckbox checkbox,
- String value,
- String label,
- boolean checked,
- boolean renderId)
- throws IOException
- {
- String clientId = checkbox.getClientId(facesContext);
-
- ResponseWriter writer = facesContext.getResponseWriter();
-
- writer.startElement(HTML.INPUT_ELEM, checkbox);
- writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_CHECKBOX, null);
- writer.writeAttribute(HTML.NAME_ATTR, clientId, null);
- if (renderId)
- {
- HtmlRendererUtils.writeIdIfNecessary(writer, checkbox, facesContext);
- }
-
- if (checked)
- {
- writer.writeAttribute(HTML.CHECKED_ATTR, HTML.CHECKED_ATTR, null);
- }
-
- if ((value != null) && (value.length() > 0))
- {
- writer.writeAttribute(HTML.VALUE_ATTR, value, null);
- }
-
- HtmlRendererUtils.renderHTMLAttributes(writer, checkbox,
- HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
-
- if(checkbox.getStyle() != null)
- writer.writeAttribute(HTML.STYLE_ATTR, checkbox.getStyle(), null);
- if(checkbox.getStyleClass() != null)
- writer.writeAttribute(HTML.STYLE_CLASS_ATTR, checkbox.getStyleClass(), null);
-
- if (isDisabled(facesContext, checkbox))
- {
- writer.writeAttribute(HTML.DISABLED_ATTR, Boolean.TRUE, null);
- }
- writer.writeText("", null); // close input
- if ((label != null) && (label.length() > 0))
- {
- writer.write(HTML.NBSP_ENTITY);
- writer.writeText(label, null);
- }
- }
protected boolean isDisabled(FacesContext facesContext, UIComponent uiComponent)
{
@@ -398,7 +154,6 @@
return super.isDisabled(facesContext, uiComponent);
}
}
-
public void decode(FacesContext facesContext, UIComponent uiComponent)
{
Modified: myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlListboxRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlListboxRenderer.java?rev=170291&r1=170290&r2=170291&view=diff
==============================================================================
--- myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlListboxRenderer.java (original)
+++ myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlListboxRenderer.java Sun May 15 17:44:39 2005
@@ -15,11 +15,13 @@
*/
package org.apache.myfaces.renderkit.html.ext;
+import org.apache.myfaces.component.DisplayValueOnlyCapable;
import org.apache.myfaces.component.UserRoleUtils;
-import org.apache.myfaces.renderkit.html.HtmlListboxRendererBase;
+import org.apache.myfaces.renderkit.html.HtmlRendererUtils;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import java.io.IOException;
/**
@@ -27,7 +29,7 @@
* @version $Revision$ $Date$
*/
public class HtmlListboxRenderer
- extends HtmlListboxRendererBase
+ extends org.apache.myfaces.renderkit.html.HtmlListboxRenderer
{
protected boolean isDisabled(FacesContext facesContext, UIComponent uiComponent)
{
@@ -40,4 +42,17 @@
return super.isDisabled(facesContext, uiComponent);
}
}
+
+ public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {
+
+ if(uiComponent instanceof DisplayValueOnlyCapable && ((DisplayValueOnlyCapable) uiComponent).isDisplayValueOnly())
+ {
+ HtmlRendererUtils.renderDisplayValueOnly(facesContext, uiComponent);
+ }
+ else
+ {
+ super.encodeEnd(facesContext, uiComponent);
+ }
+ }
+
}
Modified: myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlMenuRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlMenuRenderer.java?rev=170291&r1=170290&r2=170291&view=diff
==============================================================================
--- myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlMenuRenderer.java (original)
+++ myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlMenuRenderer.java Sun May 15 17:44:39 2005
@@ -15,24 +15,14 @@
*/
package org.apache.myfaces.renderkit.html.ext;
+import org.apache.myfaces.component.DisplayValueOnlyCapable;
import org.apache.myfaces.component.UserRoleUtils;
-import org.apache.myfaces.component.html.ext.HtmlSelectOneMenu;
import org.apache.myfaces.renderkit.html.HtmlMenuRendererBase;
import org.apache.myfaces.renderkit.html.HtmlRendererUtils;
-import org.apache.myfaces.renderkit.html.HTML;
-import org.apache.myfaces.renderkit.RendererUtils;
import javax.faces.component.UIComponent;
-import javax.faces.component.UISelectMany;
-import javax.faces.component.UISelectOne;
import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.convert.Converter;
-import javax.faces.FacesException;
-import javax.faces.model.SelectItem;
-import javax.faces.model.SelectItemGroup;
import java.io.IOException;
-import java.util.*;
/**
@@ -58,9 +48,10 @@
public void encodeEnd(FacesContext facesContext, UIComponent component)
throws IOException
{
- if(component instanceof HtmlSelectOneMenu)
+ if(component instanceof DisplayValueOnlyCapable
+ && ((DisplayValueOnlyCapable) component).isDisplayValueOnly())
{
- internalRenderSelect(facesContext, component, isDisabled(facesContext, component), 1, false);
+ HtmlRendererUtils.renderDisplayValueOnly(facesContext, component);
}
else
{
@@ -68,204 +59,4 @@
}
}
- private static void internalRenderSelect(FacesContext facesContext,
- UIComponent uiComponent, boolean disabled, int size,
- boolean selectMany) throws IOException {
- ResponseWriter writer = facesContext.getResponseWriter();
-
- writer.startElement(HTML.SELECT_ELEM, uiComponent);
- HtmlRendererUtils.writeIdIfNecessary(writer, uiComponent, facesContext);
- writer.writeAttribute(HTML.NAME_ATTR, uiComponent.getClientId(facesContext), null);
-
- List selectItemList;
- Converter converter;
- if (selectMany) {
- writer.writeAttribute(HTML.MULTIPLE_ATTR, "true", null);
- selectItemList = RendererUtils.getSelectItemList((UISelectMany) uiComponent);
- try {
- converter = RendererUtils.findUISelectManyConverter(
- facesContext, (UISelectMany) uiComponent);
- } catch (FacesException e) {
-// log.error("Error finding Converter for component with id "
-// + uiComponent.getClientId(facesContext));
- converter = null;
- }
- } else {
- selectItemList = RendererUtils
- .getSelectItemList((UISelectOne) uiComponent);
- try {
- converter = RendererUtils.findUIOutputConverter(facesContext,
- (UISelectOne) uiComponent);
- } catch (FacesException e) {
-// log.error("Error finding Converter for component with id "
-// + uiComponent.getClientId(facesContext));
- converter = null;
- }
- }
-
- if (size == 0) {
- //No size given (Listbox) --> size is number of select items
- writer.writeAttribute(HTML.SIZE_ATTR, Integer
- .toString(selectItemList.size()), null);
- } else {
- writer.writeAttribute(HTML.SIZE_ATTR, Integer.toString(size), null);
- }
- HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent,
- HTML.SELECT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
- if (disabled) {
- writer.writeAttribute(HTML.DISABLED_ATTR, Boolean.TRUE, null);
- }
-
- Set lookupSet;
- boolean useSubmittedValue;
- if (selectMany) {
- UISelectMany uiSelectMany = (UISelectMany) uiComponent;
- lookupSet = RendererUtils.getSubmittedValuesAsSet(facesContext, uiComponent, converter, uiSelectMany);
- if (lookupSet == null)
- {
- useSubmittedValue = false;
- lookupSet = RendererUtils.getSelectedValuesAsSet(facesContext, uiComponent, converter, uiSelectMany);
- }
- else
- {
- useSubmittedValue = true;
- }
- } else {
- UISelectOne uiSelectOne = (UISelectOne) uiComponent;
- Object lookup = uiSelectOne.getSubmittedValue();
- if (lookup == null)
- {
- useSubmittedValue = false;
- lookup = uiSelectOne.getValue();
- }
- else
- {
- useSubmittedValue = true;
- }
- String lookupString = RendererUtils.getConvertedStringValue(facesContext, uiComponent, converter, lookup);
- lookupSet = Collections.singleton(lookupString);
- }
-
- if(uiComponent instanceof HtmlSelectOneMenu)
- {
- if(((HtmlSelectOneMenu)uiComponent).isDisplayValueOnly())
- renderSelectOptions(facesContext, (HtmlSelectOneMenu)uiComponent, converter, lookupSet,
- useSubmittedValue, selectItemList);
- else
- renderSelectOptionsValueOnly(facesContext, (HtmlSelectOneMenu)uiComponent,
- converter, lookupSet,
- useSubmittedValue, selectItemList);
- }
- // bug #970747: force separate end tag
- writer.writeText("", null);
- writer.endElement(HTML.SELECT_ELEM);
- }
-
- /**
- * Renders the select options for a <code>UIComponent</code> that is
- * rendered as an HTML select element.
- *
- * @param context
- * the current <code>FacesContext</code>.
- * @param menu
- * the <code>menu</code> whose options need to be
- * rendered.
- * @param converter
- * <code>component</code>'s converter
- * @param lookupSet
- * the <code>Set</code> to use to look up selected options
- * @param useSubmittedValue
- * whether we are using the submittedValue
- * @param selectItemList
- * the <code>List</code> of <code>SelectItem</code> s to be
- * rendered as HTML option elements.
- * @throws IOException
- */
- private static void renderSelectOptions(FacesContext context,
- HtmlSelectOneMenu menu, Converter converter, Set lookupSet,
- boolean useSubmittedValue, List selectItemList) throws IOException {
- ResponseWriter writer = context.getResponseWriter();
-
- for (Iterator it = selectItemList.iterator(); it.hasNext();) {
- SelectItem selectItem = (SelectItem) it.next();
-
- if (selectItem instanceof SelectItemGroup) {
- writer.startElement(HTML.OPTGROUP_ELEM, null);
- writer.writeAttribute(HTML.LABEL_ATTR, selectItem.getLabel(),
- null);
- SelectItem[] selectItems = ((SelectItemGroup) selectItem)
- .getSelectItems();
- renderSelectOptions(context, menu, converter, lookupSet,
- useSubmittedValue, Arrays.asList(selectItems));
- writer.endElement(HTML.OPTGROUP_ELEM);
- } else {
- String itemStrValue = RendererUtils.getConvertedStringValue(context, menu,
- converter, selectItem);
-
- writer.write("\t\t");
- writer.startElement(HTML.OPTION_ELEM, null);
- if (itemStrValue != null) {
- writer.writeAttribute(HTML.VALUE_ATTR, itemStrValue, null);
- }
-
- if (lookupSet.contains(itemStrValue)) { //TODO/FIX: we always compare the String vales, better fill lookupSet with Strings only when useSubmittedValue==true, else use the real item value Objects
- writer.writeAttribute(HTML.SELECTED_ATTR,
- HTML.SELECTED_ATTR, null);
- }
-
- if (selectItem.isDisabled()) {
- writer.writeAttribute(HTML.DISABLED_ATTR,
- HTML.DISABLED_ATTR, null);
- }
-
- writer.writeText(selectItem.getLabel(), null);
-
- writer.endElement(HTML.OPTION_ELEM);
- }
- }
- }
-
- private static void renderSelectOptionsValueOnly(FacesContext context,
- HtmlSelectOneMenu menu, Converter converter, Set lookupSet,
- boolean useSubmittedValue, List selectItemList) throws IOException {
- ResponseWriter writer = context.getResponseWriter();
-
- for (Iterator it = selectItemList.iterator(); it.hasNext();) {
- SelectItem selectItem = (SelectItem) it.next();
-
- if (selectItem instanceof SelectItemGroup) {
- writer.startElement(HTML.OPTGROUP_ELEM, null);
- writer.writeAttribute(HTML.LABEL_ATTR, selectItem.getLabel(),
- null);
- SelectItem[] selectItems = ((SelectItemGroup) selectItem)
- .getSelectItems();
- renderSelectOptions(context, menu, converter, lookupSet,
- useSubmittedValue, Arrays.asList(selectItems));
- writer.endElement(HTML.OPTGROUP_ELEM);
- } else {
- String itemStrValue = RendererUtils.getConvertedStringValue(context, menu,
- converter, selectItem);
-
- writer.write("\t\t");
- writer.startElement(HTML.SPAN_ELEM, null);
- if (itemStrValue != null) {
- writer.writeAttribute(HTML.VALUE_ATTR, itemStrValue, null);
- }
-
- if (lookupSet.contains(itemStrValue)) { //TODO/FIX: we always compare the String vales, better fill lookupSet with Strings only when useSubmittedValue==true, else use the real item value Objects
- writer.writeAttribute(HTML.SELECTED_ATTR,
- HTML.SELECTED_ATTR, null);
- }
-
- if (selectItem.isDisabled()) {
- writer.writeAttribute(HTML.DISABLED_ATTR,
- HTML.DISABLED_ATTR, null);
- }
-
- writer.writeText(selectItem.getLabel(), null);
-
- writer.endElement(HTML.SPAN_ELEM);
- }
- }
- }
}
Modified: myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlRadioRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlRadioRenderer.java?rev=170291&r1=170290&r2=170291&view=diff
==============================================================================
--- myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlRadioRenderer.java (original)
+++ myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlRadioRenderer.java Sun May 15 17:44:39 2005
@@ -16,10 +16,9 @@
package org.apache.myfaces.renderkit.html.ext;
import org.apache.myfaces.component.UserRoleUtils;
-import org.apache.myfaces.component.html.ext.HtmlSelectOneRadio;
+import org.apache.myfaces.component.DisplayValueOnlyCapable;
import org.apache.myfaces.custom.radio.HtmlRadio;
import org.apache.myfaces.renderkit.RendererUtils;
-import org.apache.myfaces.renderkit.JSFAttr;
import org.apache.myfaces.renderkit.html.HTML;
import org.apache.myfaces.renderkit.html.HtmlRadioRendererBase;
import org.apache.myfaces.renderkit.html.HtmlRendererUtils;
@@ -27,14 +26,12 @@
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.component.UISelectOne;
-import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
import javax.faces.model.SelectItem;
import java.io.IOException;
import java.util.List;
-import java.util.Iterator;
/**
@@ -49,9 +46,6 @@
private static final String LAYOUT_SPREAD = "spread";
- private static final String PAGE_DIRECTION = "pageDirection";
- private static final String LINE_DIRECTION = "lineDirection";
-
public void encodeEnd(FacesContext context, UIComponent component) throws IOException
{
if (context == null) throw new NullPointerException("context");
@@ -61,6 +55,11 @@
{
renderRadio(context, (HtmlRadio)component);
}
+ else if (component instanceof DisplayValueOnlyCapable &&
+ ((DisplayValueOnlyCapable) component).isDisplayValueOnly())
+ {
+ HtmlRendererUtils.renderDisplayValueOnly(context, component);
+ }
else if (component instanceof UISelectOne)
{
String layout = getLayout(component);
@@ -70,8 +69,7 @@
}
else
{
- //super.encodeEnd(context, component);
- renderRadio(context, (UISelectOne)component);
+ super.encodeEnd(context, component);
}
}
else
@@ -80,91 +78,6 @@
}
}
- private void renderRadio(FacesContext facesContext, UISelectOne selectOne) throws IOException
- {
-// RendererUtils.checkParamValidity(facesContext, uiComponent, UISelectOne.class);
- String layout = getLayout(selectOne);
-
- boolean pageDirectionLayout = false; // Defaults to LINE_DIRECTION
- if (layout != null)
- {
- if (layout.equals(PAGE_DIRECTION))
- {
- pageDirectionLayout = true;
- }
- else if (layout.equals(LINE_DIRECTION))
- {
- pageDirectionLayout = false;
- }
- else
- {
- //log.error("Wrong layout attribute for component " + selectOne.getClientId(facesContext) + ": " + layout);
- }
- }
-
- ResponseWriter writer = facesContext.getResponseWriter();
-
- writer.startElement(HTML.TABLE_ELEM, selectOne);
- HtmlRendererUtils.renderHTMLAttributes(writer, selectOne,
- HTML.SELECT_TABLE_PASSTHROUGH_ATTRIBUTES);
- HtmlRendererUtils.writeIdIfNecessary(writer, selectOne, facesContext);
-
- if (!pageDirectionLayout) writer.startElement(HTML.TR_ELEM, selectOne);
-
- Converter converter;
- List selectItemList = RendererUtils.getSelectItemList(selectOne);
- try
- {
- converter = RendererUtils.findUIOutputConverter(facesContext, selectOne);
- }
- catch (FacesException e)
- {
- //log.error("Error finding Converter for component with id " + uiComponent.getClientId(facesContext));
- converter = null;
- }
-
- String currentValueStr = RendererUtils.getStringValue(facesContext, selectOne);
-
- for (Iterator it = selectItemList.iterator(); it.hasNext(); )
- {
- SelectItem selectItem = (SelectItem)it.next();
- String itemStrValue = RendererUtils.getConvertedStringValue(facesContext, selectOne, converter, selectItem.getValue());
-
- writer.write("\t\t");
- if (pageDirectionLayout) writer.startElement(HTML.TR_ELEM, selectOne);
- writer.startElement(HTML.TD_ELEM, selectOne);
- writer.startElement(HTML.LABEL_ELEM, selectOne);
- if(selectOne instanceof HtmlSelectOneRadio)
- {
- if(((HtmlSelectOneRadio)selectOne).isDisplayValueOnly())
- renderRadioValueOnly(facesContext,
- (HtmlSelectOneRadio)selectOne,
- itemStrValue,
- selectItem.getLabel(),
- currentValueStr.equals(itemStrValue), false);
- else
- renderRadio(facesContext,
- selectOne,
- itemStrValue,
- selectItem.getLabel(),
- currentValueStr.equals(itemStrValue), false);
- }
- else
- {
- renderRadio(facesContext,
- selectOne,
- itemStrValue,
- selectItem.getLabel(),
- currentValueStr.equals(itemStrValue), false);
- }
- writer.endElement(HTML.LABEL_ELEM);
- writer.endElement(HTML.TD_ELEM);
- if (pageDirectionLayout) writer.endElement(HTML.TR_ELEM);
- }
- if (!pageDirectionLayout) writer.endElement(HTML.TR_ELEM);
- writer.endElement(HTML.TABLE_ELEM);
- }
-
private void renderRadio(FacesContext facesContext, HtmlRadio radio) throws IOException
{
String forAttr = radio.getFor();
@@ -220,75 +133,17 @@
ResponseWriter writer = facesContext.getResponseWriter();
writer.startElement(HTML.LABEL_ELEM, uiSelectOne);
- if(uiSelectOne instanceof HtmlSelectOneRadio)
- {
- if(((HtmlSelectOneRadio)uiSelectOne).isDisplayValueOnly())
- renderRadioValueOnly(facesContext,
- (HtmlSelectOneRadio)uiSelectOne,
- itemStrValue,
- selectItem.getLabel(),
- currentValue == null && itemValue == null ||
- currentValue != null && currentValue.equals(itemValue), false);
- else
- renderRadio(facesContext,
- uiSelectOne,
- itemStrValue,
- selectItem.getLabel(),
- currentValue == null && itemValue == null ||
- currentValue != null && currentValue.equals(itemValue), false);
- }
- else
- {
- renderRadio(facesContext,
- uiSelectOne,
- itemStrValue,
- selectItem.getLabel(),
- currentValue == null && itemValue == null ||
- currentValue != null && currentValue.equals(itemValue), false);
- }
+
+ renderRadio(facesContext,
+ uiSelectOne,
+ itemStrValue,
+ selectItem.getLabel(),
+ currentValue == null && itemValue == null ||
+ currentValue != null && currentValue.equals(itemValue), false);
writer.endElement(HTML.LABEL_ELEM);
}
-
- protected void renderRadioValueOnly(FacesContext facesContext,
- HtmlSelectOneRadio radio,
- String value,
- String label,
- boolean checked,
- boolean renderId)
- throws IOException
- {
- String clientId = radio.getClientId(facesContext);
-
- ResponseWriter writer = facesContext.getResponseWriter();
-
- writer.startElement(HTML.SPAN_ELEM, radio);
- writer.writeAttribute(HTML.NAME_ATTR, clientId, null);
-
- if (renderId)
- {
- writer.writeAttribute(HTML.ID_ATTR, clientId, null);
- }
-
- HtmlRendererUtils.renderHTMLAttributes(writer, radio, HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
-
- String strValue = RendererUtils.getStringValue(facesContext, radio);
- writer.writeText(strValue, JSFAttr.VALUE_ATTR);
-// if ((value != null) && (value.length() > 0))
-// {
-// writer.writeAttribute(HTML.VALUE_ATTR, value, null);
-// }
-
- writer.endElement(HTML.SPAN_ELEM);
-
- if ((label != null) && (label.length() > 0))
- {
- writer.write(HTML.NBSP_ENTITY);
- writer.writeText(label, null);
- }
- }
-
protected boolean isDisabled(FacesContext facesContext, UIComponent uiComponent)
{
if (!UserRoleUtils.isEnabledOnUserRole(uiComponent))
@@ -300,6 +155,7 @@
return super.isDisabled(facesContext, uiComponent);
}
}
+
public void decode(FacesContext facesContext, UIComponent uiComponent)
{
Modified: myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlTextRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlTextRenderer.java?rev=170291&r1=170290&r2=170291&view=diff
==============================================================================
--- myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlTextRenderer.java (original)
+++ myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlTextRenderer.java Sun May 15 17:44:39 2005
@@ -57,7 +57,7 @@
if(((HtmlInputText)component).isDisplayValueOnly())
renderInputValueOnly(facesContext, (HtmlInputText)component);
else
- renderInput(facesContext, (HtmlInputText)component);
+ super.renderInput(facesContext, (HtmlInputText)component);
}
else
{
@@ -65,34 +65,6 @@
}
}
- protected void renderInput(FacesContext facesContext, HtmlInputText inputText)
- throws IOException
- {
- ResponseWriter writer = facesContext.getResponseWriter();
-
- String clientId = inputText.getClientId(facesContext);
- String value = RendererUtils.getStringValue(facesContext, inputText);
-
- writer.startElement(HTML.INPUT_ELEM, inputText);
- writer.writeAttribute(HTML.ID_ATTR, clientId, null);
- writer.writeAttribute(HTML.NAME_ATTR, clientId, null);
- writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_TEXT, null);
- if (value != null)
- writer.writeAttribute(HTML.VALUE_ATTR, value, JSFAttr.VALUE_ATTR);
-
- HtmlRendererUtils.renderHTMLAttributes(writer, inputText, HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
-
- if(inputText.getStyle() != null)
- writer.writeAttribute(HTML.STYLE_ATTR, inputText.getStyle(), null);
- if(inputText.getStyleClass() != null)
- writer.writeAttribute(HTML.STYLE_CLASS_ATTR, inputText.getStyleClass(), null);
-
- if (isDisabled(facesContext, inputText))
- writer.writeAttribute(HTML.DISABLED_ATTR, Boolean.TRUE, null);
-
- writer.endElement(HTML.INPUT_ELEM);
- }
-
protected void renderInputValueOnly(FacesContext facesContext, HtmlInputText inputText)
throws IOException
{
@@ -104,12 +76,7 @@
writer.writeAttribute(HTML.NAME_ATTR, clientId, null);
- HtmlRendererUtils.renderHTMLAttributes(writer, inputText, HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
-
- if(inputText.getDisplayValueOnlyStyle() != null)
- writer.writeAttribute(HTML.STYLE_ATTR, inputText.getDisplayValueOnlyStyle(), null);
- if(inputText.getDisplayValueOnlyStyleClass() != null)
- writer.writeAttribute(HTML.STYLE_CLASS_ATTR, inputText.getDisplayValueOnlyStyleClass(), null);
+ HtmlRendererUtils.renderDisplayValueOnlyAttributes(inputText, writer);
String strValue = RendererUtils.getStringValue(facesContext, inputText);
writer.writeText(strValue, JSFAttr.VALUE_ATTR);
Modified: myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlTextareaRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlTextareaRenderer.java?rev=170291&r1=170290&r2=170291&view=diff
==============================================================================
--- myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlTextareaRenderer.java (original)
+++ myfaces/trunk/src/components/org/apache/myfaces/renderkit/html/ext/HtmlTextareaRenderer.java Sun May 15 17:44:39 2005
@@ -60,35 +60,10 @@
if(textarea.isDisplayValueOnly())
encodeDisplayValueOnly(facesContext, textarea);
else
- encodeNormal(facesContext, textarea);
+ super.encodeTextArea(facesContext, textarea);
}
}
- private void encodeNormal(FacesContext facesContext, HtmlInputTextarea textarea) throws IOException
- {
- ResponseWriter writer = facesContext.getResponseWriter();
- writer.startElement(HTML.TEXTAREA_ELEM, textarea);
-
- String clientId = textarea.getClientId(facesContext);
- writer.writeAttribute(HTML.NAME_ATTR, clientId, null);
- HtmlRendererUtils.writeIdIfNecessary(writer, textarea, facesContext);
-
- HtmlRendererUtils.renderHTMLAttributes(writer, textarea, HTML.TEXTAREA_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
-
- if(textarea.getStyle() != null)
- writer.writeAttribute(HTML.STYLE_ATTR, textarea.getStyle(), null);
- if(textarea.getStyleClass() != null)
- writer.writeAttribute(HTML.STYLE_CLASS_ATTR, textarea.getStyleClass(), null);
-
- if (isDisabled(facesContext, textarea))
- writer.writeAttribute(HTML.DISABLED_ATTR, Boolean.TRUE, null);
-
- String strValue = RendererUtils.getStringValue(facesContext, textarea);
- writer.writeText(strValue, JSFAttr.VALUE_ATTR);
-
- writer.endElement(HTML.TEXTAREA_ELEM);
- }
-
private void encodeDisplayValueOnly(FacesContext facesContext, HtmlInputTextarea textarea) throws IOException
{
ResponseWriter writer = facesContext.getResponseWriter();
@@ -98,12 +73,7 @@
writer.writeAttribute(HTML.NAME_ATTR, clientId, null);
HtmlRendererUtils.writeIdIfNecessary(writer, textarea, facesContext);
- HtmlRendererUtils.renderHTMLAttributes(writer, textarea, HTML.TEXTAREA_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
-
- if(textarea.getDisplayValueOnlyStyle() != null)
- writer.writeAttribute(HTML.STYLE_ATTR, textarea.getDisplayValueOnlyStyle(), null);
- if(textarea.getDisplayValueOnlyStyleClass() != null)
- writer.writeAttribute(HTML.STYLE_CLASS_ATTR, textarea.getDisplayValueOnlyStyleClass(), null);
+ HtmlRendererUtils.renderDisplayValueOnlyAttributes(textarea, writer);
String strValue = RendererUtils.getStringValue(facesContext, textarea);
writer.writeText(strValue, JSFAttr.VALUE_ATTR);
Modified: myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HtmlRadioRendererBase.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HtmlRadioRendererBase.java?rev=170291&r1=170290&r2=170291&view=diff
==============================================================================
--- myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HtmlRadioRendererBase.java (original)
+++ myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HtmlRadioRendererBase.java Sun May 15 17:44:39 2005
@@ -85,15 +85,7 @@
Converter converter;
List selectItemList = RendererUtils.getSelectItemList(selectOne);
- try
- {
- converter = RendererUtils.findUIOutputConverter(facesContext, selectOne);
- }
- catch (FacesException e)
- {
- log.error("Error finding Converter for component with id " + uiComponent.getClientId(facesContext));
- converter = null;
- }
+ converter = HtmlRendererUtils.findUIOutputConverterFailSafe(facesContext, selectOne);
String currentValueStr = RendererUtils.getStringValue(facesContext, selectOne);
Modified: myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HtmlRendererUtils.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HtmlRendererUtils.java?rev=170291&r1=170290&r2=170291&view=diff
==============================================================================
--- myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HtmlRendererUtils.java (original)
+++ myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HtmlRendererUtils.java Sun May 15 17:44:39 2005
@@ -43,6 +43,7 @@
import org.apache.myfaces.renderkit.RendererUtils;
import org.apache.myfaces.renderkit.html.util.DummyFormUtils;
import org.apache.myfaces.renderkit.html.util.JavascriptUtils;
+import org.apache.myfaces.component.DisplayValueOnlyCapable;
/**
* @author Manfred Geiler (latest modification by $Author$)
@@ -133,7 +134,9 @@
public static boolean isDisabledOrReadOnly(UIComponent component)
{
- return isTrue(component.getAttributes().get("disabled")) ||
+ return (component instanceof DisplayValueOnlyCapable &&
+ ((DisplayValueOnlyCapable) component).isDisplayValueOnly()) ||
+ isTrue(component.getAttributes().get("disabled")) ||
isTrue(component.getAttributes().get("readOnly"));
}
@@ -273,25 +276,11 @@
writer.writeAttribute(HTML.MULTIPLE_ATTR, "true", null);
selectItemList = RendererUtils
.getSelectItemList((UISelectMany) uiComponent);
- try {
- converter = RendererUtils.findUISelectManyConverter(
- facesContext, (UISelectMany) uiComponent);
- } catch (FacesException e) {
- log.error("Error finding Converter for component with id "
- + uiComponent.getClientId(facesContext));
- converter = null;
- }
+ converter = findUISelectManyConverterFailsafe(facesContext, uiComponent);
} else {
selectItemList = RendererUtils
.getSelectItemList((UISelectOne) uiComponent);
- try {
- converter = RendererUtils.findUIOutputConverter(facesContext,
- (UISelectOne) uiComponent);
- } catch (FacesException e) {
- log.error("Error finding Converter for component with id "
- + uiComponent.getClientId(facesContext));
- converter = null;
- }
+ converter = findUIOutputConverterFailSafe(facesContext, uiComponent);
}
if (size == 0) {
@@ -307,41 +296,62 @@
writer.writeAttribute(HTML.DISABLED_ATTR, Boolean.TRUE, null);
}
+ Set lookupSet = getSubmittedOrSelectedValuesAsSet(selectMany, uiComponent, facesContext, converter);
+
+ renderSelectOptions(facesContext, uiComponent, converter, lookupSet,
+ selectItemList);
+ // bug #970747: force separate end tag
+ writer.writeText("", null);
+ writer.endElement(HTML.SELECT_ELEM);
+ }
+
+ public static Set getSubmittedOrSelectedValuesAsSet(boolean selectMany, UIComponent uiComponent, FacesContext facesContext, Converter converter) {
Set lookupSet;
- boolean useSubmittedValue;
+
if (selectMany) {
UISelectMany uiSelectMany = (UISelectMany) uiComponent;
lookupSet = RendererUtils.getSubmittedValuesAsSet(facesContext, uiComponent, converter, uiSelectMany);
if (lookupSet == null)
{
- useSubmittedValue = false;
lookupSet = RendererUtils.getSelectedValuesAsSet(facesContext, uiComponent, converter, uiSelectMany);
}
- else
- {
- useSubmittedValue = true;
- }
} else {
UISelectOne uiSelectOne = (UISelectOne) uiComponent;
Object lookup = uiSelectOne.getSubmittedValue();
if (lookup == null)
{
- useSubmittedValue = false;
lookup = uiSelectOne.getValue();
}
- else
- {
- useSubmittedValue = true;
- }
String lookupString = RendererUtils.getConvertedStringValue(facesContext, uiComponent, converter, lookup);
lookupSet = Collections.singleton(lookupString);
}
+ return lookupSet;
+ }
- renderSelectOptions(facesContext, uiComponent, converter, lookupSet,
- useSubmittedValue, selectItemList);
- // bug #970747: force separate end tag
- writer.writeText("", null);
- writer.endElement(HTML.SELECT_ELEM);
+ public static Converter findUISelectManyConverterFailsafe(FacesContext facesContext, UIComponent uiComponent) {
+ Converter converter;
+ try {
+ converter = RendererUtils.findUISelectManyConverter(
+ facesContext, (UISelectMany) uiComponent);
+ } catch (FacesException e) {
+ log.error("Error finding Converter for component with id "
+ + uiComponent.getClientId(facesContext));
+ converter = null;
+ }
+ return converter;
+ }
+
+ public static Converter findUIOutputConverterFailSafe(FacesContext facesContext, UIComponent uiComponent) {
+ Converter converter;
+ try {
+ converter = RendererUtils.findUIOutputConverter(facesContext,
+ (UISelectOne) uiComponent);
+ } catch (FacesException e) {
+ log.error("Error finding Converter for component with id "
+ + uiComponent.getClientId(facesContext));
+ converter = null;
+ }
+ return converter;
}
/**
@@ -357,16 +367,14 @@
* <code>component</code>'s converter
* @param lookupSet
* the <code>Set</code> to use to look up selected options
- * @param useSubmittedValue
- * whether we are using the submittedValue
* @param selectItemList
* the <code>List</code> of <code>SelectItem</code> s to be
* rendered as HTML option elements.
* @throws IOException
*/
private static void renderSelectOptions(FacesContext context,
- UIComponent component, Converter converter, Set lookupSet,
- boolean useSubmittedValue, List selectItemList) throws IOException {
+ UIComponent component, Converter converter, Set lookupSet,
+ List selectItemList) throws IOException {
ResponseWriter writer = context.getResponseWriter();
for (Iterator it = selectItemList.iterator(); it.hasNext();) {
@@ -379,7 +387,7 @@
SelectItem[] selectItems = ((SelectItemGroup) selectItem)
.getSelectItems();
renderSelectOptions(context, component, converter, lookupSet,
- useSubmittedValue, Arrays.asList(selectItems));
+ Arrays.asList(selectItems));
writer.endElement(HTML.OPTGROUP_ELEM);
} else {
String itemStrValue = RendererUtils.getConvertedStringValue(context, component,
@@ -557,6 +565,116 @@
if(component.getId()!=null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
{
writer.writeAttribute(HTML.ID_ATTR, component.getClientId(facesContext),null);
+ }
+ }
+
+ public static void renderDisplayValueOnly(FacesContext facesContext, UIComponent
+ uiComponent)
+ throws IOException
+ {
+ ResponseWriter writer = facesContext.getResponseWriter();
+
+ List selectItemList;
+ Converter converter;
+ if (uiComponent instanceof UISelectMany) {
+ selectItemList = RendererUtils
+ .getSelectItemList((UISelectMany) uiComponent);
+ converter = findUISelectManyConverterFailsafe(facesContext, uiComponent);
+ } else {
+ selectItemList = RendererUtils
+ .getSelectItemList((UISelectOne) uiComponent);
+ converter = findUIOutputConverterFailSafe(facesContext, uiComponent);
+ }
+
+ writer.startElement(HTML.UL_ELEM, uiComponent);
+ writeIdIfNecessary(writer, uiComponent, facesContext);
+ writer.writeAttribute(HTML.NAME_ATTR, uiComponent
+ .getClientId(facesContext), null);
+
+ renderDisplayValueOnlyAttributes(uiComponent, writer);
+
+
+ Set lookupSet = getSubmittedOrSelectedValuesAsSet(
+ uiComponent instanceof UISelectMany,
+ uiComponent, facesContext, converter);
+
+ renderSelectOptionsAsText(facesContext, uiComponent, converter, lookupSet,
+ selectItemList);
+
+ // bug #970747: force separate end tag
+ writer.writeText("", null);
+ writer.endElement(HTML.UL_ELEM);
+
+ }
+
+ public static void renderDisplayValueOnlyAttributes(UIComponent uiComponent, ResponseWriter writer) throws IOException {
+ if(!(uiComponent instanceof DisplayValueOnlyCapable))
+ {
+ log.error("Wrong type of uiComponent. needs DisplayValueOnlyCapable.");
+ renderHTMLAttributes(writer, uiComponent,
+ HTML.COMMON_PASSTROUGH_ATTRIBUTES);
+
+ return;
+ }
+
+ DisplayValueOnlyCapable displayOnlyCapable = (DisplayValueOnlyCapable)
+ uiComponent;
+
+
+ if(displayOnlyCapable.getDisplayValueOnlyStyle() != null || displayOnlyCapable.getDisplayValueOnlyStyleClass()!=null)
+ {
+ if(displayOnlyCapable.getDisplayValueOnlyStyle() != null)
+ {
+ writer.writeAttribute(HTML.STYLE_ATTR, displayOnlyCapable.getDisplayValueOnlyStyle(), null);
+ }
+ else if(uiComponent.getAttributes().get("style")!=null)
+ {
+ writer.writeAttribute(HTML.STYLE_ATTR, uiComponent.getAttributes().get("style"), null);
+ }
+
+ if(displayOnlyCapable.getDisplayValueOnlyStyleClass() != null)
+ {
+ writer.writeAttribute(HTML.STYLE_CLASS_ATTR, displayOnlyCapable.getDisplayValueOnlyStyleClass(), null);
+ }
+ else if(uiComponent.getAttributes().get("styleClass")!=null)
+ {
+ writer.writeAttribute(HTML.STYLE_CLASS_ATTR, uiComponent.getAttributes().get("styleClass"), null);
+ }
+
+ renderHTMLAttributes(writer, uiComponent,
+ HTML.COMMON_PASSTROUGH_ATTRIBUTES_WITHOUT_STYLE);
+ }
+ else
+ {
+ renderHTMLAttributes(writer, uiComponent,
+ HTML.COMMON_PASSTROUGH_ATTRIBUTES);
+ }
+ }
+
+ private static void renderSelectOptionsAsText(FacesContext context,
+ UIComponent component, Converter converter, Set lookupSet,
+ List selectItemList) throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+
+ for (Iterator it = selectItemList.iterator(); it.hasNext();) {
+ SelectItem selectItem = (SelectItem) it.next();
+
+ if (selectItem instanceof SelectItemGroup) {
+ SelectItem[] selectItems = ((SelectItemGroup) selectItem)
+ .getSelectItems();
+ renderSelectOptionsAsText(context, component, converter, lookupSet,
+ Arrays.asList(selectItems));
+ } else {
+ String itemStrValue = RendererUtils.getConvertedStringValue(context, component,
+ converter, selectItem);
+
+ if (lookupSet.contains(itemStrValue)) { //TODO/FIX: we always compare the String vales, better fill lookupSet with Strings only when useSubmittedValue==true, else use the real item value Objects
+
+ writer.startElement(HTML.LI_ELEM, null);
+ writer.writeText(selectItem.getLabel(), null);
+ writer.endElement(HTML.LI_ELEM);
+ }
+ }
}
}
Modified: myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HtmlTextareaRendererBase.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HtmlTextareaRendererBase.java?rev=170291&r1=170290&r2=170291&view=diff
==============================================================================
--- myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HtmlTextareaRendererBase.java (original)
+++ myfaces/trunk/src/share/org/apache/myfaces/renderkit/html/HtmlTextareaRendererBase.java Sun May 15 17:44:39 2005
@@ -41,6 +41,11 @@
{
RendererUtils.checkParamValidity(facesContext, uiComponent, UIInput.class);
+ encodeTextArea(facesContext, uiComponent);
+
+ }
+
+ protected void encodeTextArea(FacesContext facesContext, UIComponent uiComponent) throws IOException {
ResponseWriter writer = facesContext.getResponseWriter();
writer.startElement(HTML.TEXTAREA_ELEM, uiComponent);
Modified: myfaces/trunk/tlds/myfaces_ext.tld
URL: http://svn.apache.org/viewcvs/myfaces/trunk/tlds/myfaces_ext.tld?rev=170291&r1=170290&r2=170291&view=diff
==============================================================================
--- myfaces/trunk/tlds/myfaces_ext.tld (original)
+++ myfaces/trunk/tlds/myfaces_ext.tld Sun May 15 17:44:39 2005
@@ -61,9 +61,13 @@
<!ENTITY standard_output_label_attributes SYSTEM "entities/standard_output_label_attributes.xml">
<!ENTITY standard_output_text_attributes SYSTEM "entities/standard_output_text_attributes.xml">
<!ENTITY standard_panel_group_attributes SYSTEM "entities/standard_panel_group_attributes.xml">
+<!ENTITY standard_select_boolean_checkbox_attributes SYSTEM "entities/standard_select_boolean_checkbox_attributes.xml">
+<!ENTITY standard_select_many_checkbox_attributes SYSTEM "entities/standard_select_many_checkbox_attributes.xml">
+<!ENTITY standard_select_many_listbox_attributes SYSTEM "entities/standard_select_many_listbox_attributes.xml">
+<!ENTITY standard_select_many_menu_attributes SYSTEM "entities/standard_select_many_menu_attributes.xml">
+<!ENTITY standard_select_one_listbox_attributes SYSTEM "entities/standard_select_one_listbox_attributes.xml">
<!ENTITY standard_select_one_menu_attributes SYSTEM "entities/standard_select_one_menu_attributes.xml">
<!ENTITY standard_select_one_radio_attributes SYSTEM "entities/standard_select_one_radio_attributes.xml">
-<!ENTITY standard_select_many_checkbox_attributes SYSTEM "entities/standard_select_many_checkbox_attributes.xml">
<!ENTITY alt_location_attributes SYSTEM "entities/alt_location_attributes.xml">
]>
@@ -403,6 +407,20 @@
&display_value_only_attributes;
</tag>
+ <!-- selectManyMenu -->
+ <tag>
+ <name>selectManyMenu</name>
+ <tag-class>org.apache.myfaces.taglib.html.ext.HtmlSelectManyMenuTag</tag-class>
+ <body-content>JSP</body-content>
+ <description>
+ Extends standard selectManyMenu by user role support.
+ </description>
+ &standard_select_many_menu_attributes;
+ &user_role_attributes;
+ &ext_forceId_attribute;
+ &display_value_only_attributes;
+ </tag>
+
<!-- selectOneRadio -->
<tag>
<name>selectOneRadio</name>
@@ -419,6 +437,20 @@
&display_value_only_attributes;
</tag>
+ <!-- selectBooleanCheckbox -->
+ <tag>
+ <name>selectBooleanCheckbox</name>
+ <tag-class>org.apache.myfaces.taglib.html.ext.HtmlSelectBooleanCheckboxTag</tag-class>
+ <body-content>JSP</body-content>
+ <description>
+ Extends standard selectBooleanCheckbox by user role support.
+ </description>
+ &standard_select_boolean_checkbox_attributes;
+ &user_role_attributes;
+ &ext_forceId_attribute;
+ &display_value_only_attributes;
+ </tag>
+
<!-- selectManyCheckbox -->
<tag>
<name>selectManyCheckbox</name>
@@ -435,6 +467,33 @@
&display_value_only_attributes;
</tag>
+ <!-- selectOneListbox -->
+ <tag>
+ <name>selectOneCheckbox</name>
+ <tag-class>org.apache.myfaces.taglib.html.ext.HtmlSelectOneListboxTag</tag-class>
+ <body-content>JSP</body-content>
+ <description>
+ Extends standard selectOneListbox by user role support.
+ </description>
+ &standard_select_one_listbox_attributes;
+ &user_role_attributes;
+ &ext_forceId_attribute;
+ &display_value_only_attributes;
+ </tag>
+
+ <!-- selectManyListbox -->
+ <tag>
+ <name>selectManyListbox</name>
+ <tag-class>org.apache.myfaces.taglib.html.ext.HtmlSelectManyListboxTag</tag-class>
+ <body-content>JSP</body-content>
+ <description>
+ Extends standard selectManyListbox by user role support.
+ </description>
+ &standard_select_many_listbox_attributes;
+ &user_role_attributes;
+ &ext_forceId_attribute;
+ &display_value_only_attributes;
+ </tag>
<!-- Custom components -->
Modified: myfaces/trunk/tlds/myfaces_html.tld
URL: http://svn.apache.org/viewcvs/myfaces/trunk/tlds/myfaces_html.tld?rev=170291&r1=170290&r2=170291&view=diff
==============================================================================
--- myfaces/trunk/tlds/myfaces_html.tld (original)
+++ myfaces/trunk/tlds/myfaces_html.tld Sun May 15 17:44:39 2005
@@ -57,9 +57,13 @@
<!ENTITY standard_output_label_attributes SYSTEM "entities/standard_output_label_attributes.xml">
<!ENTITY standard_output_text_attributes SYSTEM "entities/standard_output_text_attributes.xml">
<!ENTITY standard_panel_group_attributes SYSTEM "entities/standard_panel_group_attributes.xml">
-<!ENTITY standard_select_one_menu_attributes SYSTEM "entities/standard_select_one_menu_attributes.xml">
-<!ENTITY standard_select_one_radio_attributes SYSTEM "entities/standard_select_one_radio_attributes.xml">
+<!ENTITY standard_select_boolean_checkbox_attributes SYSTEM "entities/standard_select_boolean_checkbox_attributes.xml">
<!ENTITY standard_select_many_checkbox_attributes SYSTEM "entities/standard_select_many_checkbox_attributes.xml">
+<!ENTITY standard_select_many_listbox_attributes SYSTEM "entities/standard_select_many_listbox_attributes.xml">
+<!ENTITY standard_select_many_menu_attributes SYSTEM "entities/standard_select_many_menu_attributes.xml">
+<!ENTITY standard_select_one_listbox_attributes SYSTEM "entities/standard_select_one_listbox_attributes.xml">
+<!ENTITY standard_select_one_menu_attributes SYSTEM "entities/standard_select_one_menu_attributes.xml">
+<!ENTITY standard_select_one_radio_attributes SYSTEM "entities/standard_select_one_radio_attributes.xml">
]>
<taglib>
@@ -341,10 +345,7 @@
<name>selectBooleanCheckbox</name>
<tag-class>org.apache.myfaces.taglib.html.HtmlSelectBooleanCheckboxTag</tag-class>
<body-content>JSP</body-content>
- &ui_select_boolean_attributes;
- &html_universal_attributes;
- &html_event_handler_attributes;
- &html_input_checkbox_attributes;
+ &standard_select_boolean_checkbox_attributes;
</tag>
<!-- selectManyCheckbox -->
@@ -360,18 +361,7 @@
<name>selectManyListbox</name>
<tag-class>org.apache.myfaces.taglib.html.HtmlSelectManyListboxTag</tag-class>
<body-content>JSP</body-content>
- &ui_select_many_attributes;
- &html_universal_attributes;
- &html_event_handler_attributes;
- &html_select_attributes;
- <!-- ListboxRenderer attributes -->
- <attribute>
- <name>size</name>
- <required>false</required>
- <rtexprvalue>false</rtexprvalue>
- <type>java.lang.String</type>
- <description>see JSF Spec.</description>
- </attribute>
+ &standard_select_many_listbox_attributes;
</tag>
<!-- selectmany_menu -->
@@ -379,10 +369,7 @@
<name>selectManyMenu</name>
<tag-class>org.apache.myfaces.taglib.html.HtmlSelectManyMenuTag</tag-class>
<body-content>JSP</body-content>
- &ui_select_many_attributes;
- &html_universal_attributes;
- &html_event_handler_attributes;
- &html_select_attributes;
+ &standard_select_many_menu_attributes;
</tag>
<!-- selectOneListbox -->
@@ -390,18 +377,7 @@
<name>selectOneListbox</name>
<tag-class>org.apache.myfaces.taglib.html.HtmlSelectOneListboxTag</tag-class>
<body-content>JSP</body-content>
- &ui_select_one_attributes;
- &html_universal_attributes;
- &html_event_handler_attributes;
- &html_select_attributes;
- <!-- ListboxRenderer attributes -->
- <attribute>
- <name>size</name>
- <required>false</required>
- <rtexprvalue>false</rtexprvalue>
- <type>java.lang.String</type>
- <description>see JSF Spec.</description>
- </attribute>
+ &standard_select_one_listbox_attributes;
</tag>
<!-- selectOneMenu -->
Modified: myfaces/trunk/webapps/examples/sample2.jsp
URL: http://svn.apache.org/viewcvs/myfaces/trunk/webapps/examples/sample2.jsp?rev=170291&r1=170290&r2=170291&view=diff
==============================================================================
Binary files - no diff available.