You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by gv...@apache.org on 2006/02/14 05:36:50 UTC
svn commit: r377616 - /struts/shale/trunk/use-cases/src/web/symbols/home.jsp
Author: gvanmatre
Date: Mon Feb 13 20:36:49 2006
New Revision: 377616
URL: http://svn.apache.org/viewcvs?rev=377616&view=rev
Log: (empty)
Modified:
struts/shale/trunk/use-cases/src/web/symbols/home.jsp
Modified: struts/shale/trunk/use-cases/src/web/symbols/home.jsp
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/use-cases/src/web/symbols/home.jsp?rev=377616&r1=377615&r2=377616&view=diff
==============================================================================
--- struts/shale/trunk/use-cases/src/web/symbols/home.jsp (original)
+++ struts/shale/trunk/use-cases/src/web/symbols/home.jsp Mon Feb 13 20:36:49 2006
@@ -50,922 +50,7 @@
<f:param name="url" value="/symbols/layout.html"/></h:outputLink> that defines
sections of a typical page having a header,
footer, left navbar and body sections. The layout is defined as an HTML template,
- but the entry point can be a full XML or full HTML teIndex: src/java/org/apache/shale/faces/ValidatorRenderKit.java
-===================================================================
---- src/java/org/apache/shale/faces/ValidatorRenderKit.java (revision 0)
-+++ src/java/org/apache/shale/faces/ValidatorRenderKit.java (revision 0)
-@@ -0,0 +1,68 @@
-+/*
-+ * Copyright 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.shale.faces;
-+
-+import java.io.OutputStream;
-+import java.io.Writer;
-+
-+import javax.faces.context.ResponseStream;
-+import javax.faces.context.ResponseWriter;
-+import javax.faces.render.RenderKit;
-+import javax.faces.render.Renderer;
-+import javax.faces.render.ResponseStateManager;
-+
-+import org.apache.shale.renderer.ValidatorCommandRenderer;
-+
-+public class ValidatorRenderKit extends RenderKit {
-+
-+ private RenderKit defaultRenderKit = null;
-+ public ValidatorRenderKit(RenderKit defaultRenderKit) {
-+ this.defaultRenderKit = defaultRenderKit;
-+ }
-+
-+ public void addRenderer(String componentFamily, String rendererType, Renderer renderer) {
-+ this.defaultRenderKit.addRenderer(componentFamily, rendererType, renderer);
-+ }
-+
-+ public Renderer getRenderer(String componentFamily, String rendererType) {
-+ Renderer target = defaultRenderKit.getRenderer(componentFamily, rendererType);
-+ if (componentFamily.equals("javax.faces.Command")) {
-+ if (!(target instanceof ValidatorCommandRenderer)) {
-+ target = new ValidatorCommandRenderer(target);
-+ addRenderer(componentFamily, rendererType, target);
-+ }
-+ }
-+
-+ return target;
-+ }
-+
-+ public ResponseStateManager getResponseStateManager() {
-+ return defaultRenderKit.getResponseStateManager();
-+ }
-+
-+ public ResponseWriter createResponseWriter(Writer writer,
-+ String contentTypeList,
-+ String characterEncoding){
-+ return defaultRenderKit.createResponseWriter(writer, contentTypeList, characterEncoding);
-+ }
-+
-+ public ResponseStream createResponseStream(OutputStream outputStream) {
-+ return defaultRenderKit.createResponseStream(outputStream);
-+ }
-+
-+}
-Index: src/java/org/apache/shale/validator/Globals.java
-===================================================================
---- src/java/org/apache/shale/validator/Globals.java (revision 367478)
-+++ src/java/org/apache/shale/validator/Globals.java (working copy)
-@@ -19,7 +19,7 @@
- /**
- * <p>Manifest constants that are global to the validator implementation.</p>
- *
-- * $Id:$
-+ * $Id$
- */
-
- public class Globals {
-Index: src/java/org/apache/shale/renderer/ValidatorCommandRenderer.java
-===================================================================
---- src/java/org/apache/shale/renderer/ValidatorCommandRenderer.java (revision 0)
-+++ src/java/org/apache/shale/renderer/ValidatorCommandRenderer.java (revision 0)
-@@ -0,0 +1,168 @@
-+/*
-+ * Copyright 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.shale.renderer;
-+
-+import java.io.IOException;
-+import java.io.StringWriter;
-+
-+import javax.faces.component.UICommand;
-+import javax.faces.component.UIComponent;
-+import javax.faces.context.FacesContext;
-+import javax.faces.context.ResponseWriter;
-+import javax.faces.render.Renderer;
-+
-+public class ValidatorCommandRenderer extends Renderer {
-+
-+ private Renderer defaultRenderer = null;
-+ public ValidatorCommandRenderer(Renderer defaultRenderer) {
-+ this.defaultRenderer = defaultRenderer;
-+ }
-+
-+
-+
-+ /**
-+ * <p>
-+ * Attribute name used to override the default behavior of how the immediate
-+ * attribute effects the execution of client side javascript validation.
-+ * </p>
-+ */
-+ public static final String OVERRIDE_IMMEDIATE = "org.apache.shale.validator.immediate";
-+
-+ private static final int ENCODE_BEGIN = 0;
-+
-+ private static final int ENCODE_CHILDREN = 1;
-+
-+ private static final int ENCODE_END = 2;
-+
-+ /**
-+ * <b>Interrogates the component's immediate property and the component's
-+ * immediate override attribute to determine if client side validation is
-+ * invoked. If either the property or attribute override is false, client
-+ * side validation is invoked. Otherwise, the response writer is hijacked
-+ * and the original render is invoked. The result is buffered and a
-+ * statement of javascript is injected into the onclick event which cancels
-+ * client side validation. The original response writer is restored and the
-+ * modified markup is written to the response writer. The
-+ * <code>encodeSwitch</code> determines if the encodeBegin, encodeChildren
-+ * or encodeEnd methods should be invoked on the decorated renderer.</b>
-+ */
-+ protected void encode(FacesContext context, UIComponent component,
-+ int encodeSwitch) throws IOException {
-+
-+ UICommand command = (UICommand) component;
-+
-+ // look for a override to the default
-+ boolean immediateOverride = true;
-+ String attr = (String) component.getAttributes()
-+ .get(OVERRIDE_IMMEDIATE);
-+ if (attr != null) {
-+ immediateOverride = Boolean.valueOf(attr).booleanValue();
-+ }
-+
-+ if (command.isImmediate() && immediateOverride) {
-+
-+ ResponseWriter hijackedWriter = context.getResponseWriter();
-+ // builds a buffer to write the page to
-+ StringWriter writer = new StringWriter();
-+ // create a buffered response writer
-+ ResponseWriter buffResponsewriter = context.getRenderKit()
-+ .createResponseWriter(writer, null,
-+ hijackedWriter.getCharacterEncoding());
-+ // push buffered writer to the faces context
-+ context.setResponseWriter(buffResponsewriter);
-+
-+ if (encodeSwitch == ENCODE_BEGIN)
-+ defaultRenderer.encodeBegin(context, component);
-+ else if (encodeSwitch == ENCODE_CHILDREN)
-+ defaultRenderer.encodeChildren(context, component);
-+ else
-+ defaultRenderer.encodeEnd(context, component);
-+
-+ StringBuffer buff = writer.getBuffer();
-+ int i = buff.indexOf("onclick=\"");
-+ if (i > 0) {
-+ buff.insert(i + "onclick=\"".length(), "bCancel=true;");
-+ }
-+
-+ hijackedWriter.write(buff.toString());
-+ context.setResponseWriter(hijackedWriter);
-+
-+ } else {
-+ if (encodeSwitch == ENCODE_BEGIN)
-+ defaultRenderer.encodeBegin(context, component);
-+ else if (encodeSwitch == ENCODE_CHILDREN)
-+ defaultRenderer.encodeChildren(context, component);
-+ else
-+ defaultRenderer.encodeEnd(context, component);
-+ }
-+ }
-+
-+
-+
-+ /**
-+ * <p>
-+ * Decorates the original component renderer invoking its decode method.
-+ * <p>
-+ */
-+ public void decode(FacesContext context, UIComponent component) {
-+ defaultRenderer.decode(context, component);
-+ }
-+
-+ /**
-+ * <p>
-+ * Invokes the <code>encode</code> method passing
-+ * <code>ENCODE_BEGIN</code> for the encodeSwitch parameter.
-+ * </p>
-+ */
-+ public void encodeBegin(FacesContext context, UIComponent component)
-+ throws IOException {
-+ encode(context, component, ENCODE_BEGIN);
-+ }
-+
-+ /**
-+ * <p>
-+ * Invokes the <code>encode</code> method passing
-+ * <code>ENCODE_CHILDREN</code> for the encodeSwitch parameter.
-+ * </p>
-+ */
-+ public void encodeChildren(FacesContext context, UIComponent component)
-+ throws IOException {
-+ encode(context, component, ENCODE_CHILDREN);
-+ }
-+
-+ /**
-+ * <p>
-+ * Invokes the <code>encode</code> method passing <code>ENCODE_END</code>
-+ * for the encodeSwitch parameter.
-+ * </p>
-+ */
-+ public void encodeEnd(FacesContext context, UIComponent component)
-+ throws IOException {
-+ encode(context, component, ENCODE_END);
-+ }
-+
-+ /**
-+ * <p>
-+ * This method is hard-coded to return <code>true</code>. The other
-+ * overriden methods invoke the decorated original render.
-+ */
-+ public boolean getRendersChildren() {
-+ return defaultRenderer.getRendersChildren();
-+ }
-+
-+}
-Index: src/java/org/apache/shale/view/faces/ViewViewHandler.java
-===================================================================
---- src/java/org/apache/shale/view/faces/ViewViewHandler.java (revision 367478)
-+++ src/java/org/apache/shale/view/faces/ViewViewHandler.java (working copy)
-@@ -23,15 +23,18 @@
- import java.util.Map;
-
- import javax.faces.FacesException;
-+import javax.faces.FactoryFinder;
- import javax.faces.application.ViewHandler;
- import javax.faces.component.UIViewRoot;
- import javax.faces.context.FacesContext;
- import javax.faces.el.EvaluationException;
--import javax.faces.el.ValueBinding;
- import javax.faces.el.VariableResolver;
-+import javax.faces.render.RenderKit;
-+import javax.faces.render.RenderKitFactory;
-
- import org.apache.commons.logging.Log;
- import org.apache.commons.logging.LogFactory;
-+import org.apache.shale.faces.ValidatorRenderKit;
- import org.apache.shale.util.Messages;
- import org.apache.shale.view.Constants;
- import org.apache.shale.view.ViewController;
-@@ -124,6 +127,7 @@
- public UIViewRoot createView(FacesContext context, String viewId) {
- UIViewRoot view = original.createView(context, viewId);
- setupViewController(context, view, viewId, false);
-+ setupRenderKit(context, view);
- return view;
- }
-
-@@ -263,5 +267,13 @@
-
- }
-
-+
-+ private void setupRenderKit(FacesContext context, UIViewRoot view) {
-+ RenderKitFactory factory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
-+ RenderKit defaultRenderKit = factory.getRenderKit(context, view.getRenderKitId());
-+ if (!(defaultRenderKit instanceof ValidatorRenderKit))
-+ factory.addRenderKit(view.getRenderKitId(), new ValidatorRenderKit(defaultRenderKit));
-+ }
-
-+
- }
-Index: src/java/org/apache/shale/faces/ValidatorRenderKit.java
-===================================================================
---- src/java/org/apache/shale/faces/ValidatorRenderKit.java (revision 0)
-+++ src/java/org/apache/shale/faces/ValidatorRenderKit.java (revision 0)
-@@ -0,0 +1,68 @@
-+/*
-+ * Copyright 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.shale.faces;
-+
-+import java.io.OutputStream;
-+import java.io.Writer;
-+
-+import javax.faces.context.ResponseStream;
-+import javax.faces.context.ResponseWriter;
-+import javax.faces.render.RenderKit;
-+import javax.faces.render.Renderer;
-+import javax.faces.render.ResponseStateManager;
-+
-+import org.apache.shale.renderer.ValidatorCommandRenderer;
-+
-+public class ValidatorRenderKit extends RenderKit {
-+
-+ private RenderKit defaultRenderKit = null;
-+ public ValidatorRenderKit(RenderKit defaultRenderKit) {
-+ this.defaultRenderKit = defaultRenderKit;
-+ }
-+
-+ public void addRenderer(String componentFamily, String rendererType, Renderer renderer) {
-+ this.defaultRenderKit.addRenderer(componentFamily, rendererType, renderer);
-+ }
-+
-+ public Renderer getRenderer(String componentFamily, String rendererType) {
-+ Renderer target = defaultRenderKit.getRenderer(componentFamily, rendererType);
-+ if (componentFamily.equals("javax.faces.Command")) {
-+ if (!(target instanceof ValidatorCommandRenderer)) {
-+ target = new ValidatorCommandRenderer(target);
-+ addRenderer(componentFamily, rendererType, target);
-+ }
-+ }
-+
-+ return target;
-+ }
-+
-+ public ResponseStateManager getResponseStateManager() {
-+ return defaultRenderKit.getResponseStateManager();
-+ }
-+
-+ public ResponseWriter createResponseWriter(Writer writer,
-+ String contentTypeList,
-+ String characterEncoding){
-+ return defaultRenderKit.createResponseWriter(writer, contentTypeList, characterEncoding);
-+ }
-+
-+ public ResponseStream createResponseStream(OutputStream outputStream) {
-+ return defaultRenderKit.createResponseStream(outputStream);
-+ }
-+
-+}
-Index: src/java/org/apache/shale/validator/Globals.java
-===================================================================
---- src/java/org/apache/shale/validator/Globals.java (revision 367478)
-+++ src/java/org/apache/shale/validator/Globals.java (working copy)
-@@ -19,7 +19,7 @@
- /**
- * <p>Manifest constants that are global to the validator implementation.</p>
- *
-- * $Id:$
-+ * $Id$
- */
-
- public class Globals {
-Index: src/java/org/apache/shale/renderer/ValidatorCommandRenderer.java
-===================================================================
---- src/java/org/apache/shale/renderer/ValidatorCommandRenderer.java (revision 0)
-+++ src/java/org/apache/shale/renderer/ValidatorCommandRenderer.java (revision 0)
-@@ -0,0 +1,168 @@
-+/*
-+ * Copyright 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.shale.renderer;
-+
-+import java.io.IOException;
-+import java.io.StringWriter;
-+
-+import javax.faces.component.UICommand;
-+import javax.faces.component.UIComponent;
-+import javax.faces.context.FacesContext;
-+import javax.faces.context.ResponseWriter;
-+import javax.faces.render.Renderer;
-+
-+public class ValidatorCommandRenderer extends Renderer {
-+
-+ private Renderer defaultRenderer = null;
-+ public ValidatorCommandRenderer(Renderer defaultRenderer) {
-+ this.defaultRenderer = defaultRenderer;
-+ }
-+
-+
-+
-+ /**
-+ * <p>
-+ * Attribute name used to override the default behavior of how the immediate
-+ * attribute effects the execution of client side javascript validation.
-+ * </p>
-+ */
-+ public static final String OVERRIDE_IMMEDIATE = "org.apache.shale.validator.immediate";
-+
-+ private static final int ENCODE_BEGIN = 0;
-+
-+ private static final int ENCODE_CHILDREN = 1;
-+
-+ private static final int ENCODE_END = 2;
-+
-+ /**
-+ * <b>Interrogates the component's immediate property and the component's
-+ * immediate override attribute to determine if client side validation is
-+ * invoked. If either the property or attribute override is false, client
-+ * side validation is invoked. Otherwise, the response writer is hijacked
-+ * and the original render is invoked. The result is buffered and a
-+ * statement of javascript is injected into the onclick event which cancels
-+ * client side validation. The original response writer is restored and the
-+ * modified markup is written to the response writer. The
-+ * <code>encodeSwitch</code> determines if the encodeBegin, encodeChildren
-+ * or encodeEnd methods should be invoked on the decorated renderer.</b>
-+ */
-+ protected void encode(FacesContext context, UIComponent component,
-+ int encodeSwitch) throws IOException {
-+
-+ UICommand command = (UICommand) component;
-+
-+ // look for a override to the default
-+ boolean immediateOverride = true;
-+ String attr = (String) component.getAttributes()
-+ .get(OVERRIDE_IMMEDIATE);
-+ if (attr != null) {
-+ immediateOverride = Boolean.valueOf(attr).booleanValue();
-+ }
-+
-+ if (command.isImmediate() && immediateOverride) {
-+
-+ ResponseWriter hijackedWriter = context.getResponseWriter();
-+ // builds a buffer to write the page to
-+ StringWriter writer = new StringWriter();
-+ // create a buffered response writer
-+ ResponseWriter buffResponsewriter = context.getRenderKit()
-+ .createResponseWriter(writer, null,
-+ hijackedWriter.getCharacterEncoding());
-+ // push buffered writer to the faces context
-+ context.setResponseWriter(buffResponsewriter);
-+
-+ if (encodeSwitch == ENCODE_BEGIN)
-+ defaultRenderer.encodeBegin(context, component);
-+ else if (encodeSwitch == ENCODE_CHILDREN)
-+ defaultRenderer.encodeChildren(context, component);
-+ else
-+ defaultRenderer.encodeEnd(context, component);
-+
-+ StringBuffer buff = writer.getBuffer();
-+ int i = buff.indexOf("onclick=\"");
-+ if (i > 0) {
-+ buff.insert(i + "onclick=\"".length(), "bCancel=true;");
-+ }
-+
-+ hijackedWriter.write(buff.toString());
-+ context.setResponseWriter(hijackedWriter);
-+
-+ } else {
-+ if (encodeSwitch == ENCODE_BEGIN)
-+ defaultRenderer.encodeBegin(context, component);
-+ else if (encodeSwitch == ENCODE_CHILDREN)
-+ defaultRenderer.encodeChildren(context, component);
-+ else
-+ defaultRenderer.encodeEnd(context, component);
-+ }
-+ }
-+
-+
-+
-+ /**
-+ * <p>
-+ * Decorates the original component renderer invoking its decode method.
-+ * <p>
-+ */
-+ public void decode(FacesContext context, UIComponent component) {
-+ defaultRenderer.decode(context, component);
-+ }
-+
-+ /**
-+ * <p>
-+ * Invokes the <code>encode</code> method passing
-+ * <code>ENCODE_BEGIN</code> for the encodeSwitch parameter.
-+ * </p>
-+ */
-+ public void encodeBegin(FacesContext context, UIComponent component)
-+ throws IOException {
-+ encode(context, component, ENCODE_BEGIN);
-+ }
-+
-+ /**
-+ * <p>
-+ * Invokes the <code>encode</code> method passing
-+ * <code>ENCODE_CHILDREN</code> for the encodeSwitch parameter.
-+ * </p>
-+ */
-+ public void encodeChildren(FacesContext context, UIComponent component)
-+ throws IOException {
-+ encode(context, component, ENCODE_CHILDREN);
-+ }
-+
-+ /**
-+ * <p>
-+ * Invokes the <code>encode</code> method passing <code>ENCODE_END</code>
-+ * for the encodeSwitch parameter.
-+ * </p>
-+ */
-+ public void encodeEnd(FacesContext context, UIComponent component)
-+ throws IOException {
-+ encode(context, component, ENCODE_END);
-+ }
-+
-+ /**
-+ * <p>
-+ * This method is hard-coded to return <code>true</code>. The other
-+ * overriden methods invoke the decorated original render.
-+ */
-+ public boolean getRendersChildren() {
-+ return defaultRenderer.getRendersChildren();
-+ }
-+
-+}
-Index: src/java/org/apache/shale/view/faces/ViewViewHandler.java
-===================================================================
---- src/java/org/apache/shale/view/faces/ViewViewHandler.java (revision 367478)
-+++ src/java/org/apache/shale/view/faces/ViewViewHandler.java (working copy)
-@@ -23,15 +23,18 @@
- import java.util.Map;
-
- import javax.faces.FacesException;
-+import javax.faces.FactoryFinder;
- import javax.faces.application.ViewHandler;
- import javax.faces.component.UIViewRoot;
- import javax.faces.context.FacesContext;
- import javax.faces.el.EvaluationException;
--import javax.faces.el.ValueBinding;
- import javax.faces.el.VariableResolver;
-+import javax.faces.render.RenderKit;
-+import javax.faces.render.RenderKitFactory;
-
- import org.apache.commons.logging.Log;
- import org.apache.commons.logging.LogFactory;
-+import org.apache.shale.faces.ValidatorRenderKit;
- import org.apache.shale.util.Messages;
- import org.apache.shale.view.Constants;
- import org.apache.shale.view.ViewController;
-@@ -124,6 +127,7 @@
- public UIViewRoot createView(FacesContext context, String viewId) {
- UIViewRoot view = original.createView(context, viewId);
- setupViewController(context, view, viewId, false);
-+ setupRenderKit(context, view);
- return view;
- }
-
-@@ -263,5 +267,13 @@
-
- }
-
-+
-+ private void setupRenderKit(FacesContext context, UIViewRoot view) {
-+ RenderKitFactory factory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
-+ RenderKit defaultRenderKit = factory.getRenderKit(context, view.getRenderKitId());
-+ if (!(defaultRenderKit instanceof ValidatorRenderKit))
-+ factory.addRenderKit(view.getRenderKitId(), new ValidatorRenderKit(defaultRenderKit));
-+ }
-
-+
- }
-Index: src/java/org/apache/shale/faces/ValidatorRenderKit.java
-===================================================================
---- src/java/org/apache/shale/faces/ValidatorRenderKit.java (revision 0)
-+++ src/java/org/apache/shale/faces/ValidatorRenderKit.java (revision 0)
-@@ -0,0 +1,68 @@
-+/*
-+ * Copyright 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.shale.faces;
-+
-+import java.io.OutputStream;
-+import java.io.Writer;
-+
-+import javax.faces.context.ResponseStream;
-+import javax.faces.context.ResponseWriter;
-+import javax.faces.render.RenderKit;
-+import javax.faces.render.Renderer;
-+import javax.faces.render.ResponseStateManager;
-+
-+import org.apache.shale.renderer.ValidatorCommandRenderer;
-+
-+public class ValidatorRenderKit extends RenderKit {
-+
-+ private RenderKit defaultRenderKit = null;
-+ public ValidatorRenderKit(RenderKit defaultRenderKit) {
-+ this.defaultRenderKit = defaultRenderKit;
-+ }
-+
-+ public void addRenderer(String componentFamily, String rendererType, Renderer renderer) {
-+ this.defaultRenderKit.addRenderer(componentFamily, rendererType, renderer);
-+ }
-+
-+ public Renderer getRenderer(String componentFamily, String rendererType) {
-+ Renderer target = defaultRenderKit.getRenderer(componentFamily, rendererType);
-+ if (componentFamily.equals("javax.faces.Command")) {
-+ if (!(target instanceof ValidatorCommandRenderer)) {
-+ target = new ValidatorCommandRenderer(target);
-+ addRenderer(componentFamily, rendererType, target);
-+ }
-+ }
-+
-+ return target;
-+ }
-+
-+ public ResponseStateManager getResponseStateManager() {
-+ return defaultRenderKit.getResponseStateManager();
-+ }
-+
-+ public ResponseWriter createResponseWriter(Writer writer,
-+ String contentTypeList,
-+ String characterEncoding){
-+ return defaultRenderKit.createResponseWriter(writer, contentTypeList, characterEncoding);
-+ }
-+
-+ public ResponseStream createResponseStream(OutputStream outputStream) {
-+ return defaultRenderKit.createResponseStream(outputStream);
-+ }
-+
-+}
-Index: src/java/org/apache/shale/validator/Globals.java
-===================================================================
---- src/java/org/apache/shale/validator/Globals.java (revision 367478)
-+++ src/java/org/apache/shale/validator/Globals.java (working copy)
-@@ -19,7 +19,7 @@
- /**
- * <p>Manifest constants that are global to the validator implementation.</p>
- *
-- * $Id:$
-+ * $Id$
- */
-
- public class Globals {
-Index: src/java/org/apache/shale/renderer/ValidatorCommandRenderer.java
-===================================================================
---- src/java/org/apache/shale/renderer/ValidatorCommandRenderer.java (revision 0)
-+++ src/java/org/apache/shale/renderer/ValidatorCommandRenderer.java (revision 0)
-@@ -0,0 +1,168 @@
-+/*
-+ * Copyright 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.shale.renderer;
-+
-+import java.io.IOException;
-+import java.io.StringWriter;
-+
-+import javax.faces.component.UICommand;
-+import javax.faces.component.UIComponent;
-+import javax.faces.context.FacesContext;
-+import javax.faces.context.ResponseWriter;
-+import javax.faces.render.Renderer;
-+
-+public class ValidatorCommandRenderer extends Renderer {
-+
-+ private Renderer defaultRenderer = null;
-+ public ValidatorCommandRenderer(Renderer defaultRenderer) {
-+ this.defaultRenderer = defaultRenderer;
-+ }
-+
-+
-+
-+ /**
-+ * <p>
-+ * Attribute name used to override the default behavior of how the immediate
-+ * attribute effects the execution of client side javascript validation.
-+ * </p>
-+ */
-+ public static final String OVERRIDE_IMMEDIATE = "org.apache.shale.validator.immediate";
-+
-+ private static final int ENCODE_BEGIN = 0;
-+
-+ private static final int ENCODE_CHILDREN = 1;
-+
-+ private static final int ENCODE_END = 2;
-+
-+ /**
-+ * <b>Interrogates the component's immediate property and the component's
-+ * immediate override attribute to determine if client side validation is
-+ * invoked. If either the property or attribute override is false, client
-+ * side validation is invoked. Otherwise, the response writer is hijacked
-+ * and the original render is invoked. The result is buffered and a
-+ * statement of javascript is injected into the onclick event which cancels
-+ * client side validation. The original response writer is restored and the
-+ * modified markup is written to the response writer. The
-+ * <code>encodeSwitch</code> determines if the encodeBegin, encodeChildren
-+ * or encodeEnd methods should be invoked on the decorated renderer.</b>
-+ */
-+ protected void encode(FacesContext context, UIComponent component,
-+ int encodeSwitch) throws IOException {
-+
-+ UICommand command = (UICommand) component;
-+
-+ // look for a override to the default
-+ boolean immediateOverride = true;
-+ String attr = (String) component.getAttributes()
-+ .get(OVERRIDE_IMMEDIATE);
-+ if (attr != null) {
-+ immediateOverride = Boolean.valueOf(attr).booleanValue();
-+ }
-+
-+ if (command.isImmediate() && immediateOverride) {
-+
-+ ResponseWriter hijackedWriter = context.getResponseWriter();
-+ // builds a buffer to write the page to
-+ StringWriter writer = new StringWriter();
-+ // create a buffered response writer
-+ ResponseWriter buffResponsewriter = context.getRenderKit()
-+ .createResponseWriter(writer, null,
-+ hijackedWriter.getCharacterEncoding());
-+ // push buffered writer to the faces context
-+ context.setResponseWriter(buffResponsewriter);
-+
-+ if (encodeSwitch == ENCODE_BEGIN)
-+ defaultRenderer.encodeBegin(context, component);
-+ else if (encodeSwitch == ENCODE_CHILDREN)
-+ defaultRenderer.encodeChildren(context, component);
-+ else
-+ defaultRenderer.encodeEnd(context, component);
-+
-+ StringBuffer buff = writer.getBuffer();
-+ int i = buff.indexOf("onclick=\"");
-+ if (i > 0) {
-+ buff.insert(i + "onclick=\"".length(), "bCancel=true;");
-+ }
-+
-+ hijackedWriter.write(buff.toString());
-+ context.setResponseWriter(hijackedWriter);
-+
-+ } else {
-+ if (encodeSwitch == ENCODE_BEGIN)
-+ defaultRenderer.encodeBegin(context, component);
-+ else if (encodeSwitch == ENCODE_CHILDREN)
-+ defaultRenderer.encodeChildren(context, component);
-+ else
-+ defaultRenderer.encodeEnd(context, component);
-+ }
-+ }
-+
-+
-+
-+ /**
-+ * <p>
-+ * Decorates the original component renderer invoking its decode method.
-+ * <p>
-+ */
-+ public void decode(FacesContext context, UIComponent component) {
-+ defaultRenderer.decode(context, component);
-+ }
-+
-+ /**
-+ * <p>
-+ * Invokes the <code>encode</code> method passing
-+ * <code>ENCODE_BEGIN</code> for the encodeSwitch parameter.
-+ * </p>
-+ */
-+ public void encodeBegin(FacesContext context, UIComponent component)
-+ throws IOException {
-+ encode(context, component, ENCODE_BEGIN);
-+ }
-+
-+ /**
-+ * <p>
-+ * Invokes the <code>encode</code> method passing
-+ * <code>ENCODE_CHILDREN</code> for the encodeSwitch parameter.
-+ * </p>
-+ */
-+ public void encodeChildren(FacesContext context, UIComponent component)
-+ throws IOException {
-+ encode(context, component, ENCODE_CHILDREN);
-+ }
-+
-+ /**
-+ * <p>
-+ * Invokes the <code>encode</code> method passing <code>ENCODE_END</code>
-+ * for the encodeSwitch parameter.
-+ * </p>
-+ */
-+ public void encodeEnd(FacesContext context, UIComponent component)
-+ throws IOException {
-+ encode(context, component, ENCODE_END);
-+ }
-+
-+ /**
-+ * <p>
-+ * This method is hard-coded to return <code>true</code>. The other
-+ * overriden methods invoke the decorated original render.
-+ */
-+ public boolean getRendersChildren() {
-+ return defaultRenderer.getRendersChildren();
-+ }
-+
-+}
-Index: src/java/org/apache/shale/view/faces/ViewViewHandler.java
-===================================================================
---- src/java/org/apache/shale/view/faces/ViewViewHandler.java (revision 367478)
-+++ src/java/org/apache/shale/view/faces/ViewViewHandler.java (working copy)
-@@ -23,15 +23,18 @@
- import java.util.Map;
-
- import javax.faces.FacesException;
-+import javax.faces.FactoryFinder;
- import javax.faces.application.ViewHandler;
- import javax.faces.component.UIViewRoot;
- import javax.faces.context.FacesContext;
- import javax.faces.el.EvaluationException;
--import javax.faces.el.ValueBinding;
- import javax.faces.el.VariableResolver;
-+import javax.faces.render.RenderKit;
-+import javax.faces.render.RenderKitFactory;
-
- import org.apache.commons.logging.Log;
- import org.apache.commons.logging.LogFactory;
-+import org.apache.shale.faces.ValidatorRenderKit;
- import org.apache.shale.util.Messages;
- import org.apache.shale.view.Constants;
- import org.apache.shale.view.ViewController;
-@@ -124,6 +127,7 @@
- public UIViewRoot createView(FacesContext context, String viewId) {
- UIViewRoot view = original.createView(context, viewId);
- setupViewController(context, view, viewId, false);
-+ setupRenderKit(context, view);
- return view;
- }
-
-@@ -263,5 +267,13 @@
-
- }
-
-+
-+ private void setupRenderKit(FacesContext context, UIViewRoot view) {
-+ RenderKitFactory factory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
-+ RenderKit defaultRenderKit = factory.getRenderKit(context, view.getRenderKitId());
-+ if (!(defaultRenderKit instanceof ValidatorRenderKit))
-+ factory.addRenderKit(view.getRenderKitId(), new ValidatorRenderKit(defaultRenderKit));
-+ }
-
-+
- }
-mplate. There is a central
+ but the entry point can be a full XML or full HTML template. There is a central
Clay configuration that is dedicated to full XML views and a base component definition
in the common clay configuration file.
<br/><br/>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org