You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gr...@apache.org on 2005/05/11 18:45:12 UTC
svn commit: r169655 [7/8] - in /myfaces/trunk:
src/cactus/org/apache/myfaces/renderkit/html/
src/cactus/org/apache/myfaces/taglib/core/
src/cactus/org/apache/myfaces/taglib/html/
src/components/org/apache/myfaces/renderkit/html/ext/
src/components/org/apache/myfaces/taglib/html/ext/
src/junit/org/apache/myfaces/renderkit/
src/junit/org/apache/myfaces/renderkit/html/
src/junit/org/apache/myfaces/renderkit/html/util/
src/junit/org/apache/myfaces/util/ src/junit/org/apache/myfaces/webapp/
src/myfaces/org/apache/myfaces/lifecycle/
src/myfaces/org/apache/myfaces/portlet/
src/myfaces/org/apache/myfaces/renderkit/
src/myfaces/org/apache/myfaces/renderkit/html/
src/myfaces/org/apache/myfaces/taglib/core/
src/myfaces/org/apache/myfaces/taglib/html/
src/myfaces/org/apache/myfaces/util/ src/myfaces/org/apache/myfaces/webapp/
src/myfaces/org/apache/myfaces/webapp/filter/
src/share/org/apache/myfaces/renderkit/
src/share/org/apache/myfaces/renderkit/html/
src/share/org/apache/myfaces/renderkit/html/util/
src/share/org/apache/myfaces/taglib/
src/share/org/apache/myfaces/taglib/core/
src/share/org/apache/myfaces/taglib/html/ src/share/org/apache/myfaces/util/
src/share/org/apache/myfaces/webapp/webxml/
src/wml/org/apache/myfaces/wap/base/ src/wml/org/apache/myfaces/wap/def/
src/wml/org/apache/myfaces/wap/renderkit/
src/wml/org/apache/myfaces/wap/renderkit/wml/
src/xdoclet/org/apache/myfaces/xdoclet/
webapps/src/example/org/apache/myfaces/examples/validate/
Modified: myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/CommandButtonRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/CommandButtonRenderer.java?rev=169655&r1=169654&r2=169655&view=diff
==============================================================================
--- myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/CommandButtonRenderer.java (original)
+++ myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/CommandButtonRenderer.java Wed May 11 09:45:06 2005
@@ -1,12 +1,12 @@
/*
* Copyright 2004 The Apache Software Foundation.
- *
+ *
* Licensed 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 KIND, either express or implied.
@@ -36,163 +36,159 @@
/**
* @author <a href="mailto:Jiri.Zaloudek@ivancice.cz">Jiri Zaloudek</a> (latest modification by $Author$)
- * @version $Revision$ $Date$
- * $Log$
- * Revision 1.1 2004/12/30 09:37:26 matzew
- * added a new RenderKit for WML. Thanks to Jirí aloudek
- *
+ * @version $Revision$ $Date$
*/
public class CommandButtonRenderer extends WmlRenderer {
private static Log log = LogFactory.getLog(CommandButtonRenderer.class);
-
+
/** Creates a new instance of FormRenderer */
public CommandButtonRenderer() {
super();
log.debug("created object " + this.getClass().getName());
}
-
+
public void encodeBegin(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeBegin(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
if (!component.isRendered()) return;
-
+
}
-
+
public void encodeChildren(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeChildren(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
}
-
+
public void encodeEnd(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeEnd(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
if (!component.isRendered()) return;
-
+
ResponseWriter writer = context.getResponseWriter();
CommandButton comp = (CommandButton)component;
-
+
// <do type='accept' label='submit' >
writer.startElement(Attributes.DO, component);
RendererUtils.writeAttribute(Attributes.ID, comp.getClientId(context), writer);
//RenderUtils.writeAttribute(Attributes.STYLE_CLASS, comp.getStyleClass(), writer);
//RenderUtils.writeAttribute(Attributes.XML_LANG, comp.getXmllang(), writer);
//RenderUtils.writeAttribute(Attributes.NAME, comp.getName(), writer);
- RendererUtils.writeAttribute(Attributes.LABEL, comp.getValue(), writer);
+ RendererUtils.writeAttribute(Attributes.LABEL, comp.getValue(), writer);
RendererUtils.writeAttribute(Attributes.TYPE, comp.getType(), writer);
-
+
/* default value is false, write only if value of attribute emptyok is "true" */
- if (comp.isOptional()) RendererUtils.writeAttribute(Attributes.OPTIONAL, "true", writer);
-
+ if (comp.isOptional()) RendererUtils.writeAttribute(Attributes.OPTIONAL, "true", writer);
+
if (isReset(comp))
renderReset(context, comp);
else
renderAction(context, comp);
-
+
writer.endElement(Attributes.DO);
}
-
-
+
+
public void decode(FacesContext context, UIComponent component) {
log.debug("decode(" + component.getId() + ")");
if (component == null ) throw new NullPointerException();
if (!component.isRendered()) return;
-
+
Map map = context.getExternalContext().getRequestParameterMap();
-
+
// was this link activated?
if (map.containsKey(component.getClientId(context) + Attributes.POSTFIX_ACTIVATED) && !isReset((CommandButton)component)){
log.debug("action queued");
component.queueEvent(new ActionEvent(component));
}
}
-
+
private void renderAction(FacesContext context, CommandButton comp) throws java.io.IOException {
ResponseWriter writer = context.getResponseWriter();
-
+
// post form data
UIForm parentForm = getParentForm(context, comp);
String href = RendererUtils.getCurrentUrl(context);
-
+
// <go href='"+ href +"' method='post' >
writer.startElement(Attributes.GO, comp);
writer.writeAttribute(Attributes.HREF, href, null);
writer.writeAttribute(Attributes.METHOD, Attributes.POST, null);
-
+
Set inputTags = RendererUtils.getInputTags(parentForm.getChildren());
Iterator iter = inputTags.iterator();
-
+
log.debug("Form has " + inputTags.size() + " input tags.");
-
+
while(iter.hasNext()){
- UIComponent component = (UIComponent)iter.next();
+ UIComponent component = (UIComponent)iter.next();
String name = RendererUtils.getAttribute(component, Attributes.NAME);
-
+
// <postfield name='" + name + "' value='$(" + name + ")' />
writer.startElement(Attributes.POSTFIELD, component);
writer.writeAttribute(Attributes.NAME, name, null);
writer.writeAttribute(Attributes.VALUE, "$(" + name + ")", null);
writer.endElement(Attributes.POSTFIELD);
}
-
+
// write hidden input to determine "submited" value on decode parent UIForm component
writer.startElement(Attributes.POSTFIELD, comp);
writer.writeAttribute(Attributes.NAME, parentForm.getClientId(context) + Attributes.POSTFIX_SUBMITED, null);
writer.writeAttribute(Attributes.VALUE, "true", null);
writer.endElement(Attributes.POSTFIELD);
-
+
// write hidden input to determine "activated" value on decode commandLink
writer.startElement(Attributes.POSTFIELD, comp);
writer.writeAttribute(Attributes.NAME, comp.getClientId(context) + Attributes.POSTFIX_ACTIVATED, null);
writer.writeAttribute(Attributes.VALUE, "true", null);
writer.endElement(Attributes.POSTFIELD);
-
+
writer.endElement(Attributes.GO);
-
+
}
- private void renderReset(FacesContext context, CommandButton comp) throws java.io.IOException {
+ private void renderReset(FacesContext context, CommandButton comp) throws java.io.IOException {
ResponseWriter writer = context.getResponseWriter();
-
+
writer.startElement(Attributes.REFRESH, comp);
-
+
UIForm parentForm = getParentForm(context, comp);
Set inputTags = RendererUtils.getInputTags(parentForm.getChildren());
Iterator iter = inputTags.iterator();
-
+
while(iter.hasNext()){
- UIComponent component = (UIComponent)iter.next();
-
+ UIComponent component = (UIComponent)iter.next();
+
// <setvar name='" + name + "' value='$(" + name + ")' />
writer.startElement(Attributes.SETVAR, comp);
String name = RendererUtils.getAttribute(component, Attributes.NAME);
writer.writeAttribute(Attributes.NAME, name, null);
-
+
String value = RendererUtils.getAttribute(component, Attributes.VALUE);
writer.writeAttribute(Attributes.VALUE, value, null);
writer.endElement(Attributes.SETVAR);
}
-
+
writer.endElement(Attributes.REFRESH);
}
-
+
private boolean isReset(CommandButton comp){
return ("reset".compareToIgnoreCase(comp.getType()) == 0);
}
-
-
+
+
private UIForm getParentForm(FacesContext context, UIComponent component){
// find UIForm parent
UIComponent parent = component.getParent();
while(parent != null && !(parent instanceof UIForm)){
parent = parent.getParent();
}
-
+
String formId;
if (parent == null){ //parent not found
//TODO: create dummy form
@@ -201,5 +197,5 @@
return((UIForm)parent);
}
}
-}
-
+}
+
Modified: myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/CommandLinkRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/CommandLinkRenderer.java?rev=169655&r1=169654&r2=169655&view=diff
==============================================================================
--- myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/CommandLinkRenderer.java (original)
+++ myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/CommandLinkRenderer.java Wed May 11 09:45:06 2005
@@ -1,12 +1,12 @@
/*
* Copyright 2004 The Apache Software Foundation.
- *
+ *
* Licensed 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 KIND, either express or implied.
@@ -35,40 +35,36 @@
/**
* @author <a href="mailto:Jiri.Zaloudek@ivancice.cz">Jiri Zaloudek</a> (latest modification by $Author$)
- * @version $Revision$ $Date$
- * $Log$
- * Revision 1.1 2004/12/30 09:37:26 matzew
- * added a new RenderKit for WML. Thanks to Jirí aloudek
- *
+ * @version $Revision$ $Date$
*/
public class CommandLinkRenderer extends WmlRenderer {
private static Log log = LogFactory.getLog(CommandLinkRenderer.class);
-
+
/** Creates a new instance of TextRenderer */
public CommandLinkRenderer() {
super();
log.debug("created object " + this.getClass().getName());
}
-
+
public boolean getRendersChildren(){
return(false);
}
-
+
public void encodeBegin(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeBegin(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
if (!component.isRendered()) return;
-
+
CommandLink comp = (CommandLink)component;
ResponseWriter writer = context.getResponseWriter();
- writer.startElement(Attributes.ANCHOR, component);
+ writer.startElement(Attributes.ANCHOR, component);
RendererUtils.writeAttribute(Attributes.TITLE, comp.getTitle(), writer);
writer.flush();
}
-
+
public void encodeChildren(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeChildren(" + component.getId() + ")");
if (context == null || component == null) {
@@ -78,7 +74,7 @@
RendererUtils.renderChildren(context, component);
}
-
+
public void encodeEnd(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeEnd(" + component.getId() + ")");
if (context == null || component == null) {
@@ -88,23 +84,23 @@
CommandLink comp = (CommandLink)component;
UIForm parentForm = getParentForm(context, component);
-
+
ResponseWriter writer = context.getResponseWriter();
-
- String href = RendererUtils.getCurrentUrl(context);
-
+
+ String href = RendererUtils.getCurrentUrl(context);
+
// <go href='"+ href +"' method='post' >
writer.startElement(Attributes.GO, component);
writer.writeAttribute(Attributes.HREF, href, null);
writer.writeAttribute(Attributes.METHOD, Attributes.POST, null);
-
- Set inputTags = RendererUtils.getInputTags(parentForm.getChildren());
+
+ Set inputTags = RendererUtils.getInputTags(parentForm.getChildren());
Iterator iter = inputTags.iterator();
-
- log.debug("Form has " + inputTags.size() + " input tags.");
-
+
+ log.debug("Form has " + inputTags.size() + " input tags.");
+
while(iter.hasNext()){
- UIComponent inputComp = (UIComponent)iter.next();
+ UIComponent inputComp = (UIComponent)iter.next();
String name = RendererUtils.getAttribute(inputComp, Attributes.NAME);
// <postfield name='" + name + "' value='$(" + name + ")' />
@@ -113,13 +109,13 @@
writer.writeAttribute(Attributes.VALUE, "$(" + name + ")", null);
writer.endElement(Attributes.POSTFIELD);
}
-
+
// write hidden input to determine "submited" value on decode parent UIForm component
- writer.startElement(Attributes.POSTFIELD, component);
+ writer.startElement(Attributes.POSTFIELD, component);
writer.writeAttribute(Attributes.NAME, parentForm.getClientId(context) + Attributes.POSTFIX_SUBMITED, null);
writer.writeAttribute(Attributes.VALUE, "true", null);
writer.endElement(Attributes.POSTFIELD);
-
+
// write hidden input to determine "activated" value on decode commandLink
writer.startElement(Attributes.POSTFIELD, component);
writer.writeAttribute(Attributes.NAME, component.getClientId(context) + Attributes.POSTFIX_ACTIVATED, null);
@@ -127,36 +123,36 @@
writer.endElement(Attributes.POSTFIELD);
writer.endElement(Attributes.GO);
- writer.endElement(Attributes.ANCHOR);
- }
-
+ writer.endElement(Attributes.ANCHOR);
+ }
+
public void decode(FacesContext context, UIComponent component) {
log.debug("decode(" + component.getId() + ")");
if (component == null || context == null) throw new NullPointerException();
if (!component.isRendered()) return;
Map map = context.getExternalContext().getRequestParameterMap();
-
+
// was this link activated?
if (map.containsKey(component.getClientId(context) + Attributes.POSTFIX_ACTIVATED))
component.queueEvent(new ActionEvent(component));
- }
-
+ }
+
private UIForm getParentForm(FacesContext context, UIComponent component){
- // find UIForm parent
+ // find UIForm parent
UIComponent parent = component.getParent();
while(parent != null && !(parent instanceof UIForm)){
parent = parent.getParent();
}
-
+
String formId;
if (parent == null){ //parent not found
- //TODO: create dummy form
+ //TODO: create dummy form
throw new FacesException("FacesException - tag commandLink must be nested in a UIForm tag");
} else {
return((UIForm)parent);
- }
+ }
}
-
+
}
Modified: myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/FormRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/FormRenderer.java?rev=169655&r1=169654&r2=169655&view=diff
==============================================================================
--- myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/FormRenderer.java (original)
+++ myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/FormRenderer.java Wed May 11 09:45:06 2005
@@ -1,12 +1,12 @@
/*
* Copyright 2004 The Apache Software Foundation.
- *
+ *
* Licensed 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 KIND, either express or implied.
@@ -29,21 +29,17 @@
/**
* @author <a href="mailto:Jiri.Zaloudek@ivancice.cz">Jiri Zaloudek</a> (latest modification by $Author$)
- * @version $Revision$ $Date$
- * $Log$
- * Revision 1.1 2004/12/30 09:37:26 matzew
- * added a new RenderKit for WML. Thanks to Jirí aloudek
- *
+ * @version $Revision$ $Date$
*/
public class FormRenderer extends WmlRenderer {
private static Log log = LogFactory.getLog(FormRenderer.class);
-
+
/** Creates a new instance of FormRenderer */
public FormRenderer() {
super();
log.debug("created object " + this.getClass().getName());
}
-
+
public void encodeBegin(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeBegin(" + component.getId() + ")");
if (context == null || component == null) {
@@ -51,14 +47,14 @@
}
if (!component.isRendered()) return;
}
-
+
public void encodeChildren(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeChildren(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
}
-
+
public void encodeEnd(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeEnd(" + component.getId() + ")");
if (context == null || component == null) {
@@ -69,26 +65,26 @@
// write state marker
context.getApplication().getViewHandler().writeState(context);
}
-
-
+
+
public void decode(FacesContext context, UIComponent component) {
log.debug("decode(" + component.getId() + ")");
if (component == null ) throw new NullPointerException();
-
+
Map params = context.getExternalContext().getRequestParameterMap();
-
+
if (params.containsKey(component.getClientId(context) + Attributes.POSTFIX_SUBMITED)){
((UIForm)component).setSubmitted(true);
log.debug("form submited");
}
- else{ ((UIForm)component).setSubmitted(false);
+ else{ ((UIForm)component).setSubmitted(false);
log.debug("form not submited");
}
-
+
/* TODO: correct the Duplicate component ID bug */
- //context.getViewRoot().setTransient(true);
+ //context.getViewRoot().setTransient(true);
}
-
-
-
+
+
+
}
Modified: myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/GridRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/GridRenderer.java?rev=169655&r1=169654&r2=169655&view=diff
==============================================================================
--- myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/GridRenderer.java (original)
+++ myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/GridRenderer.java Wed May 11 09:45:06 2005
@@ -1,12 +1,12 @@
/*
* Copyright 2004 The Apache Software Foundation.
- *
+ *
* Licensed 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 KIND, either express or implied.
@@ -32,35 +32,31 @@
/**
* @author <a href="mailto:Jiri.Zaloudek@ivancice.cz">Jiri Zaloudek</a> (latest modification by $Author$)
- * @version $Revision$ $Date$
- * $Log$
- * Revision 1.1 2004/12/30 09:37:26 matzew
- * added a new RenderKit for WML. Thanks to Jirí aloudek
- *
+ * @version $Revision$ $Date$
*/
public class GridRenderer extends WmlRenderer {
private static Log log = LogFactory.getLog(GridRenderer.class);
-
+
/** Creates a new instance of TextRenderer */
public GridRenderer() {
super();
log.debug("created object " + this.getClass().getName());
}
-
+
public boolean getRendersChildren(){
return(true);
}
-
+
public void encodeBegin(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeBegin(" + component.getId() + ")");
-
+
if (context == null || component == null) {
throw new NullPointerException();
}
if (!component.isRendered()) return;
// renderen in method encodeEnd
}
-
+
public void encodeChildren(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeChildren(" + component.getId() + ")");
if (context == null || component == null) {
@@ -69,71 +65,71 @@
if (!component.isRendered()) return;
// renderen in method encodeEnd
}
-
+
public void encodeEnd(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeEnd(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
if (!component.isRendered()) return;
-
+
ResponseWriter writer = context.getResponseWriter();
PanelGrid comp = (PanelGrid)component;
int columns = getColumnsNumber(comp.getColumns());
-
+
// If no body, header or footer is found, then the table element will be not rendered.
if (!hasTableAnyContext(context, component)) return;
-
+
writer.startElement(Attributes.TABLE, component);
RendererUtils.writeAttribute(Attributes.ID, comp.getClientId(context), writer);
RendererUtils.writeAttribute(Attributes.CLASS, comp.getStyleClass(), writer);
RendererUtils.writeAttribute(Attributes.XML_LANG, comp.getXmllang(), writer);
-
+
RendererUtils.writeAttribute(Attributes.ALIGN, comp.getAlign(), writer);
RendererUtils.writeAttribute(Attributes.COLUMNS, comp.getColumns(), writer);
RendererUtils.writeAttribute(Attributes.TITLE, comp.getTitle(), writer);
-
+
renderHeaderOrFooter(context, component, Attributes.HEADER, columns);
-
+
renderChildern(context, component, columns);
-
+
renderHeaderOrFooter(context, component, Attributes.FOOTER, columns);
-
+
writer.endElement(Attributes.TABLE);
}
-
+
public void decode(FacesContext context, UIComponent component) {
if (component == null ) throw new NullPointerException();
}
-
+
private void renderChildern(FacesContext context, UIComponent component, int maxColumn) throws IOException {
ResponseWriter writer = context.getResponseWriter();
int column = 0, row = 0;
boolean rowStarted = false;
-
+
Iterator childn = component.getChildren().iterator();
while (childn.hasNext()){
if (!rowStarted) {
writer.startElement(Attributes.TR, component);
rowStarted = true; column = 0; row = 1;
}
-
+
// next cell
writer.startElement(Attributes.TD, component);
RendererUtils.renderChild(context, (UIComponent)childn.next());
writer.endElement(Attributes.TD);
column++;
-
+
// end row
if (column >= maxColumn) {
writer.endElement(Attributes.TR);
rowStarted = false;
}
}
-
+
if (rowStarted) writeRowEnd(component, writer, column, maxColumn);
}
-
+
/**
* renders header or footer of the table
* @param context
@@ -145,21 +141,21 @@
private void renderHeaderOrFooter(FacesContext context, UIComponent component, String str, int maxColumn) throws IOException {
ResponseWriter writer = context.getResponseWriter();
UIComponent facet = component.getFacet(str);
-
+
int column = 0;
boolean rowStarted = false;
-
+
if (facet == null) return;
-
+
log.debug("Facet " + str + " is not null. Child numb:" + facet.getChildCount());
Iterator childn = facet.getChildren().iterator();
-
+
// starts header row
if (childn.hasNext()){
writer.startElement(Attributes.TR, component);
rowStarted = true;
}
-
+
// render all children
while (childn.hasNext()){
writer.startElement(Attributes.TD, component);
@@ -168,10 +164,10 @@
writer.endElement(Attributes.TD);
column++;
}
-
+
if (rowStarted) writeRowEnd(component, writer, column, maxColumn);
}
-
+
/**
* appends free cells to the number of columns
* @param component
@@ -188,16 +184,16 @@
}
writer.endElement(Attributes.TR);
}
-
+
/** Checks if the table has any header, body or footer. */
private boolean hasTableAnyContext(FacesContext context, UIComponent component){
boolean hasHeader = component.getFacet(Attributes.HEADER) != null;
boolean hasBody = component.getChildCount() > 0;
boolean hasFooter = component.getFacet(Attributes.FOOTER) != null;
-
+
return (hasHeader || hasBody || hasFooter);
}
-
+
/** Returns number of columns in table. Converts String parameter to int number, if parameter is not correct int number, return zero. */
private int getColumnsNumber(String columns){
int number;
Modified: myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/GroupRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/GroupRenderer.java?rev=169655&r1=169654&r2=169655&view=diff
==============================================================================
--- myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/GroupRenderer.java (original)
+++ myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/GroupRenderer.java Wed May 11 09:45:06 2005
@@ -1,12 +1,12 @@
/*
* Copyright 2004 The Apache Software Foundation.
- *
+ *
* Licensed 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 KIND, either express or implied.
@@ -26,57 +26,53 @@
/**
* @author <a href="mailto:Jiri.Zaloudek@ivancice.cz">Jiri Zaloudek</a> (latest modification by $Author$)
- * @version $Revision$ $Date$
- * $Log$
- * Revision 1.1 2004/12/30 09:37:26 matzew
- * added a new RenderKit for WML. Thanks to Jirí aloudek
- *
+ * @version $Revision$ $Date$
*/
public class GroupRenderer extends WmlRenderer {
private static Log log = LogFactory.getLog(GroupRenderer.class);
-
+
/** Creates a new instance of GroupRenderer */
public GroupRenderer() {
super();
log.debug("created object " + this.getClass().getName());
}
-
+
public boolean getRendersChildren(){
return(true);
}
-
+
public void encodeBegin(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeBegin(" + component.getId() + ")");
-
+
if (context == null || component == null) {
throw new NullPointerException();
}
if (!component.isRendered()) return;
// renderen in method encodeEnd
}
-
+
public void encodeChildren(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeChildren(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
if (!component.isRendered()) return;
-
+
// renderen in method encodeEnd
}
-
+
public void encodeEnd(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeEnd(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
if (!component.isRendered()) return;
-
+
RendererUtils.renderChildren(context, component);
}
-
+
public void decode(FacesContext context, UIComponent component) {
if (component == null ) throw new NullPointerException();
- }
+ }
}
Modified: myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/ImageRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/ImageRenderer.java?rev=169655&r1=169654&r2=169655&view=diff
==============================================================================
--- myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/ImageRenderer.java (original)
+++ myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/ImageRenderer.java Wed May 11 09:45:06 2005
@@ -1,12 +1,12 @@
/*
* Copyright 2004 The Apache Software Foundation.
- *
+ *
* Licensed 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 KIND, either express or implied.
@@ -28,61 +28,57 @@
/**
* @author <a href="mailto:Jiri.Zaloudek@ivancice.cz">Jiri Zaloudek</a> (latest modification by $Author$)
- * @version $Revision$ $Date$
- * $Log$
- * Revision 1.1 2004/12/30 09:37:26 matzew
- * added a new RenderKit for WML. Thanks to Jirí aloudek
- *
+ * @version $Revision$ $Date$
*/
public class ImageRenderer extends WmlRenderer {
private static Log log = LogFactory.getLog(ImageRenderer.class);
-
+
/** Creates a new instance of ImageRenderer */
public ImageRenderer() {
super();
log.debug("created object " + this.getClass().getName());
}
-
+
public void encodeBegin(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeBegin(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
}
-
+
public void encodeChildren(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeChildren(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
- }
+ }
}
public void encodeEnd(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeEnd(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
- }
+ }
if (!component.isRendered()) return;
-
+
GraphicImage comp = (GraphicImage)component;
String contextPath = context.getExternalContext().getRequestContextPath();
//String url = (String)component.getAttributes().get("url");
ResponseWriter writer = context.getResponseWriter();
-
+
writer.startElement(Attributes.IMG, comp);
-
+
RendererUtils.writeAttribute(Attributes.ID, comp.getClientId(context), writer);
RendererUtils.writeAttribute(Attributes.STYLE_CLASS, comp.getStyleClass(), writer);
RendererUtils.writeAttribute(Attributes.XML_LANG, comp.getXmllang(), writer);
RendererUtils.writeAttribute(Attributes.ALT, comp.getAlt(), writer);
// src
- String url = null;
+ String url = null;
if (comp.getValue() != null) url = (String)comp.getValue(); // 'value' have a priority
else if (comp.getUrl() != null) url = (String)comp.getUrl();
RendererUtils.writeAttribute(Attributes.SRC, getURL(context, url), writer);
-
+
RendererUtils.writeAttribute(Attributes.LOCAL_SRC, comp.getLocalsrc(), writer);
RendererUtils.writeAttribute(Attributes.VSPACE, comp.getVspace(), writer);
RendererUtils.writeAttribute(Attributes.HSPACE, comp.getHspace(), writer);
@@ -92,12 +88,12 @@
writer.endElement(Attributes.IMG);
}
-
-
+
+
public void decode(FacesContext context, UIComponent component) {
- if (component == null) throw new NullPointerException();
+ if (component == null) throw new NullPointerException();
}
-
+
/** Passing it to the getResourceURL() method of the ViewHandler for this application,
* and passing the result through the encodeResourceURL() method of the ExternalContext
*/
@@ -107,6 +103,6 @@
url = context.getExternalContext().encodeResourceURL(url);
return (url);
}
-
+
}
Modified: myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/InputSecretRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/InputSecretRenderer.java?rev=169655&r1=169654&r2=169655&view=diff
==============================================================================
--- myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/InputSecretRenderer.java (original)
+++ myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/InputSecretRenderer.java Wed May 11 09:45:06 2005
@@ -1,12 +1,12 @@
/*
* Copyright 2004 The Apache Software Foundation.
- *
+ *
* Licensed 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 KIND, either express or implied.
@@ -30,62 +30,58 @@
/**
* @author <a href="mailto:Jiri.Zaloudek@ivancice.cz">Jiri Zaloudek</a> (latest modification by $Author$)
- * @version $Revision$ $Date$
- * $Log$
- * Revision 1.1 2004/12/30 09:37:26 matzew
- * added a new RenderKit for WML. Thanks to Jirí aloudek
- *
+ * @version $Revision$ $Date$
*/
public class InputSecretRenderer extends WmlRenderer {
private static Log log = LogFactory.getLog(InputSecretRenderer.class);
-
+
/** Creates a new instance of TextRenderer */
public InputSecretRenderer() {
super();
log.debug("created object " + this.getClass().getName());
}
-
+
public void encodeBegin(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeBegin(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
}
-
+
public void encodeChildren(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeChildren(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
}
-
+
public void encodeEnd(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeEnd(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
-
+
if (!component.isRendered()) return;
-
+
InputSecret comp = (InputSecret)component;
-
+
ResponseWriter writer = context.getResponseWriter();
writer.startElement(Attributes.INPUT, component);
-
+
RendererUtils.writeAttribute(Attributes.ID, comp.getClientId(context), writer);
RendererUtils.writeAttribute(Attributes.STYLE_CLASS, comp.getStyleClass(), writer);
RendererUtils.writeAttribute(Attributes.XML_LANG, comp.getXmllang(), writer);
-
+
/* attribute name is not required. If is not set, name value equals component id */
if (comp.getName() == null) {
log.debug("getName is null");
comp.setName(comp.getClientId(context));
}
RendererUtils.writeAttribute(Attributes.NAME, comp.getName(), writer);
-
+
/* default value is false, write only if value of attribute emptyok is true */
if (comp.isEmptyok()) RendererUtils.writeAttribute(Attributes.EMPTY_OK, "true", writer);
-
+
RendererUtils.writeAttribute(Attributes.FORMAT, comp.getFormat(), writer);
RendererUtils.writeAttribute(Attributes.MAX_LENGTH, comp.getMaxlength(), writer);
RendererUtils.writeAttribute(Attributes.SIZE, comp.getSize(), writer);
@@ -93,20 +89,20 @@
RendererUtils.writeAttribute(Attributes.TITLE, comp.getTitle(), writer);
RendererUtils.writeAttribute(Attributes.VALUE, comp.getValue(), writer);
RendererUtils.writeAttribute(Attributes.TYPE, "password", writer);
-
+
writer.endElement(Attributes.INPUT);
}
-
+
public void decode(FacesContext context, UIComponent component) {
log.debug("decode(" + component.getId() + ")");
if (component == null || context == null) throw new NullPointerException();
if (!(component instanceof InputSecret))
log.error("Component " + component.getClass().getName() + " is no InputSecret, cannot be converted!");
-
+
InputSecret comp = (InputSecret)component;
-
+
Map map = context.getExternalContext().getRequestParameterMap();
-
+
// Set the submitted value of this UIInput component
if (map.containsKey(comp.getName())){
log.debug("Parameter:" + comp.getName() + " was found in the request. Value: " + map.get(comp.getName()));
@@ -114,7 +110,7 @@
//comp.setValue(map.get(comp.getName()));
}
}
-
+
/** Overrides method getConvertedValue */
public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue) throws javax.faces.convert.ConverterException {
return(RendererUtils.convertToObject(context, component));
Modified: myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/InputTextRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/InputTextRenderer.java?rev=169655&r1=169654&r2=169655&view=diff
==============================================================================
--- myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/InputTextRenderer.java (original)
+++ myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/InputTextRenderer.java Wed May 11 09:45:06 2005
@@ -1,12 +1,12 @@
/*
* Copyright 2004 The Apache Software Foundation.
- *
+ *
* Licensed 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 KIND, either express or implied.
@@ -30,85 +30,81 @@
/**
* @author <a href="mailto:Jiri.Zaloudek@ivancice.cz">Jiri Zaloudek</a> (latest modification by $Author$)
- * @version $Revision$ $Date$
- * $Log$
- * Revision 1.1 2004/12/30 09:37:26 matzew
- * added a new RenderKit for WML. Thanks to Jirí aloudek
- *
+ * @version $Revision$ $Date$
*/
public class InputTextRenderer extends WmlRenderer {
private static Log log = LogFactory.getLog(InputTextRenderer.class);
-
+
/** Creates a new instance of TextRenderer */
public InputTextRenderer() {
super();
log.debug("created object " + this.getClass().getName());
}
-
+
public void encodeBegin(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeBegin(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
}
-
+
public void encodeChildren(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeChildren(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
}
-
+
public void encodeEnd(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeEnd(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
-
+
if (!component.isRendered()) return;
-
+
InputText comp = (InputText)component;
-
+
ResponseWriter writer = context.getResponseWriter();
writer.startElement(Attributes.INPUT, component);
-
+
RendererUtils.writeAttribute(Attributes.ID, comp.getClientId(context), writer);
RendererUtils.writeAttribute(Attributes.STYLE_CLASS, comp.getStyleClass(), writer);
RendererUtils.writeAttribute(Attributes.XML_LANG, comp.getXmllang(), writer);
-
+
/* attribute name is not required. If is not set, name value equals component id */
if (comp.getName() == null) {
log.debug("getName is null");
comp.setName(comp.getClientId(context));
}
RendererUtils.writeAttribute(Attributes.NAME, comp.getName(), writer);
-
+
/* default value is false, write only if value of attribute emptyok is true */
if (comp.isEmptyok()) RendererUtils.writeAttribute(Attributes.EMPTY_OK, "true", writer);
-
+
RendererUtils.writeAttribute(Attributes.FORMAT, comp.getFormat(), writer);
RendererUtils.writeAttribute(Attributes.MAX_LENGTH, comp.getMaxlength(), writer);
RendererUtils.writeAttribute(Attributes.SIZE, comp.getSize(), writer);
RendererUtils.writeAttribute(Attributes.TABINDEX, comp.getTabindex(), writer);
RendererUtils.writeAttribute(Attributes.TITLE, comp.getTitle(), writer);
RendererUtils.writeAttribute(Attributes.VALUE, comp.getValue(), writer);
-
+
// value "text" is default, don't must be written
//RenderUtils.writeAttribute(Attributes.TYPE, "text", writer);
-
+
writer.endElement(Attributes.INPUT);
}
-
+
public void decode(FacesContext context, UIComponent component) {
log.debug("decode(" + component.getId() + ")");
if (component == null || context == null) throw new NullPointerException();
if (!(component instanceof InputText))
log.error("Component " + component.getClass().getName() + " is no InputText, cannot be converted!");
-
+
InputText comp = (InputText)component;
-
+
Map map = context.getExternalContext().getRequestParameterMap();
-
+
// Set the submitted value of this UIInput component
if (map.containsKey(comp.getName())){
log.debug("Parameter:" + comp.getName() + " was found in the request. Value: " + (String)map.get(comp.getName()));
@@ -116,7 +112,7 @@
//comp.setValue(map.get(comp.getName()));
}
}
-
+
/** Overrides method getConvertedValue */
public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue) throws javax.faces.convert.ConverterException {
return(RendererUtils.convertToObject(context, component));
Modified: myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/MessageRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/MessageRenderer.java?rev=169655&r1=169654&r2=169655&view=diff
==============================================================================
--- myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/MessageRenderer.java (original)
+++ myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/MessageRenderer.java Wed May 11 09:45:06 2005
@@ -1,12 +1,12 @@
/*
* Copyright 2004 The Apache Software Foundation.
- *
+ *
* Licensed 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 KIND, either express or implied.
@@ -29,52 +29,48 @@
/**
* @author <a href="mailto:Jiri.Zaloudek@ivancice.cz">Jiri Zaloudek</a> (latest modification by $Author$)
- * @version $Revision$ $Date$
- * $Log$
- * Revision 1.1 2004/12/30 09:37:26 matzew
- * added a new RenderKit for WML. Thanks to Jirí aloudek
- *
+ * @version $Revision$ $Date$
*/
public class MessageRenderer extends WmlRenderer {
private static Log log = LogFactory.getLog(MessageRenderer.class);
-
+
/** Creates a new instance of TextRenderer */
public MessageRenderer() {
super();
log.debug("created object " + this.getClass().getName());
}
-
+
public void encodeBegin(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeBegin(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
}
-
+
public void encodeChildren(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeChildren(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
}
-
+
public void encodeEnd(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeEnd(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
if (!component.isRendered()) return;
-
- Message comp = (Message)component;
+
+ Message comp = (Message)component;
ResponseWriter writer = context.getResponseWriter();
-
+
String _for = comp.getFor();
if (_for == null) log.error("Attribute 'for' of UIMessage must not be null.");
-
+
UIComponent forComponent = component.findComponent(_for);
if (forComponent == null) log.error("Unable to find component '" + _for + "'. Can not render UIMessage component.");
-
- Iterator iter = context.getMessages(forComponent.getClientId(context));
+
+ Iterator iter = context.getMessages(forComponent.getClientId(context));
if (iter.hasNext()) {
FacesMessage message = (FacesMessage)iter.next();
if (comp.isShowSummary())
@@ -83,7 +79,7 @@
writer.write(message.getDetail());
}
}
-
+
public void decode(FacesContext context, UIComponent component) {
if (component == null ) throw new NullPointerException();
}
Modified: myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/MessagesRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/MessagesRenderer.java?rev=169655&r1=169654&r2=169655&view=diff
==============================================================================
--- myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/MessagesRenderer.java (original)
+++ myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/MessagesRenderer.java Wed May 11 09:45:06 2005
@@ -1,12 +1,12 @@
/*
* Copyright 2004 The Apache Software Foundation.
- *
+ *
* Licensed 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 KIND, either express or implied.
@@ -31,54 +31,50 @@
/**
* @author <a href="mailto:Jiri.Zaloudek@ivancice.cz">Jiri Zaloudek</a> (latest modification by $Author$)
- * @version $Revision$ $Date$
- * $Log$
- * Revision 1.1 2004/12/30 09:37:26 matzew
- * added a new RenderKit for WML. Thanks to Jirí aloudek
- *
+ * @version $Revision$ $Date$
*/
public class MessagesRenderer extends WmlRenderer {
private static Log log = LogFactory.getLog(MessagesRenderer.class);
-
+
/** Creates a new instance of TextRenderer */
public MessagesRenderer() {
super();
log.debug("created object " + this.getClass().getName());
}
-
+
public void encodeBegin(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeBegin(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
}
-
+
public void encodeChildren(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeChildren(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
}
-
+
public void encodeEnd(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeEnd(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
if (!component.isRendered()) return;
-
+
Messages comp = (Messages)component;
ResponseWriter writer = context.getResponseWriter();
-
+
MessagesIterator messagesIterator = new MessagesIterator(context, comp.isGlobalOnly());
-
+
if (messagesIterator.hasNext()) {
String layout = comp.getLayout();
-
+
if (layout == null || layout.equalsIgnoreCase(Attributes.LIST)) {
while(messagesIterator.hasNext()) {
renderMessage(context, comp, (FacesMessage)messagesIterator.next());
-
+
if (messagesIterator.hasNext())
writer.startElement(Attributes.BR, comp);
}
@@ -86,15 +82,15 @@
else { // renderers messages as a table
writer.startElement(Attributes.TABLE, comp);
writer.writeAttribute(Attributes.COLUMNS, "1", null);
-
+
while(messagesIterator.hasNext()) {
writer.startElement(Attributes.TR, comp);
writer.startElement(Attributes.TD, comp);
renderMessage(context, comp, (FacesMessage)messagesIterator.next());
-
+
if (messagesIterator.hasNext())
writer.startElement(Attributes.BR, comp);
-
+
writer.endElement(Attributes.TD);
writer.endElement(Attributes.TR);
}
@@ -102,27 +98,27 @@
}
}
}
-
+
private void renderMessage(FacesContext context, Messages comp, FacesMessage message) throws java.io.IOException{
ResponseWriter writer = context.getResponseWriter();
-
+
if (comp.isShowSummary())
writer.write(message.getSummary());
if (comp.isShowDetail())
writer.write(message.getDetail());
}
-
+
public void decode(FacesContext context, UIComponent component) {
if (component == null ) throw new NullPointerException();
}
-
+
private static class MessagesIterator implements Iterator {
private FacesContext _facesContext;
private Iterator _globalMessagesIterator;
private Iterator _clientIdsWithMessagesIterator;
private Iterator _componentMessagesIterator = null;
private String _clientId = null;
-
+
public MessagesIterator(FacesContext facesContext, boolean globalOnly) {
_facesContext = facesContext;
_globalMessagesIterator = facesContext.getMessages(null);
@@ -135,13 +131,13 @@
_componentMessagesIterator = null;
_clientId = null;
}
-
+
public boolean hasNext() {
return _globalMessagesIterator.hasNext() ||
_clientIdsWithMessagesIterator.hasNext() ||
(_componentMessagesIterator != null && _componentMessagesIterator.hasNext());
}
-
+
public Object next() {
if (_globalMessagesIterator.hasNext()) {
return _globalMessagesIterator.next();
@@ -155,15 +151,15 @@
return _componentMessagesIterator.next();
}
}
-
+
public void remove() {
throw new UnsupportedOperationException(this.getClass().getName() + " UnsupportedOperationException");
}
-
+
public String getClientId() {
return _clientId;
}
}
-
+
}
Modified: myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/OutputLinkRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/OutputLinkRenderer.java?rev=169655&r1=169654&r2=169655&view=diff
==============================================================================
--- myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/OutputLinkRenderer.java (original)
+++ myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/OutputLinkRenderer.java Wed May 11 09:45:06 2005
@@ -1,12 +1,12 @@
/*
* Copyright 2004 The Apache Software Foundation.
- *
+ *
* Licensed 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 KIND, either express or implied.
@@ -32,38 +32,34 @@
/**
* @author <a href="mailto:Jiri.Zaloudek@ivancice.cz">Jiri Zaloudek</a> (latest modification by $Author$)
- * @version $Revision$ $Date$
- * $Log$
- * Revision 1.1 2004/12/30 09:37:26 matzew
- * added a new RenderKit for WML. Thanks to Jirí aloudek
- *
+ * @version $Revision$ $Date$
*/
public class OutputLinkRenderer extends WmlRenderer {
private static Log log = LogFactory.getLog(OutputLinkRenderer.class);
-
+
/** Creates a new instance of TextRenderer */
public OutputLinkRenderer() {
super();
log.debug("created object " + this.getClass().getName());
}
-
+
public boolean getRendersChildren(){
return(true);
}
-
+
public void encodeBegin(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeBegin(" + component.getId() + ")");
-
+
if (context == null || component == null) {
throw new NullPointerException();
}
if (!component.isRendered()) return;
-
+
ResponseWriter writer = context.getResponseWriter();
OutputLink comp = (OutputLink)component;
-
+
String href = RendererUtils.convertToString(context, component);
-
+
List child = component.getChildren();
for (int i = 0; i < child.size(); i++){ // insert parameters from UIParameter components
if (child.get(i) instanceof UIParameter){
@@ -71,7 +67,7 @@
}
}
href = context.getExternalContext().encodeResourceURL(href);
-
+
writer.startElement(Attributes.A, component);
RendererUtils.writeAttribute(Attributes.HREF, href, writer);
RendererUtils.writeAttribute(Attributes.ID, comp.getClientId(context), writer);
@@ -80,39 +76,39 @@
RendererUtils.writeAttribute(Attributes.TITLE, comp.getTitle(), writer);
writer.flush();
}
-
+
public void encodeChildren(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeChildren(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
if (!component.isRendered()) return;
-
+
RendererUtils.renderChildren(context, component);
}
-
+
public void encodeEnd(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeEnd(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
if (!component.isRendered()) return;
-
+
ResponseWriter writer = context.getResponseWriter();
writer.endElement(Attributes.A);
}
-
+
public void decode(FacesContext context, UIComponent component) {
if (component == null ) throw new NullPointerException();
}
-
+
private String insertParam(String href, UIParameter param, String encoding) throws java.io.IOException {
String name = (String)param.getName();
String value = (String)param.getValue();
-
+
return(RendererUtils.insertGetParam(href, name, value, encoding));
}
-
+
/** Overrides method getConvertedValue */
public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue) throws javax.faces.convert.ConverterException {
return(RendererUtils.convertToObject(context, component));
Modified: myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/OutputTextRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/OutputTextRenderer.java?rev=169655&r1=169654&r2=169655&view=diff
==============================================================================
--- myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/OutputTextRenderer.java (original)
+++ myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/OutputTextRenderer.java Wed May 11 09:45:06 2005
@@ -1,12 +1,12 @@
/*
* Copyright 2004 The Apache Software Foundation.
- *
+ *
* Licensed 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 KIND, either express or implied.
@@ -28,63 +28,59 @@
/**
* @author <a href="mailto:Jiri.Zaloudek@ivancice.cz">Jiri Zaloudek</a> (latest modification by $Author$)
- * @version $Revision$ $Date$
- * $Log$
- * Revision 1.1 2004/12/30 09:37:26 matzew
- * added a new RenderKit for WML. Thanks to Jirí aloudek
- *
+ * @version $Revision$ $Date$
*/
public class OutputTextRenderer extends WmlRenderer {
private static Log log = LogFactory.getLog(OutputTextRenderer.class);
-
+
/** Creates a new instance of TextRenderer */
public OutputTextRenderer() {
super();
log.debug("created object " + this.getClass().getName());
}
-
+
public void encodeBegin(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeBegin(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
}
-
+
public void encodeChildren(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeChildren(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
}
-
+
public void encodeEnd(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeEnd(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
-
+
if (!component.isRendered()) return;
-
+
OutputText comp = (OutputText)component;
-
+
ResponseWriter writer = context.getResponseWriter();
-
+
if (comp.getValue() != null) {
String textValue = RendererUtils.convertToString(context, component);
log.debug("OutputText value:" + textValue);
-
+
if (comp.isEscape())
writer.writeText(textValue, Attributes.VALUE);
else
writer.write(textValue);
-
+
}
}
-
+
public void decode(FacesContext context, UIComponent component) {
if (component == null ) throw new NullPointerException();
}
-
+
/** Overrides method getConvertedValue */
public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue) throws javax.faces.convert.ConverterException {
return(RendererUtils.convertToObject(context, component));
Modified: myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/SelectBooleanRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/SelectBooleanRenderer.java?rev=169655&r1=169654&r2=169655&view=diff
==============================================================================
--- myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/SelectBooleanRenderer.java (original)
+++ myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/SelectBooleanRenderer.java Wed May 11 09:45:06 2005
@@ -1,12 +1,12 @@
/*
* Copyright 2004 The Apache Software Foundation.
- *
+ *
* Licensed 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 KIND, either express or implied.
@@ -30,22 +30,18 @@
/**
* @author <a href="mailto:Jiri.Zaloudek@ivancice.cz">Jiri Zaloudek</a> (latest modification by $Author$)
- * @version $Revision$ $Date$
- * $Log$
- * Revision 1.1 2004/12/30 09:37:26 matzew
- * added a new RenderKit for WML. Thanks to Jirí aloudek
- *
+ * @version $Revision$ $Date$
*/
public class SelectBooleanRenderer extends WmlRenderer {
private static Log log = LogFactory.getLog(SelectBooleanRenderer.class);
private static String OPTION_VALUE = "bool";
-
+
/** Creates a new instance of renderer */
public SelectBooleanRenderer() {
super();
log.debug("created object " + this.getClass().getName());
}
-
+
public void encodeBegin(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeBegin(" + component.getId() + ")");
if (context == null || component == null) {
@@ -54,76 +50,76 @@
if (!component.isRendered()) return;
SelectBoolean comp = (SelectBoolean)component;
-
+
ResponseWriter writer = context.getResponseWriter();
-
+
writer.startElement(Attributes.SELECT, component);
RendererUtils.writeAttribute(Attributes.ID, comp.getClientId(context), writer);
RendererUtils.writeAttribute(Attributes.STYLE_CLASS, comp.getStyleClass(), writer);
RendererUtils.writeAttribute(Attributes.XML_LANG, comp.getXmllang(), writer);
-
+
/* attribute name is not required. If is not set, name value equals component id */
if (comp.getName() == null) {
log.debug("getName is null");
comp.setName(comp.getClientId(context));
}
RendererUtils.writeAttribute(Attributes.NAME, comp.getName(), writer);
-
+
RendererUtils.writeAttribute(Attributes.TABINDEX, comp.getTabindex(), writer);
RendererUtils.writeAttribute(Attributes.TITLE, comp.getTitle(), writer);
-
+
if (comp.isSelected())
RendererUtils.writeAttribute(Attributes.VALUE, OPTION_VALUE, writer);
else { /* don't check off */ }
-
+
// multiple
- RendererUtils.writeAttribute(Attributes.MULTIPLE, "true", writer);
-
+ RendererUtils.writeAttribute(Attributes.MULTIPLE, "true", writer);
+
// write option
- writer.startElement(Attributes.OPTION, component);
+ writer.startElement(Attributes.OPTION, component);
RendererUtils.writeAttribute(Attributes.VALUE, OPTION_VALUE, writer);
}
-
+
public void encodeChildren(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeChildren(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
if (!component.isRendered()) return;
-
+
RendererUtils.renderChildren(context, component);
}
-
+
public void encodeEnd(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeEnd(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
- }
+ }
if (!component.isRendered()) return;
-
+
ResponseWriter writer = context.getResponseWriter();
-
- writer.endElement(Attributes.OPTION);
+
+ writer.endElement(Attributes.OPTION);
writer.endElement(Attributes.SELECT);
}
-
+
public void decode(FacesContext context, UIComponent component) {
log.debug("decode(" + component.getId() + ")");
if (component == null || context == null) throw new NullPointerException();
if (!(component instanceof SelectBoolean))
log.error("Component " + component.getClass().getName() + " is no SelectMany component, cannot be converted!");
-
+
SelectBoolean comp = (SelectBoolean)component;
-
+
Map map = context.getExternalContext().getRequestParameterMap();
-
+
// Set the submitted value of this UISelectOne component
if (map.containsKey(comp.getName())){
log.debug("Parameter:" + comp.getName() + " was found in the request. Value: " + (String)map.get(comp.getName()));
-
- String value = (String)map.get(comp.getName());
+
+ String value = (String)map.get(comp.getName());
if (OPTION_VALUE.equalsIgnoreCase(value)) comp.setSelected(true);
- else comp.setSelected(false);
+ else comp.setSelected(false);
}
}
}
Modified: myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/SelectManyRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/SelectManyRenderer.java?rev=169655&r1=169654&r2=169655&view=diff
==============================================================================
--- myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/SelectManyRenderer.java (original)
+++ myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/SelectManyRenderer.java Wed May 11 09:45:06 2005
@@ -1,12 +1,12 @@
/*
* Copyright 2004 The Apache Software Foundation.
- *
+ *
* Licensed 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 KIND, either express or implied.
@@ -37,144 +37,140 @@
/**
* @author <a href="mailto:Jiri.Zaloudek@ivancice.cz">Jiri Zaloudek</a> (latest modification by $Author$)
- * @version $Revision$ $Date$
- * $Log$
- * Revision 1.1 2004/12/30 09:37:26 matzew
- * added a new RenderKit for WML. Thanks to Jirí aloudek
- *
+ * @version $Revision$ $Date$
*/
public class SelectManyRenderer extends WmlRenderer {
private static Log log = LogFactory.getLog(SelectManyRenderer.class);
-
+
/** Creates a new instance of TextRenderer */
public SelectManyRenderer() {
super();
log.debug("created object " + this.getClass().getName());
}
-
+
public void encodeBegin(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeBegin(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
}
-
+
public void encodeChildren(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeChildren(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
}
-
+
public void encodeEnd(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeEnd(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
-
+
if (!component.isRendered()) return;
-
+
SelectMany comp = (SelectMany)component;
-
+
ResponseWriter writer = context.getResponseWriter();
-
+
writer.startElement(Attributes.SELECT, component);
RendererUtils.writeAttribute(Attributes.ID, comp.getClientId(context), writer);
RendererUtils.writeAttribute(Attributes.STYLE_CLASS, comp.getStyleClass(), writer);
RendererUtils.writeAttribute(Attributes.XML_LANG, comp.getXmllang(), writer);
/* TODO: attribute "required" */
-
+
/* attribute name is not required. If is not set, name value equals component id */
if (comp.getName() == null) {
log.debug("getName is null");
comp.setName(comp.getClientId(context));
}
RendererUtils.writeAttribute(Attributes.NAME, comp.getName(), writer);
-
+
RendererUtils.writeAttribute(Attributes.TABINDEX, comp.getTabindex(), writer);
RendererUtils.writeAttribute(Attributes.TITLE, comp.getTitle(), writer);
-
+
// RenderUtils.writeAttribute(Attributes.VALUE, convertSelectedValuesToString(comp.getSelectedValues()), writer);
RendererUtils.writeAttribute(Attributes.VALUE, convertSelectedValuesToString(comp.getSelectedValues()), writer);
-
+
// multiple
RendererUtils.writeAttribute(Attributes.MULTIPLE, "true", writer);
-
+
List child = component.getChildren();
for (int i = 0; i < child.size(); i++){
if (child.get(i) instanceof UISelectItem){
UISelectItem item = (UISelectItem)child.get(i);
WmlRenderUtils.writeOption((SelectItem)item.getValue(), comp, writer);
}
- if (child.get(i) instanceof UISelectItems){
- UISelectItems item = (UISelectItems)child.get(i);
+ if (child.get(i) instanceof UISelectItems){
+ UISelectItems item = (UISelectItems)child.get(i);
WmlRenderUtils.writeOptions(item.getValue(), comp, writer);
}
}
-
+
writer.endElement(Attributes.SELECT);
}
-
+
public void decode(FacesContext context, UIComponent component) {
log.debug("decode(" + component.getId() + ")");
if (component == null || context == null) throw new NullPointerException();
if (!(component instanceof SelectMany))
log.error("Component " + component.getClass().getName() + " is no SelectMany component, cannot be converted!");
-
+
SelectMany comp = (SelectMany)component;
-
+
Map map = context.getExternalContext().getRequestParameterMap();
-
+
// Set the submitted value of this UISelectOne component
if (map.containsKey(comp.getName())){
log.debug("Parameter:" + comp.getName() + " was found in the request. Value: " + (String)map.get(comp.getName()));
-
- String value = (String)map.get(comp.getName());
+
+ String value = (String)map.get(comp.getName());
comp.setSelectedValues(convertSubmittedValueToObject(value));
}
}
-
+
/** Overrides method getConvertedValue */
public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue) throws javax.faces.convert.ConverterException {
if (!(component instanceof UISelectMany))
throw new IllegalArgumentException("Expected component of type UISelectMany. Cannot convert selected value.");
-
+
UISelectMany comp = (UISelectMany)component;
-
+
return(RendererUtils.convertUISelectManyToObject(context, comp, submittedValue));
- }
-
- /** Returns WML String representating the selected options.
+ }
+
+ /** Returns WML String representating the selected options.
* @param obj Object returned from getSelectedValue(). This object must be a String[] type.
- * @return String representing selected options for wml code. Is rendered as a value of "value" attribute in the select element.
+ * @return String representing selected options for wml code. Is rendered as a value of "value" attribute in the select element.
*/
private String convertSelectedValuesToString(Object obj){
- if (obj == null) return(null);
-
+ if (obj == null) return(null);
+
if (!(obj instanceof String[]))
- throw new ClassCastException("Value of SelectMany component must be a String[] type.");
-
+ throw new ClassCastException("Value of SelectMany component must be a String[] type.");
+
StringBuffer buff = new StringBuffer();
-
+
String[] selected = (String[])obj;
for (int i = 0 ; i < selected.length; i++){
String item = selected[i];
-
+
buff.append(item);
-
+
// insert separator
- if (i < selected.length - 1) buff.append(Attributes.SELECT_MANY_SEPARATOR);
+ if (i < selected.length - 1) buff.append(Attributes.SELECT_MANY_SEPARATOR);
}
return (buff.toString());
}
-
+
/** Tokenizes submitted value from request parameter to the String array . */
private String[] convertSubmittedValueToObject(String value){
StringTokenizer st = new StringTokenizer(value, Attributes.SELECT_MANY_SEPARATOR);
-
+
String[] ret = new String[st.countTokens()];
-
+
log.debug("Selected option:");
for (int i = 0; st.hasMoreTokens(); i++){
ret[i] = st.nextToken();
Modified: myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/SelectOneRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/SelectOneRenderer.java?rev=169655&r1=169654&r2=169655&view=diff
==============================================================================
--- myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/SelectOneRenderer.java (original)
+++ myfaces/trunk/src/wml/org/apache/myfaces/wap/renderkit/wml/SelectOneRenderer.java Wed May 11 09:45:06 2005
@@ -1,12 +1,12 @@
/*
* Copyright 2004 The Apache Software Foundation.
- *
+ *
* Licensed 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 KIND, either express or implied.
@@ -35,92 +35,88 @@
/**
* @author <a href="mailto:Jiri.Zaloudek@ivancice.cz">Jiri Zaloudek</a> (latest modification by $Author$)
- * @version $Revision$ $Date$
- * $Log$
- * Revision 1.1 2004/12/30 09:37:26 matzew
- * added a new RenderKit for WML. Thanks to Jirí aloudek
- *
+ * @version $Revision$ $Date$
*/
public class SelectOneRenderer extends WmlRenderer {
private static Log log = LogFactory.getLog(SelectOneRenderer.class);
-
+
/** Creates a new instance of TextRenderer */
public SelectOneRenderer() {
super();
log.debug("created object " + this.getClass().getName());
}
-
+
public void encodeBegin(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeBegin(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
}
-
+
public void encodeChildren(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeChildren(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
}
-
+
public void encodeEnd(FacesContext context, UIComponent component) throws java.io.IOException {
log.debug("encodeEnd(" + component.getId() + ")");
if (context == null || component == null) {
throw new NullPointerException();
}
-
+
if (!component.isRendered()) return;
-
+
SelectOne comp = (SelectOne)component;
-
+
ResponseWriter writer = context.getResponseWriter();
-
+
writer.startElement(Attributes.SELECT, component);
RendererUtils.writeAttribute(Attributes.ID, comp.getClientId(context), writer);
RendererUtils.writeAttribute(Attributes.STYLE_CLASS, comp.getStyleClass(), writer);
RendererUtils.writeAttribute(Attributes.XML_LANG, comp.getXmllang(), writer);
/* TODO: attribute "required" */
-
+
/* attribute name is not required. If is not set, name value equals component id */
if (comp.getName() == null) {
log.debug("getName is null");
comp.setName(comp.getClientId(context));
}
RendererUtils.writeAttribute(Attributes.NAME, comp.getName(), writer);
-
+
RendererUtils.writeAttribute(Attributes.TABINDEX, comp.getTabindex(), writer);
RendererUtils.writeAttribute(Attributes.TITLE, comp.getTitle(), writer);
RendererUtils.writeAttribute(Attributes.VALUE, comp.getValue(), writer);
-
+
// "false" is default. Don't must be written.
//RenderUtils.writeAttribute(Attributes.MULTIPLE, "false", writer);
-
+
List child = component.getChildren();
for (int i = 0; i < child.size(); i++){
if (child.get(i) instanceof UISelectItem){
UISelectItem item = (UISelectItem)child.get(i);
WmlRenderUtils.writeOption((SelectItem)item.getValue(), comp, writer);
}
- if (child.get(i) instanceof UISelectItems){
- UISelectItems item = (UISelectItems)child.get(i);
+ if (child.get(i) instanceof UISelectItems){
+ UISelectItems item = (UISelectItems)child.get(i);
WmlRenderUtils.writeOptions(item.getValue(), comp, writer);
}
}
-
+
writer.endElement(Attributes.SELECT);
}
-
+
public void decode(FacesContext context, UIComponent component) {
log.debug("decode(" + component.getId() + ")");
if (component == null || context == null) throw new NullPointerException();
if (!(component instanceof SelectOne))
log.error("Component " + component.getClass().getName() + " is no SelectOne component, cannot be converted!");
-
+
SelectOne comp = (SelectOne)component;
-
+
Map map = context.getExternalContext().getRequestParameterMap();
-
+
// Set the submitted value of this UISelectOne component
if (map.containsKey(comp.getName())){
log.debug("Parameter:" + comp.getName() + " was found in the request. Value: " + (String)map.get(comp.getName()));
@@ -128,10 +124,10 @@
//comp.setValue(map.get(comp.getName()));
}
}
-
+
/** Overrides method getConvertedValue */
public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue) throws javax.faces.convert.ConverterException {
return(RendererUtils.convertToObject(context, component));
- }
+ }
}