You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2006/08/01 19:44:01 UTC
svn commit: r427657 [32/42] - in /myfaces:
core/trunk/api/src/main/java/javax/faces/component/
core/trunk/api/src/test/java/javax/faces/
core/trunk/api/src/test/java/javax/faces/application/
core/trunk/api/src/test/java/javax/faces/component/ core/trun...
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/scope/ScopeUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/scope/ScopeUtils.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/scope/ScopeUtils.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/scope/ScopeUtils.java Tue Aug 1 10:43:28 2006
@@ -1,90 +1,90 @@
-/**
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.myfaces.custom.scope;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.faces.context.FacesContext;
-
-/**
- * Small helper to cope with the
- * managed beans within the scope tag
- * handler
- *
- * Thanks Derek Shen to allow me to relicense
- * the Faces Utils code under Apache2
- * this class is derived from it
- *
- * http://www.javaworld.com/javaworld/jw-07-2004/jw-0719-jsf.html
- *
- * @author Werner Punz werpu@gmx.at
- *
- */
-public class ScopeUtils
-{
- private static final String EL_END = "}";
- private static final String EL_BEGIN = "#{";
- private static Log log = LogFactory.getLog(ScopeUtils.class);
-
- /**
- * el checker
- *
- * @param beanName
- * @return true if the bean is a managed bean
- */
- public static final boolean isEl(String beanName)
- {
- beanName = beanName.trim();
- return beanName.startsWith(EL_BEGIN) && beanName.endsWith(EL_END);
- }
-
- /**
- * returns the managed bean from the given bean name
- * @param beanName
- * @return Object managed bean
- */
- public static Object getManagedBean(String beanName)
- {
- if (isEl(beanName))
- {
- if(FacesContext.getCurrentInstance() == null)
- return null;
-
- return FacesContext.getCurrentInstance().getApplication()
- .createValueBinding(beanName).getValue(
- FacesContext.getCurrentInstance());
- }
- else
- {
- try
- {
- if(FacesContext.getCurrentInstance() == null)
- return null;
-
- return FacesContext.getCurrentInstance().getApplication()
- .createValueBinding(EL_BEGIN + beanName + EL_END).getValue(
- FacesContext.getCurrentInstance());
- }
- catch(Exception ex)
- {
- log.info("ScopeContainer not found - has not been initialized.",ex);
- return null;
- }
- }
- }
-
-}
+/**
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.custom.scope;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * Small helper to cope with the
+ * managed beans within the scope tag
+ * handler
+ *
+ * Thanks Derek Shen to allow me to relicense
+ * the Faces Utils code under Apache2
+ * this class is derived from it
+ *
+ * http://www.javaworld.com/javaworld/jw-07-2004/jw-0719-jsf.html
+ *
+ * @author Werner Punz werpu@gmx.at
+ *
+ */
+public class ScopeUtils
+{
+ private static final String EL_END = "}";
+ private static final String EL_BEGIN = "#{";
+ private static Log log = LogFactory.getLog(ScopeUtils.class);
+
+ /**
+ * el checker
+ *
+ * @param beanName
+ * @return true if the bean is a managed bean
+ */
+ public static final boolean isEl(String beanName)
+ {
+ beanName = beanName.trim();
+ return beanName.startsWith(EL_BEGIN) && beanName.endsWith(EL_END);
+ }
+
+ /**
+ * returns the managed bean from the given bean name
+ * @param beanName
+ * @return Object managed bean
+ */
+ public static Object getManagedBean(String beanName)
+ {
+ if (isEl(beanName))
+ {
+ if(FacesContext.getCurrentInstance() == null)
+ return null;
+
+ return FacesContext.getCurrentInstance().getApplication()
+ .createValueBinding(beanName).getValue(
+ FacesContext.getCurrentInstance());
+ }
+ else
+ {
+ try
+ {
+ if(FacesContext.getCurrentInstance() == null)
+ return null;
+
+ return FacesContext.getCurrentInstance().getApplication()
+ .createValueBinding(EL_BEGIN + beanName + EL_END).getValue(
+ FacesContext.getCurrentInstance());
+ }
+ catch(Exception ex)
+ {
+ log.info("ScopeContainer not found - has not been initialized.",ex);
+ return null;
+ }
+ }
+ }
+
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/scope/ScopeUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/scope/UIScope.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/scope/UIScope.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/scope/UIScope.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/scope/UIScope.java Tue Aug 1 10:43:28 2006
@@ -1,96 +1,96 @@
-/*
- * Copyright 2002,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. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package org.apache.myfaces.custom.scope;
-
-import javax.faces.component.UIParameter;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-
-/**
- * Scope control
- * which does basically the same as
- * savestate but bypasses the serialization
- * and utilizes the session directly
- *
- * @author Werner Punz werpu@gmx.at
- * @version $Revision$ $Date$
- */
-
-public class UIScope extends UIParameter
-{
-
- public static final String SCOPE_CONTAINER_KEY = "ScopeContainer";
- public static final String COMPONENT_TYPE = "org.apache.myfaces.Scope";
- public static final String COMPONENT_FAMILY = "javax.faces.Parameter";
-
- ScopeHolder holder = (ScopeHolder) ScopeUtils
- .getManagedBean(UIScope.SCOPE_CONTAINER_KEY);
-
- public String getFamily()
- {
- return COMPONENT_FAMILY;
- }
-
- /**
- * save state saves the scope value binding into the holder map
- */
- public Object saveState(FacesContext context)
- {
- Object values[] = new Object[1];
- values[0] = super.saveState(context);
-
- ValueBinding vb = getValueBinding("value");
- holder.saveScopeEntry(this, context, vb);
- return ((Object) (values));
- }
-
- /**
- * in the restores state phase we get the binding and replace the one from
- * the system with the one from the scope map
- */
- public void restoreState(FacesContext context, Object state)
- {
- Object values[] = (Object[]) state;
- super.restoreState(context, values[0]);
-
- /*
- * fetch the old scoped object and bind it to the value binding if it
- * exists, otherwise there will be no binding
- */
- ValueBinding vb = getValueBinding("value");
- Object oldVal = holder.restoreScopeEntry(vb.getExpressionString());
- if (oldVal == null)
- return;
- vb.setValue(context, oldVal);
- setValueBinding("value", vb);
-
- }
-
- /**
- * reset scope helper which allows to remove the scope from the system
- * within the backend context
- *
- * @param context
- */
- public void resetScope(FacesContext context)
- {
- ValueBinding vb = getValueBinding("value");
- vb.setValue(context, "");
- setValueBinding("value", vb);
- holder.resetScope(vb.getExpressionString());
- }
-}
+/*
+ * Copyright 2002,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. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.myfaces.custom.scope;
+
+import javax.faces.component.UIParameter;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
+/**
+ * Scope control
+ * which does basically the same as
+ * savestate but bypasses the serialization
+ * and utilizes the session directly
+ *
+ * @author Werner Punz werpu@gmx.at
+ * @version $Revision$ $Date$
+ */
+
+public class UIScope extends UIParameter
+{
+
+ public static final String SCOPE_CONTAINER_KEY = "ScopeContainer";
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.Scope";
+ public static final String COMPONENT_FAMILY = "javax.faces.Parameter";
+
+ ScopeHolder holder = (ScopeHolder) ScopeUtils
+ .getManagedBean(UIScope.SCOPE_CONTAINER_KEY);
+
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
+
+ /**
+ * save state saves the scope value binding into the holder map
+ */
+ public Object saveState(FacesContext context)
+ {
+ Object values[] = new Object[1];
+ values[0] = super.saveState(context);
+
+ ValueBinding vb = getValueBinding("value");
+ holder.saveScopeEntry(this, context, vb);
+ return ((Object) (values));
+ }
+
+ /**
+ * in the restores state phase we get the binding and replace the one from
+ * the system with the one from the scope map
+ */
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object values[] = (Object[]) state;
+ super.restoreState(context, values[0]);
+
+ /*
+ * fetch the old scoped object and bind it to the value binding if it
+ * exists, otherwise there will be no binding
+ */
+ ValueBinding vb = getValueBinding("value");
+ Object oldVal = holder.restoreScopeEntry(vb.getExpressionString());
+ if (oldVal == null)
+ return;
+ vb.setValue(context, oldVal);
+ setValueBinding("value", vb);
+
+ }
+
+ /**
+ * reset scope helper which allows to remove the scope from the system
+ * within the backend context
+ *
+ * @param context
+ */
+ public void resetScope(FacesContext context)
+ {
+ ValueBinding vb = getValueBinding("value");
+ vb.setValue(context, "");
+ setValueBinding("value", vb);
+ holder.resetScope(vb.getExpressionString());
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/scope/UIScope.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/Script.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/ScriptRenderer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/ScriptTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectOneRow/SelectOneRow.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectOneRow/SelectOneRow.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectOneRow/SelectOneRow.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectOneRow/SelectOneRow.java Tue Aug 1 10:43:28 2006
@@ -1,75 +1,75 @@
-/*
- * Copyright 2004-2006 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.myfaces.custom.selectOneRow;
-
-import javax.faces.component.UIInput;
-import javax.faces.context.FacesContext;
-
-/**
- * Created by IntelliJ IDEA.
- * User: Ernst
- * Date: 01.02.2006
- * Time: 15:55:59
- * To change this template use File | Settings | File Templates.
- */
-public class SelectOneRow extends UIInput
-{
- private String groupName;
-
- public static final String COMPONENT_TYPE = "org.apache.myfaces.SelectOneRow";
-
- public static final String COMPONENT_FAMILY = "org.apache.myfaces.SelectOneRow";
-
- public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.SelectOneRow";
-
- public SelectOneRow()
- {
- setRendererType(DEFAULT_RENDERER_TYPE);
- }
-
- public String getFamily()
- {
- return COMPONENT_FAMILY;
- }
-
- public String getGroupName()
- {
- return groupName;
- }
-
- public void setGroupName(String groupName)
- {
- this.groupName = groupName;
- }
-
- public void restoreState(FacesContext context, Object state)
- {
-
- Object[] values = (Object[]) state;
- super.restoreState(context, values[0]);
- groupName = (String) values[1];
-
- }
-
- public Object saveState(FacesContext context)
- {
- Object[] values = new Object[2];
- values[0] = super.saveState(context);
- values[1] = groupName;
- return values;
- }
-
-}
+/*
+ * Copyright 2004-2006 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.custom.selectOneRow;
+
+import javax.faces.component.UIInput;
+import javax.faces.context.FacesContext;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Ernst
+ * Date: 01.02.2006
+ * Time: 15:55:59
+ * To change this template use File | Settings | File Templates.
+ */
+public class SelectOneRow extends UIInput
+{
+ private String groupName;
+
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.SelectOneRow";
+
+ public static final String COMPONENT_FAMILY = "org.apache.myfaces.SelectOneRow";
+
+ public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.SelectOneRow";
+
+ public SelectOneRow()
+ {
+ setRendererType(DEFAULT_RENDERER_TYPE);
+ }
+
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
+
+ public String getGroupName()
+ {
+ return groupName;
+ }
+
+ public void setGroupName(String groupName)
+ {
+ this.groupName = groupName;
+ }
+
+ public void restoreState(FacesContext context, Object state)
+ {
+
+ Object[] values = (Object[]) state;
+ super.restoreState(context, values[0]);
+ groupName = (String) values[1];
+
+ }
+
+ public Object saveState(FacesContext context)
+ {
+ Object[] values = new Object[2];
+ values[0] = super.saveState(context);
+ values[1] = groupName;
+ return values;
+ }
+
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectOneRow/SelectOneRow.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectOneRow/SelectOneRowRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectOneRow/SelectOneRowRenderer.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectOneRow/SelectOneRowRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectOneRow/SelectOneRowRenderer.java Tue Aug 1 10:43:28 2006
@@ -1,137 +1,137 @@
-/*
- * Copyright 2004-2006 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.myfaces.custom.selectOneRow;
-
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIData;
-import javax.faces.component.UIInput;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import java.io.IOException;
-import java.util.Map;
-
-/**
- * Created by IntelliJ IDEA.
- * User: Ernst
- * Date: 15.02.2006
- * Time: 15:01:48
- * To change this template use File | Settings | File Templates.
- */
-public class SelectOneRowRenderer extends HtmlRenderer
-{
-
- public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException
- {
- if ((component instanceof SelectOneRow) && component.isRendered())
- {
- SelectOneRow row = (SelectOneRow) component;
- String clientId = row.getClientId(facesContext);
-
- ResponseWriter writer = facesContext.getResponseWriter();
-
- writer.startElement(HTML.INPUT_ELEM, row);
- writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_RADIO, null);
- writer.writeAttribute(HTML.NAME_ATTR, row.getGroupName(), null);
-
- // todo: disabled Attribute
- //writer.writeAttribute(HTML.DISABLED_ATTR, HTML.DISABLED_ATTR, null);
-
- writer.writeAttribute(HTML.ID_ATTR, clientId, null);
-
- if (isRowSelected(row))
- {
- writer.writeAttribute(HTML.CHECKED_ATTR, HTML.CHECKED_ATTR, null);
- }
-
- writer.writeAttribute(HTML.VALUE_ATTR, clientId, null);
-
- HtmlRendererUtils.renderHTMLAttributes(writer, row, HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
-
- HtmlRendererUtils.renderHTMLAttributes(writer, row, new String[]{HTML.ONCLICK_ATTR});
-
- writer.endElement(HTML.INPUT_ELEM);
- }
- }
-
- private boolean isRowSelected(UIComponent component)
- {
- UIInput input = (UIInput) component;
- Object value = input.getValue();
-
- int currentRowIndex = getCurrentRowIndex(component);
-
- return (value != null)
- && (currentRowIndex == ((Long) value).intValue());
-
- }
-
- private int getCurrentRowIndex(UIComponent component)
- {
- UIData uidata = findUIData(component);
- if (uidata == null)
- return -1;
- else
- return uidata.getRowIndex();
- }
-
- protected UIData findUIData(UIComponent uicomponent)
- {
- if (uicomponent == null)
- return null;
- if (uicomponent instanceof UIData)
- return (UIData) uicomponent;
- else
- return findUIData(uicomponent.getParent());
- }
-
- public void decode(FacesContext context, UIComponent uiComponent)
- {
- if (! (uiComponent instanceof SelectOneRow))
- {
- return;
- }
-
- if (!uiComponent.isRendered())
- {
- return;
- }
- SelectOneRow row = (SelectOneRow) uiComponent;
-
- Map requestMap = context.getExternalContext().getRequestParameterMap();
- String postedValue;
-
- if (requestMap.containsKey(row.getGroupName()))
- {
- postedValue = (String) requestMap.get(row.getGroupName());
- String clientId = row.getClientId(context);
- if (clientId.equals(postedValue))
- {
-
- String[] postedValueArray = postedValue.split(":");
- String rowIndex = postedValueArray[postedValueArray.length - 2];
-
- Long newValue = Long.valueOf(rowIndex);
- //the value to go in conversion&validation
- row.setSubmittedValue(newValue);
- row.setValid(true);
- }
- }
- }
-}
+/*
+ * Copyright 2004-2006 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.custom.selectOneRow;
+
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
+import javax.faces.component.UIInput;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Ernst
+ * Date: 15.02.2006
+ * Time: 15:01:48
+ * To change this template use File | Settings | File Templates.
+ */
+public class SelectOneRowRenderer extends HtmlRenderer
+{
+
+ public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException
+ {
+ if ((component instanceof SelectOneRow) && component.isRendered())
+ {
+ SelectOneRow row = (SelectOneRow) component;
+ String clientId = row.getClientId(facesContext);
+
+ ResponseWriter writer = facesContext.getResponseWriter();
+
+ writer.startElement(HTML.INPUT_ELEM, row);
+ writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_RADIO, null);
+ writer.writeAttribute(HTML.NAME_ATTR, row.getGroupName(), null);
+
+ // todo: disabled Attribute
+ //writer.writeAttribute(HTML.DISABLED_ATTR, HTML.DISABLED_ATTR, null);
+
+ writer.writeAttribute(HTML.ID_ATTR, clientId, null);
+
+ if (isRowSelected(row))
+ {
+ writer.writeAttribute(HTML.CHECKED_ATTR, HTML.CHECKED_ATTR, null);
+ }
+
+ writer.writeAttribute(HTML.VALUE_ATTR, clientId, null);
+
+ HtmlRendererUtils.renderHTMLAttributes(writer, row, HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
+
+ HtmlRendererUtils.renderHTMLAttributes(writer, row, new String[]{HTML.ONCLICK_ATTR});
+
+ writer.endElement(HTML.INPUT_ELEM);
+ }
+ }
+
+ private boolean isRowSelected(UIComponent component)
+ {
+ UIInput input = (UIInput) component;
+ Object value = input.getValue();
+
+ int currentRowIndex = getCurrentRowIndex(component);
+
+ return (value != null)
+ && (currentRowIndex == ((Long) value).intValue());
+
+ }
+
+ private int getCurrentRowIndex(UIComponent component)
+ {
+ UIData uidata = findUIData(component);
+ if (uidata == null)
+ return -1;
+ else
+ return uidata.getRowIndex();
+ }
+
+ protected UIData findUIData(UIComponent uicomponent)
+ {
+ if (uicomponent == null)
+ return null;
+ if (uicomponent instanceof UIData)
+ return (UIData) uicomponent;
+ else
+ return findUIData(uicomponent.getParent());
+ }
+
+ public void decode(FacesContext context, UIComponent uiComponent)
+ {
+ if (! (uiComponent instanceof SelectOneRow))
+ {
+ return;
+ }
+
+ if (!uiComponent.isRendered())
+ {
+ return;
+ }
+ SelectOneRow row = (SelectOneRow) uiComponent;
+
+ Map requestMap = context.getExternalContext().getRequestParameterMap();
+ String postedValue;
+
+ if (requestMap.containsKey(row.getGroupName()))
+ {
+ postedValue = (String) requestMap.get(row.getGroupName());
+ String clientId = row.getClientId(context);
+ if (clientId.equals(postedValue))
+ {
+
+ String[] postedValueArray = postedValue.split(":");
+ String rowIndex = postedValueArray[postedValueArray.length - 2];
+
+ Long newValue = Long.valueOf(rowIndex);
+ //the value to go in conversion&validation
+ row.setSubmittedValue(newValue);
+ row.setValid(true);
+ }
+ }
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectOneRow/SelectOneRowRenderer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectOneRow/SelectOneRowTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectOneRow/SelectOneRowTag.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectOneRow/SelectOneRowTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectOneRow/SelectOneRowTag.java Tue Aug 1 10:43:28 2006
@@ -1,243 +1,243 @@
-/*
- * Copyright 2004-2006 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.myfaces.custom.selectOneRow;
-
-import org.apache.myfaces.shared_tomahawk.taglib.html.HtmlInputTagBase;
-
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
-
-
-import javax.faces.application.Application;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIInput;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-
-/**
- * Created by IntelliJ IDEA.
- * User: Ernst
- * Date: 01.02.2006
- * Time: 15:49:56
- * To change this template use File | Settings | File Templates.
- */
-public class SelectOneRowTag extends HtmlInputTagBase
-{
- public String getComponentType()
- {
- return SelectOneRow.COMPONENT_TYPE;
- }
-
- public String getRendererType()
- {
- return SelectOneRow.DEFAULT_RENDERER_TYPE;
- }
-
-// UIComponent attributes --> already implemented in UIComponentTagBase
-
- // user role attributes --> already implemented in UIComponentTagBase
-
- // HTML universal attributes --> already implemented in HtmlComponentTagBase
-
- // HTML event handler attributes --> already implemented in HtmlComponentTagBase
-
- // HTML input attributes relevant for password-input
- private String _accesskey;
- private String _align;
- private String _alt;
- private String _datafld;
- private String _datasrc;
- private String _dataformatas;
- private String _disabled;
- private String _maxlength;
- private String _onblur;
- private String _onchange;
- private String _onclick;
- private String _onfocus;
- private String _onselect;
- private String _readonly;
- private String _size;
- private String _tabindex;
-
- // UIOutput attributes
- // value and converterId --> already implemented in UIComponentTagBase
-
- // UIInput attributes
- // --> already implemented in HtmlInputTagBase
-
- // HTMLInputSecret attributes
- private String _groupName;
-
- public void release()
- {
- super.release();
- _accesskey = null;
- _align = null;
- _alt = null;
- _datafld = null;
- _datasrc = null;
- _dataformatas = null;
- _disabled = null;
- _maxlength = null;
- _onblur = null;
- _onchange = null;
- _onclick = null;
- _onfocus = null;
- _onselect = null;
- _readonly = null;
- _size = null;
- _tabindex = null;
- _groupName = null;
- }
-
- protected void setProperties(UIComponent component)
- {
- super.setProperties(component);
-
- setStringProperty(component, HTML.ACCESSKEY_ATTR, _accesskey);
- setStringProperty(component, HTML.ALIGN_ATTR, _align);
- setStringProperty(component, HTML.ALT_ATTR, _alt);
- setStringProperty(component, HTML.DATAFLD_ATTR, _datafld);
- setStringProperty(component, HTML.DATASRC_ATTR, _datasrc);
- setStringProperty(component, HTML.DATAFORMATAS_ATTR, _dataformatas);
- setBooleanProperty(component, HTML.DISABLED_ATTR, _disabled);
- setIntegerProperty(component, HTML.MAXLENGTH_ATTR, _maxlength);
- setStringProperty(component, HTML.ONBLUR_ATTR, _onblur);
- setStringProperty(component, HTML.ONCHANGE_ATTR, _onchange);
- setStringProperty(component, HTML.ONCLICK_ATTR, _onclick);
- setStringProperty(component, HTML.ONFOCUS_ATTR, _onfocus);
- setStringProperty(component, HTML.ONSELECT_ATTR, _onselect);
- setBooleanProperty(component, HTML.READONLY_ATTR, _readonly);
- setIntegerProperty(component, HTML.SIZE_ATTR, _size);
- setStringProperty(component, HTML.TABINDEX_ATTR, _tabindex);
-
- UIInput singleInputRowSelect = (UIInput) component;
- singleInputRowSelect.getAttributes().put("groupName", _groupName);
-
- if (getValue() != null)
- {
-
- if (isValueReference(getValue()))
- {
- FacesContext context = FacesContext.getCurrentInstance();
- Application app = context.getApplication();
- ValueBinding binding = app.createValueBinding(getValue());
- singleInputRowSelect.setValueBinding("value", binding);
-
- }
-
- }
- }
-
- public void setAccesskey(String accesskey)
- {
- _accesskey = accesskey;
- }
-
- public void setAlign(String align)
- {
- _align = align;
- }
-
- public void setAlt(String alt)
- {
- _alt = alt;
- }
-
- public void setDatafld(String datafld)
- {
- _datafld = datafld;
- }
-
- public void setDatasrc(String datasrc)
- {
- _datasrc = datasrc;
- }
-
- public void setDataformatas(String dataformatas)
- {
- _dataformatas = dataformatas;
- }
-
- public void setDisabled(String disabled)
- {
- _disabled = disabled;
- }
-
- public void setMaxlength(String maxlength)
- {
- _maxlength = maxlength;
- }
-
- public void setOnblur(String onblur)
- {
- _onblur = onblur;
- }
-
- public void setOnchange(String onchange)
- {
- _onchange = onchange;
- }
-
- public void setOnclick(String onclick)
- {
- _onclick = onclick;
- }
-
- public void setOnfocus(String onfocus)
- {
- _onfocus = onfocus;
- }
-
- public void setOnselect(String onselect)
- {
- _onselect = onselect;
- }
-
- public void setReadonly(String readonly)
- {
- _readonly = readonly;
- }
-
- public void setSize(String size)
- {
- _size = size;
- }
-
- public void setTabindex(String tabindex)
- {
- _tabindex = tabindex;
- }
-
-
- public String getValue()
- {
- return value;
- }
-
- public void setValue(String value)
- {
- this.value = value;
- }
-
- private String value;
-
- public void setGroupName(String groupName)
- {
- this._groupName = groupName;
- }
-
-
-}
+/*
+ * Copyright 2004-2006 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.custom.selectOneRow;
+
+import org.apache.myfaces.shared_tomahawk.taglib.html.HtmlInputTagBase;
+
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
+
+
+import javax.faces.application.Application;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIInput;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Ernst
+ * Date: 01.02.2006
+ * Time: 15:49:56
+ * To change this template use File | Settings | File Templates.
+ */
+public class SelectOneRowTag extends HtmlInputTagBase
+{
+ public String getComponentType()
+ {
+ return SelectOneRow.COMPONENT_TYPE;
+ }
+
+ public String getRendererType()
+ {
+ return SelectOneRow.DEFAULT_RENDERER_TYPE;
+ }
+
+// UIComponent attributes --> already implemented in UIComponentTagBase
+
+ // user role attributes --> already implemented in UIComponentTagBase
+
+ // HTML universal attributes --> already implemented in HtmlComponentTagBase
+
+ // HTML event handler attributes --> already implemented in HtmlComponentTagBase
+
+ // HTML input attributes relevant for password-input
+ private String _accesskey;
+ private String _align;
+ private String _alt;
+ private String _datafld;
+ private String _datasrc;
+ private String _dataformatas;
+ private String _disabled;
+ private String _maxlength;
+ private String _onblur;
+ private String _onchange;
+ private String _onclick;
+ private String _onfocus;
+ private String _onselect;
+ private String _readonly;
+ private String _size;
+ private String _tabindex;
+
+ // UIOutput attributes
+ // value and converterId --> already implemented in UIComponentTagBase
+
+ // UIInput attributes
+ // --> already implemented in HtmlInputTagBase
+
+ // HTMLInputSecret attributes
+ private String _groupName;
+
+ public void release()
+ {
+ super.release();
+ _accesskey = null;
+ _align = null;
+ _alt = null;
+ _datafld = null;
+ _datasrc = null;
+ _dataformatas = null;
+ _disabled = null;
+ _maxlength = null;
+ _onblur = null;
+ _onchange = null;
+ _onclick = null;
+ _onfocus = null;
+ _onselect = null;
+ _readonly = null;
+ _size = null;
+ _tabindex = null;
+ _groupName = null;
+ }
+
+ protected void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+
+ setStringProperty(component, HTML.ACCESSKEY_ATTR, _accesskey);
+ setStringProperty(component, HTML.ALIGN_ATTR, _align);
+ setStringProperty(component, HTML.ALT_ATTR, _alt);
+ setStringProperty(component, HTML.DATAFLD_ATTR, _datafld);
+ setStringProperty(component, HTML.DATASRC_ATTR, _datasrc);
+ setStringProperty(component, HTML.DATAFORMATAS_ATTR, _dataformatas);
+ setBooleanProperty(component, HTML.DISABLED_ATTR, _disabled);
+ setIntegerProperty(component, HTML.MAXLENGTH_ATTR, _maxlength);
+ setStringProperty(component, HTML.ONBLUR_ATTR, _onblur);
+ setStringProperty(component, HTML.ONCHANGE_ATTR, _onchange);
+ setStringProperty(component, HTML.ONCLICK_ATTR, _onclick);
+ setStringProperty(component, HTML.ONFOCUS_ATTR, _onfocus);
+ setStringProperty(component, HTML.ONSELECT_ATTR, _onselect);
+ setBooleanProperty(component, HTML.READONLY_ATTR, _readonly);
+ setIntegerProperty(component, HTML.SIZE_ATTR, _size);
+ setStringProperty(component, HTML.TABINDEX_ATTR, _tabindex);
+
+ UIInput singleInputRowSelect = (UIInput) component;
+ singleInputRowSelect.getAttributes().put("groupName", _groupName);
+
+ if (getValue() != null)
+ {
+
+ if (isValueReference(getValue()))
+ {
+ FacesContext context = FacesContext.getCurrentInstance();
+ Application app = context.getApplication();
+ ValueBinding binding = app.createValueBinding(getValue());
+ singleInputRowSelect.setValueBinding("value", binding);
+
+ }
+
+ }
+ }
+
+ public void setAccesskey(String accesskey)
+ {
+ _accesskey = accesskey;
+ }
+
+ public void setAlign(String align)
+ {
+ _align = align;
+ }
+
+ public void setAlt(String alt)
+ {
+ _alt = alt;
+ }
+
+ public void setDatafld(String datafld)
+ {
+ _datafld = datafld;
+ }
+
+ public void setDatasrc(String datasrc)
+ {
+ _datasrc = datasrc;
+ }
+
+ public void setDataformatas(String dataformatas)
+ {
+ _dataformatas = dataformatas;
+ }
+
+ public void setDisabled(String disabled)
+ {
+ _disabled = disabled;
+ }
+
+ public void setMaxlength(String maxlength)
+ {
+ _maxlength = maxlength;
+ }
+
+ public void setOnblur(String onblur)
+ {
+ _onblur = onblur;
+ }
+
+ public void setOnchange(String onchange)
+ {
+ _onchange = onchange;
+ }
+
+ public void setOnclick(String onclick)
+ {
+ _onclick = onclick;
+ }
+
+ public void setOnfocus(String onfocus)
+ {
+ _onfocus = onfocus;
+ }
+
+ public void setOnselect(String onselect)
+ {
+ _onselect = onselect;
+ }
+
+ public void setReadonly(String readonly)
+ {
+ _readonly = readonly;
+ }
+
+ public void setSize(String size)
+ {
+ _size = size;
+ }
+
+ public void setTabindex(String tabindex)
+ {
+ _tabindex = tabindex;
+ }
+
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ private String value;
+
+ public void setGroupName(String groupName)
+ {
+ this._groupName = groupName;
+ }
+
+
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectOneRow/SelectOneRowTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectitems/SelectItemsTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectitems/SelectItemsTag.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectitems/SelectItemsTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectitems/SelectItemsTag.java Tue Aug 1 10:43:28 2006
@@ -1,104 +1,104 @@
-/*
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.myfaces.custom.selectitems;
-
-import javax.faces.component.UIComponent;
-import javax.faces.el.ValueBinding;
-
-import org.apache.myfaces.shared_tomahawk.taglib.UIComponentTagBase;
-
-public class SelectItemsTag extends UIComponentTagBase {
-
- private String _var;
-
- private String _itemLabel;
-
- private String _itemValue;
-
- protected void setProperties(UIComponent component) {
- super.setProperties(component);
-
- if (_var != null) {
- if (isValueReference(_var)) {
- ValueBinding vb = getFacesContext().getApplication()
- .createValueBinding(_var);
- component.setValueBinding("var", vb);
- } else {
- component.getAttributes().put("var", _var);
- }
- }
-
- if (_itemLabel != null) {
- if (isValueReference(_itemLabel)) {
- ValueBinding vb = getFacesContext().getApplication()
- .createValueBinding(_itemLabel);
- component.setValueBinding("itemLabel", vb);
- } else {
- component.getAttributes().put("itemLabel", _itemLabel);
- }
- }
-
- if (_itemValue != null) {
- if (isValueReference(_itemValue)) {
- ValueBinding vb = getFacesContext().getApplication()
- .createValueBinding(_itemValue);
- component.setValueBinding("itemValue", vb);
- } else {
- component.getAttributes().put("itemValue", _itemValue);
- }
- }
-
- }
-
- public void release() {
- super.release();
- _var = null;
- _itemLabel = null;
- _itemValue = null;
- }
-
- public String getComponentType() {
- return UISelectItems.COMPONENT_TYPE;
- }
-
- public String getVar() {
- return _var;
- }
-
- public void setVar(String var) {
- this._var = var;
- }
-
- public String getItemLabel() {
- return _itemLabel;
- }
-
- public void setItemLabel(String itemLabel) {
- this._itemLabel = itemLabel;
- }
-
- public String getItemValue() {
- return _itemValue;
- }
-
- public void setItemValue(String itemValue) {
- this._itemValue = itemValue;
- }
-
- public String getRendererType() {
- return null;
- }
-}
+/*
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.custom.selectitems;
+
+import javax.faces.component.UIComponent;
+import javax.faces.el.ValueBinding;
+
+import org.apache.myfaces.shared_tomahawk.taglib.UIComponentTagBase;
+
+public class SelectItemsTag extends UIComponentTagBase {
+
+ private String _var;
+
+ private String _itemLabel;
+
+ private String _itemValue;
+
+ protected void setProperties(UIComponent component) {
+ super.setProperties(component);
+
+ if (_var != null) {
+ if (isValueReference(_var)) {
+ ValueBinding vb = getFacesContext().getApplication()
+ .createValueBinding(_var);
+ component.setValueBinding("var", vb);
+ } else {
+ component.getAttributes().put("var", _var);
+ }
+ }
+
+ if (_itemLabel != null) {
+ if (isValueReference(_itemLabel)) {
+ ValueBinding vb = getFacesContext().getApplication()
+ .createValueBinding(_itemLabel);
+ component.setValueBinding("itemLabel", vb);
+ } else {
+ component.getAttributes().put("itemLabel", _itemLabel);
+ }
+ }
+
+ if (_itemValue != null) {
+ if (isValueReference(_itemValue)) {
+ ValueBinding vb = getFacesContext().getApplication()
+ .createValueBinding(_itemValue);
+ component.setValueBinding("itemValue", vb);
+ } else {
+ component.getAttributes().put("itemValue", _itemValue);
+ }
+ }
+
+ }
+
+ public void release() {
+ super.release();
+ _var = null;
+ _itemLabel = null;
+ _itemValue = null;
+ }
+
+ public String getComponentType() {
+ return UISelectItems.COMPONENT_TYPE;
+ }
+
+ public String getVar() {
+ return _var;
+ }
+
+ public void setVar(String var) {
+ this._var = var;
+ }
+
+ public String getItemLabel() {
+ return _itemLabel;
+ }
+
+ public void setItemLabel(String itemLabel) {
+ this._itemLabel = itemLabel;
+ }
+
+ public String getItemValue() {
+ return _itemValue;
+ }
+
+ public void setItemValue(String itemValue) {
+ this._itemValue = itemValue;
+ }
+
+ public String getRendererType() {
+ return null;
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectitems/SelectItemsTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectitems/UISelectItems.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectitems/UISelectItems.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectitems/UISelectItems.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectitems/UISelectItems.java Tue Aug 1 10:43:28 2006
@@ -1,158 +1,158 @@
-/*
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.myfaces.custom.selectitems;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-import javax.faces.model.SelectItem;
-import javax.faces.model.SelectItemGroup;
-
-public class UISelectItems extends javax.faces.component.UISelectItems {
-
- public static final String COMPONENT_TYPE = "org.apache.myfaces.UISelectItems";
-
- private String _var;
-
- private Object _itemLabel;
-
- private Object _itemValue;
-
- public UISelectItems() {}
-
- public String getVar() {
- if(_var != null)
- return _var;
-
- ValueBinding vb = getValueBinding("var");
- String v = vb != null ? (String)vb.getValue(getFacesContext()) : null;
- return v;
- }
-
- public void setVar(String var) {
- this._var = var;
- }
-
- public Object getItemLabel() {
- if(_itemLabel != null)
- return _itemLabel;
-
- ValueBinding vb = getValueBinding("itemLabel");
- Object v = vb != null ? vb.getValue(getFacesContext()) : null;
- return v;
- }
-
- public void setItemLabel(Object itemLabel) {
- this._itemLabel = itemLabel;
- }
-
- public Object getItemValue() {
- if(_itemValue != null)
- return _itemValue;
-
- ValueBinding vb = getValueBinding("itemValue");
- Object v = vb != null ? vb.getValue(getFacesContext()) : null;
- return v;
- }
-
- public void setItemValue(Object itemValue) {
- this._itemValue = itemValue;
- }
-
- public Object getValue() {
- Object value = super.getValue();
- return createSelectItems(value);
- }
-
- private SelectItem[] createSelectItems(Object value) {
- List items = new ArrayList();
-
- if (value instanceof SelectItem[]) {
- return (SelectItem[]) value;
- }
- else if (value instanceof Collection) {
- Collection collection = (Collection) value;
- for (Iterator iter = collection.iterator(); iter.hasNext();) {
- Object currentItem = (Object) iter.next();
- if (currentItem instanceof SelectItemGroup) {
- SelectItemGroup itemGroup = (SelectItemGroup) currentItem;
- SelectItem[] itemsFromGroup = itemGroup.getSelectItems();
- for (int i = 0; i < itemsFromGroup.length; i++) {
- items.add(itemsFromGroup[i]);
- }
- }
- else {
- putIteratorToRequestParam(currentItem);
- SelectItem selectItem = createSelectItem();
- removeIteratorFromRequestParam();
- items.add(selectItem);
- }
- }
- }
- else if (value instanceof Map) {
- Map map = (Map) value;
- for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
- Entry currentItem = (Entry) iter.next();
- putIteratorToRequestParam(currentItem.getValue());
- SelectItem selectItem = createSelectItem();
- removeIteratorFromRequestParam();
- items.add(selectItem);
- }
- }
-
- return (SelectItem[]) items.toArray(new SelectItem[0]);
- }
-
-
- private SelectItem createSelectItem() {
- Object value = getItemValue();
- String label = getItemLabel() != null ? getItemLabel().toString() : null;
- SelectItem item = new SelectItem(value, label);
- return item;
- }
-
- private void putIteratorToRequestParam(Object object) {
- FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put(getVar(), object);
- }
-
- private void removeIteratorFromRequestParam() {
- FacesContext.getCurrentInstance().getExternalContext().getRequestMap().remove(getVar());
- }
-
- public Object saveState(FacesContext context) {
- Object values[] = new Object[4];
- values[0] = super.saveState(context);
- values[1] = _var;
- values[2] = _itemLabel;
- values[3] = _itemValue;
- return ((Object) (values));
- }
-
- public void restoreState(FacesContext context, Object state) {
- Object values[] = (Object[]) state;
- super.restoreState(context, values[0]);
- _var = (String)values[1];
- _itemLabel = values[2];
- _itemValue = values[3];
- }
-}
-
+/*
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.custom.selectitems;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.model.SelectItem;
+import javax.faces.model.SelectItemGroup;
+
+public class UISelectItems extends javax.faces.component.UISelectItems {
+
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.UISelectItems";
+
+ private String _var;
+
+ private Object _itemLabel;
+
+ private Object _itemValue;
+
+ public UISelectItems() {}
+
+ public String getVar() {
+ if(_var != null)
+ return _var;
+
+ ValueBinding vb = getValueBinding("var");
+ String v = vb != null ? (String)vb.getValue(getFacesContext()) : null;
+ return v;
+ }
+
+ public void setVar(String var) {
+ this._var = var;
+ }
+
+ public Object getItemLabel() {
+ if(_itemLabel != null)
+ return _itemLabel;
+
+ ValueBinding vb = getValueBinding("itemLabel");
+ Object v = vb != null ? vb.getValue(getFacesContext()) : null;
+ return v;
+ }
+
+ public void setItemLabel(Object itemLabel) {
+ this._itemLabel = itemLabel;
+ }
+
+ public Object getItemValue() {
+ if(_itemValue != null)
+ return _itemValue;
+
+ ValueBinding vb = getValueBinding("itemValue");
+ Object v = vb != null ? vb.getValue(getFacesContext()) : null;
+ return v;
+ }
+
+ public void setItemValue(Object itemValue) {
+ this._itemValue = itemValue;
+ }
+
+ public Object getValue() {
+ Object value = super.getValue();
+ return createSelectItems(value);
+ }
+
+ private SelectItem[] createSelectItems(Object value) {
+ List items = new ArrayList();
+
+ if (value instanceof SelectItem[]) {
+ return (SelectItem[]) value;
+ }
+ else if (value instanceof Collection) {
+ Collection collection = (Collection) value;
+ for (Iterator iter = collection.iterator(); iter.hasNext();) {
+ Object currentItem = (Object) iter.next();
+ if (currentItem instanceof SelectItemGroup) {
+ SelectItemGroup itemGroup = (SelectItemGroup) currentItem;
+ SelectItem[] itemsFromGroup = itemGroup.getSelectItems();
+ for (int i = 0; i < itemsFromGroup.length; i++) {
+ items.add(itemsFromGroup[i]);
+ }
+ }
+ else {
+ putIteratorToRequestParam(currentItem);
+ SelectItem selectItem = createSelectItem();
+ removeIteratorFromRequestParam();
+ items.add(selectItem);
+ }
+ }
+ }
+ else if (value instanceof Map) {
+ Map map = (Map) value;
+ for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
+ Entry currentItem = (Entry) iter.next();
+ putIteratorToRequestParam(currentItem.getValue());
+ SelectItem selectItem = createSelectItem();
+ removeIteratorFromRequestParam();
+ items.add(selectItem);
+ }
+ }
+
+ return (SelectItem[]) items.toArray(new SelectItem[0]);
+ }
+
+
+ private SelectItem createSelectItem() {
+ Object value = getItemValue();
+ String label = getItemLabel() != null ? getItemLabel().toString() : null;
+ SelectItem item = new SelectItem(value, label);
+ return item;
+ }
+
+ private void putIteratorToRequestParam(Object object) {
+ FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put(getVar(), object);
+ }
+
+ private void removeIteratorFromRequestParam() {
+ FacesContext.getCurrentInstance().getExternalContext().getRequestMap().remove(getVar());
+ }
+
+ public Object saveState(FacesContext context) {
+ Object values[] = new Object[4];
+ values[0] = super.saveState(context);
+ values[1] = _var;
+ values[2] = _itemLabel;
+ values[3] = _itemValue;
+ return ((Object) (values));
+ }
+
+ public void restoreState(FacesContext context, Object state) {
+ Object values[] = (Object[]) state;
+ super.restoreState(context, values[0]);
+ _var = (String)values[1];
+ _itemLabel = values[2];
+ _itemValue = values[3];
+ }
+}
+
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/selectitems/UISelectItems.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubForm.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubForm.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubForm.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubForm.java Tue Aug 1 10:43:28 2006
@@ -1,233 +1,233 @@
-/*
- * Copyright 2004-2006 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.myfaces.custom.subform;
-
-import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
-
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIComponentBase;
-import javax.faces.context.FacesContext;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.ActionEvent;
-import javax.faces.event.PhaseId;
-import java.util.Iterator;
-import java.util.List;
-
-/**A SubForm which will allow for partial validation
- * and model update.
- *
- * Components will be validated and updated only if
- * either a child-component of this form caused
- * the submit of the form, or an extended commandLink
- * or commandButton with the actionFor attribute set
- * to the client-id of this component was used.
- *
- * You can have several comma-separated entries in
- * the actionFor-attribute - with this it's possible to
- * validate and update more than one subForm at once.
- *
- *
- *
- * @author Gerald Muellan
- * @author Martin Marinschek
- * Date: 19.01.2006
- * Time: 13:58:18
- */
-public class SubForm extends UIComponentBase
- implements NamingContainer
-{
-
- public static final String COMPONENT_TYPE = "org.apache.myfaces.SubForm";
- public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.SubForm";
- public static final String COMPONENT_FAMILY = "org.apache.myfaces.SubForm";
-
- private static final String PARTIAL_ENABLED = "org.apache.myfaces.IsPartialPhaseExecutionEnabled";
- private boolean _submitted;
-
-
- public SubForm()
- {
- super.setRendererType(DEFAULT_RENDERER_TYPE);
- }
-
- public String getFamily()
- {
- return COMPONENT_FAMILY;
- }
-
- public boolean isSubmitted()
- {
- return _submitted;
- }
-
- public void setSubmitted(boolean submitted)
- {
- _submitted = submitted;
- }
-
- public void processValidators(FacesContext context)
- {
- if (context == null) throw new NullPointerException("context");
- if (!isRendered()) return;
-
- boolean partialEnabled = isPartialEnabled(context, PhaseId.PROCESS_VALIDATIONS);
-
- if(partialEnabled || (_submitted && isEmptyList(context)))
- {
- for (Iterator it = getFacetsAndChildren(); it.hasNext(); )
- {
- UIComponent childOrFacet = (UIComponent)it.next();
- childOrFacet.processValidators(context);
- }
- }
- else
- {
- processSubFormValidators(this,context);
- }
- }
-
- public void processUpdates(FacesContext context)
- {
- if (context == null) throw new NullPointerException("context");
- if (!isRendered()) return;
-
- boolean partialEnabled = isPartialEnabled(context,PhaseId.UPDATE_MODEL_VALUES);
-
- if(partialEnabled || _submitted)
- {
- for (Iterator it = getFacetsAndChildren(); it.hasNext(); )
- {
- UIComponent childOrFacet = (UIComponent)it.next();
- childOrFacet.processUpdates(context);
- }
- }
- else
- {
- processSubFormUpdates(this,context);
- }
- }
-
- private static void processSubFormUpdates(UIComponent comp, FacesContext context)
- {
- for (Iterator it = comp.getFacetsAndChildren(); it.hasNext(); )
- {
- UIComponent childOrFacet = (UIComponent)it.next();
-
- if(childOrFacet instanceof SubForm)
- {
- childOrFacet.processUpdates(context);
- }
- else
- {
- processSubFormUpdates(childOrFacet, context);
- }
- }
- }
-
- private static void processSubFormValidators(UIComponent comp, FacesContext context)
- {
- for (Iterator it = comp.getFacetsAndChildren(); it.hasNext(); )
- {
- UIComponent childOrFacet = (UIComponent)it.next();
-
- if(childOrFacet instanceof SubForm)
- {
- childOrFacet.processValidators(context);
- }
- else
- {
- processSubFormValidators(childOrFacet, context);
- }
- }
- }
-
- public void queueEvent(FacesEvent event)
- {
- if(event instanceof ActionEvent)
- {
- _submitted = true;
- }
-
- // This idea is taken from ADF faces - my approach didn't go as far
- // as necessary - I still believe this to be a hack as well.
- // If the event is being queued for anything *after* APPLY_REQUEST_VALUES,
- // then this subform is active.
- if (PhaseId.APPLY_REQUEST_VALUES.compareTo(event.getPhaseId()) < 0)
- {
- setSubmitted(true);
- }
-
- super.queueEvent(event);
- }
-
- protected boolean isEmptyList(FacesContext context)
- {
- //get the list of (parent) client-ids for which a validation/model update should be performed
- List li = (List) context.getExternalContext().getRequestMap().get(
- RendererUtils.ACTION_FOR_LIST);
-
- return li==null || li.size()==0;
- }
-
- /**Sets up information if this component is included in
- * the group of components which are associated with the current action.
- *
- * @param context
- * @return true if there has been a change by this setup which has to be undone after the phase finishes.
- */
- protected boolean isPartialEnabled(FacesContext context, PhaseId phaseId)
- {
- //we want to execute validation (and model update) only
- //if certain conditions are met
- //especially, we want to switch validation/update on/off depending on
- //the attribute "actionFor" of a MyFaces extended button or link
- //if you use commandButtons which don't set these
- //request parameters, this won't cause any adverse effects
-
- boolean partialEnabled = false;
-
- //get the list of (parent) client-ids for which a validation/model update should be performed
- List li = (List) context.getExternalContext().getRequestMap().get(
- RendererUtils.ACTION_FOR_LIST);
-
- //if there is a list, check if the current client id
- //matches an entry of the list
- if(li != null && li.contains(getClientId(context)))
- {
- if(!context.getExternalContext().getRequestMap().containsKey(PARTIAL_ENABLED))
- {
- partialEnabled=true;
- }
- }
-
- if(partialEnabled)
- {
- //get the list of phases which should be executed
- List phaseList = (List) context.getExternalContext().getRequestMap().get(
- RendererUtils.ACTION_FOR_PHASE_LIST);
-
- if(phaseList != null && !phaseList.isEmpty() && !phaseList.contains(phaseId))
- {
- partialEnabled=false;
- }
- }
-
- return partialEnabled;
- }
-
-
-}
+/*
+ * Copyright 2004-2006 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.custom.subform;
+
+import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.PhaseId;
+import java.util.Iterator;
+import java.util.List;
+
+/**A SubForm which will allow for partial validation
+ * and model update.
+ *
+ * Components will be validated and updated only if
+ * either a child-component of this form caused
+ * the submit of the form, or an extended commandLink
+ * or commandButton with the actionFor attribute set
+ * to the client-id of this component was used.
+ *
+ * You can have several comma-separated entries in
+ * the actionFor-attribute - with this it's possible to
+ * validate and update more than one subForm at once.
+ *
+ *
+ *
+ * @author Gerald Muellan
+ * @author Martin Marinschek
+ * Date: 19.01.2006
+ * Time: 13:58:18
+ */
+public class SubForm extends UIComponentBase
+ implements NamingContainer
+{
+
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.SubForm";
+ public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.SubForm";
+ public static final String COMPONENT_FAMILY = "org.apache.myfaces.SubForm";
+
+ private static final String PARTIAL_ENABLED = "org.apache.myfaces.IsPartialPhaseExecutionEnabled";
+ private boolean _submitted;
+
+
+ public SubForm()
+ {
+ super.setRendererType(DEFAULT_RENDERER_TYPE);
+ }
+
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
+
+ public boolean isSubmitted()
+ {
+ return _submitted;
+ }
+
+ public void setSubmitted(boolean submitted)
+ {
+ _submitted = submitted;
+ }
+
+ public void processValidators(FacesContext context)
+ {
+ if (context == null) throw new NullPointerException("context");
+ if (!isRendered()) return;
+
+ boolean partialEnabled = isPartialEnabled(context, PhaseId.PROCESS_VALIDATIONS);
+
+ if(partialEnabled || (_submitted && isEmptyList(context)))
+ {
+ for (Iterator it = getFacetsAndChildren(); it.hasNext(); )
+ {
+ UIComponent childOrFacet = (UIComponent)it.next();
+ childOrFacet.processValidators(context);
+ }
+ }
+ else
+ {
+ processSubFormValidators(this,context);
+ }
+ }
+
+ public void processUpdates(FacesContext context)
+ {
+ if (context == null) throw new NullPointerException("context");
+ if (!isRendered()) return;
+
+ boolean partialEnabled = isPartialEnabled(context,PhaseId.UPDATE_MODEL_VALUES);
+
+ if(partialEnabled || _submitted)
+ {
+ for (Iterator it = getFacetsAndChildren(); it.hasNext(); )
+ {
+ UIComponent childOrFacet = (UIComponent)it.next();
+ childOrFacet.processUpdates(context);
+ }
+ }
+ else
+ {
+ processSubFormUpdates(this,context);
+ }
+ }
+
+ private static void processSubFormUpdates(UIComponent comp, FacesContext context)
+ {
+ for (Iterator it = comp.getFacetsAndChildren(); it.hasNext(); )
+ {
+ UIComponent childOrFacet = (UIComponent)it.next();
+
+ if(childOrFacet instanceof SubForm)
+ {
+ childOrFacet.processUpdates(context);
+ }
+ else
+ {
+ processSubFormUpdates(childOrFacet, context);
+ }
+ }
+ }
+
+ private static void processSubFormValidators(UIComponent comp, FacesContext context)
+ {
+ for (Iterator it = comp.getFacetsAndChildren(); it.hasNext(); )
+ {
+ UIComponent childOrFacet = (UIComponent)it.next();
+
+ if(childOrFacet instanceof SubForm)
+ {
+ childOrFacet.processValidators(context);
+ }
+ else
+ {
+ processSubFormValidators(childOrFacet, context);
+ }
+ }
+ }
+
+ public void queueEvent(FacesEvent event)
+ {
+ if(event instanceof ActionEvent)
+ {
+ _submitted = true;
+ }
+
+ // This idea is taken from ADF faces - my approach didn't go as far
+ // as necessary - I still believe this to be a hack as well.
+ // If the event is being queued for anything *after* APPLY_REQUEST_VALUES,
+ // then this subform is active.
+ if (PhaseId.APPLY_REQUEST_VALUES.compareTo(event.getPhaseId()) < 0)
+ {
+ setSubmitted(true);
+ }
+
+ super.queueEvent(event);
+ }
+
+ protected boolean isEmptyList(FacesContext context)
+ {
+ //get the list of (parent) client-ids for which a validation/model update should be performed
+ List li = (List) context.getExternalContext().getRequestMap().get(
+ RendererUtils.ACTION_FOR_LIST);
+
+ return li==null || li.size()==0;
+ }
+
+ /**Sets up information if this component is included in
+ * the group of components which are associated with the current action.
+ *
+ * @param context
+ * @return true if there has been a change by this setup which has to be undone after the phase finishes.
+ */
+ protected boolean isPartialEnabled(FacesContext context, PhaseId phaseId)
+ {
+ //we want to execute validation (and model update) only
+ //if certain conditions are met
+ //especially, we want to switch validation/update on/off depending on
+ //the attribute "actionFor" of a MyFaces extended button or link
+ //if you use commandButtons which don't set these
+ //request parameters, this won't cause any adverse effects
+
+ boolean partialEnabled = false;
+
+ //get the list of (parent) client-ids for which a validation/model update should be performed
+ List li = (List) context.getExternalContext().getRequestMap().get(
+ RendererUtils.ACTION_FOR_LIST);
+
+ //if there is a list, check if the current client id
+ //matches an entry of the list
+ if(li != null && li.contains(getClientId(context)))
+ {
+ if(!context.getExternalContext().getRequestMap().containsKey(PARTIAL_ENABLED))
+ {
+ partialEnabled=true;
+ }
+ }
+
+ if(partialEnabled)
+ {
+ //get the list of phases which should be executed
+ List phaseList = (List) context.getExternalContext().getRequestMap().get(
+ RendererUtils.ACTION_FOR_PHASE_LIST);
+
+ if(phaseList != null && !phaseList.isEmpty() && !phaseList.contains(phaseId))
+ {
+ partialEnabled=false;
+ }
+ }
+
+ return partialEnabled;
+ }
+
+
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubForm.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubFormRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubFormRenderer.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubFormRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubFormRenderer.java Tue Aug 1 10:43:28 2006
@@ -1,93 +1,93 @@
-/*
- * Copyright 2004-2006 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.myfaces.custom.subform;
-
-import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.util.FormInfo;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import java.io.IOException;
-import java.util.Map;
-
-/**
- * @author Gerald Muellan
- * Date: 19.01.2006
- * Time: 14:01:35
- */
-public class SubFormRenderer extends HtmlRenderer
-{
- private static final String SUBMIT_FUNCTION_SUFFIX = "_submit";
- private static final String HIDDEN_PARAM_NAME = "org.apache.myfaces.custom.subform.submittedId";
-
- public void encodeBegin(FacesContext context, UIComponent component) throws IOException
- {
- super.encodeBegin(context, component);
-
- ResponseWriter writer = context.getResponseWriter();
-
- HtmlRendererUtils.writePrettyLineSeparator(context);
- writer.startElement(HTML.SCRIPT_ELEM, null);
- writer.writeAttribute(org.apache.myfaces.shared_tomahawk.renderkit.html.HTML.SCRIPT_TYPE_ATTR, org.apache.myfaces.shared_tomahawk.renderkit.html.HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
-
- FormInfo parentFormInfo = RendererUtils.findNestingForm(component,context);
- if(parentFormInfo!=null)
- {
- writer.writeText(createPartialSubmitJS(component.getId(), parentFormInfo.getFormName()), null);
- }
-
- writer.endElement(org.apache.myfaces.shared_tomahawk.renderkit.html.HTML.SCRIPT_ELEM);
- HtmlRendererUtils.writePrettyLineSeparator(context);
- }
-
- public void decode(FacesContext context, UIComponent component)
- {
- super.decode(context, component);
-
- Map paramValuesMap = context.getExternalContext().getRequestParameterMap();
- String reqValue = (String) paramValuesMap.get(HIDDEN_PARAM_NAME);
- if (reqValue != null && component.getId().equals(reqValue))
- {
- ((SubForm) component).setSubmitted(true);
- }
- }
-
- /**
- *
- */
- protected String createPartialSubmitJS(String subFormId, String parentFormClientId)
- {
- StringBuffer script = new StringBuffer();
- script.append("function ");
- script.append(subFormId).append(SUBMIT_FUNCTION_SUFFIX + "()");
- script.append(" {\n");
- script.append("var form = document.forms['").append(parentFormClientId).append("'];\n");
- script.append("var el = document.createElement(\"input\");\n");
- script.append("el.type = \"hidden\";\n");
- script.append("el.name = \"" + HIDDEN_PARAM_NAME + "\";\n");
- script.append("el.value = \"").append(subFormId).append("\";\n");
- script.append("form.appendChild(el);\n");
- script.append("form.submit();\n");
- script.append("}\n");
-
- return script.toString();
- }
-
-}
+/*
+ * Copyright 2004-2006 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.custom.subform;
+
+import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.util.FormInfo;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * @author Gerald Muellan
+ * Date: 19.01.2006
+ * Time: 14:01:35
+ */
+public class SubFormRenderer extends HtmlRenderer
+{
+ private static final String SUBMIT_FUNCTION_SUFFIX = "_submit";
+ private static final String HIDDEN_PARAM_NAME = "org.apache.myfaces.custom.subform.submittedId";
+
+ public void encodeBegin(FacesContext context, UIComponent component) throws IOException
+ {
+ super.encodeBegin(context, component);
+
+ ResponseWriter writer = context.getResponseWriter();
+
+ HtmlRendererUtils.writePrettyLineSeparator(context);
+ writer.startElement(HTML.SCRIPT_ELEM, null);
+ writer.writeAttribute(org.apache.myfaces.shared_tomahawk.renderkit.html.HTML.SCRIPT_TYPE_ATTR, org.apache.myfaces.shared_tomahawk.renderkit.html.HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
+
+ FormInfo parentFormInfo = RendererUtils.findNestingForm(component,context);
+ if(parentFormInfo!=null)
+ {
+ writer.writeText(createPartialSubmitJS(component.getId(), parentFormInfo.getFormName()), null);
+ }
+
+ writer.endElement(org.apache.myfaces.shared_tomahawk.renderkit.html.HTML.SCRIPT_ELEM);
+ HtmlRendererUtils.writePrettyLineSeparator(context);
+ }
+
+ public void decode(FacesContext context, UIComponent component)
+ {
+ super.decode(context, component);
+
+ Map paramValuesMap = context.getExternalContext().getRequestParameterMap();
+ String reqValue = (String) paramValuesMap.get(HIDDEN_PARAM_NAME);
+ if (reqValue != null && component.getId().equals(reqValue))
+ {
+ ((SubForm) component).setSubmitted(true);
+ }
+ }
+
+ /**
+ *
+ */
+ protected String createPartialSubmitJS(String subFormId, String parentFormClientId)
+ {
+ StringBuffer script = new StringBuffer();
+ script.append("function ");
+ script.append(subFormId).append(SUBMIT_FUNCTION_SUFFIX + "()");
+ script.append(" {\n");
+ script.append("var form = document.forms['").append(parentFormClientId).append("'];\n");
+ script.append("var el = document.createElement(\"input\");\n");
+ script.append("el.type = \"hidden\";\n");
+ script.append("el.name = \"" + HIDDEN_PARAM_NAME + "\";\n");
+ script.append("el.value = \"").append(subFormId).append("\";\n");
+ script.append("form.appendChild(el);\n");
+ script.append("form.submit();\n");
+ script.append("}\n");
+
+ return script.toString();
+ }
+
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubFormRenderer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubFormTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubFormTag.java?rev=427657&r1=427656&r2=427657&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubFormTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubFormTag.java Tue Aug 1 10:43:28 2006
@@ -1,36 +1,36 @@
-/*
- * Copyright 2004-2006 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.myfaces.custom.subform;
-
-import javax.faces.webapp.UIComponentTag;
-
-/**
- * @author Gerald Muellan
- * Date: 19.01.2006
- * Time: 14:01:07
- */
-public class SubFormTag extends UIComponentTag
-{
- public String getComponentType()
- {
- return SubForm.COMPONENT_TYPE;
- }
-
- public String getRendererType()
- {
- return SubForm.DEFAULT_RENDERER_TYPE;
- }
-}
+/*
+ * Copyright 2004-2006 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.custom.subform;
+
+import javax.faces.webapp.UIComponentTag;
+
+/**
+ * @author Gerald Muellan
+ * Date: 19.01.2006
+ * Time: 14:01:07
+ */
+public class SubFormTag extends UIComponentTag
+{
+ public String getComponentType()
+ {
+ return SubForm.COMPONENT_TYPE;
+ }
+
+ public String getRendererType()
+ {
+ return SubForm.DEFAULT_RENDERER_TYPE;
+ }
+}
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubFormTag.java
------------------------------------------------------------------------------
svn:eol-style = native