You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/07/03 23:58:25 UTC
svn commit: r673833 [13/18] - in /myfaces/tomahawk/trunk:
core/src/main/java/org/apache/myfaces/component/
core/src/main/java/org/apache/myfaces/component/html/ext/
core/src/main/java/org/apache/myfaces/component/html/util/
core/src/main/java/org/apach...
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/valueChangeNotifier/ValueChangeManager.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/valueChangeNotifier/ValueChangeManager.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/valueChangeNotifier/ValueChangeManager.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/valueChangeNotifier/ValueChangeManager.java Thu Jul 3 14:58:05 2008
@@ -38,137 +38,137 @@
*/
public final class ValueChangeManager
{
- public final static Class[] SIGNATURE = new Class[]
- { ValueChangeEvent.class };
- private final static String VCL_MANAGER = "_VCL_MANAGER_"
- + ValueChangeNotifierTag.class.getName();
-
- private List events = new ArrayList(10);
-
- private static class Entry
- {
- private final String method;
- private final ValueChangeEvent event;
- private final List restoreStateCommands;
-
- public Entry(String method,
- ValueChangeEvent event,
- List restoreStateCommands)
- {
- this.method = method;
- this.event = event;
- this.restoreStateCommands = restoreStateCommands;
- }
- }
-
- private ValueChangeManager()
- {
- }
-
- /**
- * add a new event
- */
- public void addEvent(String method,
- ValueChangeEvent event,
- List restoreStateCommands)
- {
- events.add(new Entry(method, event, restoreStateCommands));
- }
-
- /**
- * walk through list and fire collected events
- */
- public void fireEvents(FacesContext context)
- {
- try
- {
- Iterator iterEvents = events.iterator();
- while (iterEvents.hasNext())
- {
- Entry entry = (Entry) iterEvents.next();
-
- saveCurrentStates(entry.restoreStateCommands);
-
- try
- {
- restoreEventStates(entry.restoreStateCommands);
-
- MethodBinding mb = context.getApplication().createMethodBinding(entry.method, SIGNATURE);
- mb.invoke(context, new Object[] { entry.event });
- }
- catch (MethodNotFoundException e)
- {
- throw new FacesException(e);
- }
- catch (AbortProcessingException e)
- {
- // ignore any other value change event
- return;
- }
- finally
- {
- restoreCurrentStates(entry.restoreStateCommands);
- }
- }
- }
- finally
- {
- events.clear();
- }
- }
-
- protected void saveCurrentStates(List restoreStateCommands)
- {
- for (int i = 0; i<restoreStateCommands.size(); i++)
- {
- RestoreStateCommand cmd = (RestoreStateCommand) restoreStateCommands.get(i);
- cmd.saveCurrentState();
- }
- }
-
- protected void restoreCurrentStates(List restoreStateCommands)
- {
- for (int i = restoreStateCommands.size()-1; i>=0; i--)
- {
- RestoreStateCommand cmd = (RestoreStateCommand) restoreStateCommands.get(i);
- cmd.restoreCurrentState();
- }
- }
-
- protected void restoreEventStates(List restoreStateCommands)
- {
- for (int i = restoreStateCommands.size()-1; i>=0; i--)
- {
- RestoreStateCommand cmd = (RestoreStateCommand) restoreStateCommands.get(i);
- cmd.restoreEventState();
- }
- }
-
- /**
- * check if the current request has a manager.<br />
- * The current request has a manager if, and only if it
- * collected valueChange events
- */
- public static boolean hasManager(FacesContext context)
- {
- Map requestMap = context.getExternalContext().getRequestMap();
- return requestMap.get(VCL_MANAGER) != null;
- }
-
- /**
- * get the manager for this request. Create one if needed.
- */
- public static ValueChangeManager getManager(FacesContext context)
- {
- Map requestMap = context.getExternalContext().getRequestMap();
- ValueChangeManager manager = (ValueChangeManager) requestMap
- .get(VCL_MANAGER);
- if (manager == null)
- {
- manager = new ValueChangeManager();
- requestMap.put(VCL_MANAGER, manager);
- }
+ public final static Class[] SIGNATURE = new Class[]
+ { ValueChangeEvent.class };
+ private final static String VCL_MANAGER = "_VCL_MANAGER_"
+ + ValueChangeNotifierTag.class.getName();
+
+ private List events = new ArrayList(10);
+
+ private static class Entry
+ {
+ private final String method;
+ private final ValueChangeEvent event;
+ private final List restoreStateCommands;
+
+ public Entry(String method,
+ ValueChangeEvent event,
+ List restoreStateCommands)
+ {
+ this.method = method;
+ this.event = event;
+ this.restoreStateCommands = restoreStateCommands;
+ }
+ }
+
+ private ValueChangeManager()
+ {
+ }
+
+ /**
+ * add a new event
+ */
+ public void addEvent(String method,
+ ValueChangeEvent event,
+ List restoreStateCommands)
+ {
+ events.add(new Entry(method, event, restoreStateCommands));
+ }
+
+ /**
+ * walk through list and fire collected events
+ */
+ public void fireEvents(FacesContext context)
+ {
+ try
+ {
+ Iterator iterEvents = events.iterator();
+ while (iterEvents.hasNext())
+ {
+ Entry entry = (Entry) iterEvents.next();
+
+ saveCurrentStates(entry.restoreStateCommands);
+
+ try
+ {
+ restoreEventStates(entry.restoreStateCommands);
+
+ MethodBinding mb = context.getApplication().createMethodBinding(entry.method, SIGNATURE);
+ mb.invoke(context, new Object[] { entry.event });
+ }
+ catch (MethodNotFoundException e)
+ {
+ throw new FacesException(e);
+ }
+ catch (AbortProcessingException e)
+ {
+ // ignore any other value change event
+ return;
+ }
+ finally
+ {
+ restoreCurrentStates(entry.restoreStateCommands);
+ }
+ }
+ }
+ finally
+ {
+ events.clear();
+ }
+ }
+
+ protected void saveCurrentStates(List restoreStateCommands)
+ {
+ for (int i = 0; i<restoreStateCommands.size(); i++)
+ {
+ RestoreStateCommand cmd = (RestoreStateCommand) restoreStateCommands.get(i);
+ cmd.saveCurrentState();
+ }
+ }
+
+ protected void restoreCurrentStates(List restoreStateCommands)
+ {
+ for (int i = restoreStateCommands.size()-1; i>=0; i--)
+ {
+ RestoreStateCommand cmd = (RestoreStateCommand) restoreStateCommands.get(i);
+ cmd.restoreCurrentState();
+ }
+ }
+
+ protected void restoreEventStates(List restoreStateCommands)
+ {
+ for (int i = restoreStateCommands.size()-1; i>=0; i--)
+ {
+ RestoreStateCommand cmd = (RestoreStateCommand) restoreStateCommands.get(i);
+ cmd.restoreEventState();
+ }
+ }
+
+ /**
+ * check if the current request has a manager.<br />
+ * The current request has a manager if, and only if it
+ * collected valueChange events
+ */
+ public static boolean hasManager(FacesContext context)
+ {
+ Map requestMap = context.getExternalContext().getRequestMap();
+ return requestMap.get(VCL_MANAGER) != null;
+ }
+
+ /**
+ * get the manager for this request. Create one if needed.
+ */
+ public static ValueChangeManager getManager(FacesContext context)
+ {
+ Map requestMap = context.getExternalContext().getRequestMap();
+ ValueChangeManager manager = (ValueChangeManager) requestMap
+ .get(VCL_MANAGER);
+ if (manager == null)
+ {
+ manager = new ValueChangeManager();
+ requestMap.put(VCL_MANAGER, manager);
+ }
- return manager;
- }
+ return manager;
+ }
}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/valueChangeNotifier/ValueChangeNotifierTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/valueChangeNotifier/ValueChangeNotifierTag.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/valueChangeNotifier/ValueChangeNotifierTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/valueChangeNotifier/ValueChangeNotifierTag.java Thu Jul 3 14:58:05 2008
@@ -50,73 +50,73 @@
*/
public class ValueChangeNotifierTag extends TagSupport
{
- private String method = null;
-
- private static Log log = LogFactory.getLog(ValueChangeNotifierTag.class);
-
- public ValueChangeNotifierTag()
- {
- }
-
- /**
- * The bean.method name of your valueChange method<br />
- * Currently only methods listeners are supported.<br />
- * e.g. myBean.myListenerMethod
- *
- * @JSFJspAttribute
- * required = "true"
- */
- public void setMethod(String method)
- {
- this.method = method;
- }
-
- public int doStartTag() throws JspException
- {
- if (method == null)
- {
- throw new JspException("name attribute not set");
- }
-
- // Find parent UIComponentTag
- UIComponentTag componentTag = UIComponentTag
- .getParentUIComponentTag(pageContext);
- if (componentTag == null)
- {
- throw new JspException(
- "ValueChangeListenerTag has no UIComponentTag ancestor");
- }
-
- if (componentTag.getCreated())
- {
- // Component was just created, so we add the Listener
- UIComponent component = componentTag.getComponentInstance();
- if (component instanceof EditableValueHolder)
- {
- setupClassListener(component);
- }
- else
- {
- throw new JspException("Component " + component.getId()
- + " is no EditableValueHolder");
- }
- }
-
- return Tag.SKIP_BODY;
- }
-
- protected void setupClassListener(UIComponent component)
- {
- if (UIComponentTag.isValueReference(method))
- {
- ((EditableValueHolder) component)
- .addValueChangeListener(new ValueChangeCollector(method));
- }
- else
- {
- if(log.isErrorEnabled()){
- log.error("Invalid expression " + method);
- }
- }
- }
+ private String method = null;
+
+ private static Log log = LogFactory.getLog(ValueChangeNotifierTag.class);
+
+ public ValueChangeNotifierTag()
+ {
+ }
+
+ /**
+ * The bean.method name of your valueChange method<br />
+ * Currently only methods listeners are supported.<br />
+ * e.g. myBean.myListenerMethod
+ *
+ * @JSFJspAttribute
+ * required = "true"
+ */
+ public void setMethod(String method)
+ {
+ this.method = method;
+ }
+
+ public int doStartTag() throws JspException
+ {
+ if (method == null)
+ {
+ throw new JspException("name attribute not set");
+ }
+
+ // Find parent UIComponentTag
+ UIComponentTag componentTag = UIComponentTag
+ .getParentUIComponentTag(pageContext);
+ if (componentTag == null)
+ {
+ throw new JspException(
+ "ValueChangeListenerTag has no UIComponentTag ancestor");
+ }
+
+ if (componentTag.getCreated())
+ {
+ // Component was just created, so we add the Listener
+ UIComponent component = componentTag.getComponentInstance();
+ if (component instanceof EditableValueHolder)
+ {
+ setupClassListener(component);
+ }
+ else
+ {
+ throw new JspException("Component " + component.getId()
+ + " is no EditableValueHolder");
+ }
+ }
+
+ return Tag.SKIP_BODY;
+ }
+
+ protected void setupClassListener(UIComponent component)
+ {
+ if (UIComponentTag.isValueReference(method))
+ {
+ ((EditableValueHolder) component)
+ .addValueChangeListener(new ValueChangeCollector(method));
+ }
+ else
+ {
+ if(log.isErrorEnabled()){
+ log.error("Invalid expression " + method);
+ }
+ }
+ }
}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/valueChangeNotifier/ValueChangePhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/valueChangeNotifier/ValueChangePhaseListener.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/valueChangeNotifier/ValueChangePhaseListener.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/valueChangeNotifier/ValueChangePhaseListener.java Thu Jul 3 14:58:05 2008
@@ -30,25 +30,25 @@
*/
public class ValueChangePhaseListener implements PhaseListener
{
- public ValueChangePhaseListener()
- {
- }
+ public ValueChangePhaseListener()
+ {
+ }
- public void afterPhase(PhaseEvent event)
- {
- if (ValueChangeManager.hasManager(event.getFacesContext()))
- {
- ValueChangeManager manager = ValueChangeManager.getManager(event.getFacesContext());
- manager.fireEvents(event.getFacesContext());
- }
- }
+ public void afterPhase(PhaseEvent event)
+ {
+ if (ValueChangeManager.hasManager(event.getFacesContext()))
+ {
+ ValueChangeManager manager = ValueChangeManager.getManager(event.getFacesContext());
+ manager.fireEvents(event.getFacesContext());
+ }
+ }
- public void beforePhase(PhaseEvent event)
- {
- }
+ public void beforePhase(PhaseEvent event)
+ {
+ }
- public PhaseId getPhaseId()
- {
- return PhaseId.UPDATE_MODEL_VALUES;
- }
+ public PhaseId getPhaseId()
+ {
+ return PhaseId.UPDATE_MODEL_VALUES;
+ }
}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlButtonExRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlButtonExRenderer.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlButtonExRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlButtonExRenderer.java Thu Jul 3 14:58:05 2008
@@ -39,17 +39,17 @@
* @version $Revision$ $Date$
*/
public class HtmlButtonExRenderer extends HtmlButtonRenderer{
-
- public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
- HtmlCommandButton button = (HtmlCommandButton) component;
-
- if(CVUtils.isCVEnabled() && button.isImmediate()) {
- String bypassCVScript = "document.getElementById('" + CVUtils.BYPASS_CLIENT_VALIDATION_FIELD + "').value = true;";
- ComponentUtils.decorateEventAttribute(component, "onclick", bypassCVScript);
- }
-
- super.encodeBegin(context, component);
- }
+
+ public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
+ HtmlCommandButton button = (HtmlCommandButton) component;
+
+ if(CVUtils.isCVEnabled() && button.isImmediate()) {
+ String bypassCVScript = "document.getElementById('" + CVUtils.BYPASS_CLIENT_VALIDATION_FIELD + "').value = true;";
+ ComponentUtils.decorateEventAttribute(component, "onclick", bypassCVScript);
+ }
+
+ super.encodeBegin(context, component);
+ }
-
+
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlFormRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlFormRenderer.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlFormRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlFormRenderer.java Thu Jul 3 14:58:05 2008
@@ -40,39 +40,39 @@
*/
public class HtmlFormRenderer extends HtmlFormRendererBase{
- private static String CLIENT_VALIDATON_SCRIPT = "return tomahawk.executeClientLifeCycle();";
-
- public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
- if(CVUtils.isCVEnabled()) {
- ComponentUtils.decorateEventAttribute(component, "onsubmit", CLIENT_VALIDATON_SCRIPT);
- }
-
- super.encodeBegin(facesContext, component);
+ private static String CLIENT_VALIDATON_SCRIPT = "return tomahawk.executeClientLifeCycle();";
+
+ public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
+ if(CVUtils.isCVEnabled()) {
+ ComponentUtils.decorateEventAttribute(component, "onsubmit", CLIENT_VALIDATON_SCRIPT);
+ }
+
+ super.encodeBegin(facesContext, component);
}
public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
- if(CVUtils.isCVEnabled()) {
- encodeBypassCVField(facesContext, component);
- }
-
- super.encodeEnd(facesContext, component);
-
- if(CVUtils.isCVEnabled()) {
- CVUtils.encodeJavascript(facesContext);
- CVUtils.queueCVCalls(facesContext.getViewRoot());
- CVUtils.encodeValidationScript(facesContext);
- }
+ if(CVUtils.isCVEnabled()) {
+ encodeBypassCVField(facesContext, component);
+ }
+
+ super.encodeEnd(facesContext, component);
+
+ if(CVUtils.isCVEnabled()) {
+ CVUtils.encodeJavascript(facesContext);
+ CVUtils.queueCVCalls(facesContext.getViewRoot());
+ CVUtils.encodeValidationScript(facesContext);
+ }
}
//Renders a hidden input field that will act as a flag to bypass client validation or not
- private void encodeBypassCVField(FacesContext facesContext, UIComponent component) throws IOException{
- ResponseWriter writer = facesContext.getResponseWriter();
-
- writer.startElement("input", component);
- writer.writeAttribute("type", "hidden", null);
- writer.writeAttribute("id", CVUtils.BYPASS_CLIENT_VALIDATION_FIELD, null);
- writer.writeAttribute("name", CVUtils.BYPASS_CLIENT_VALIDATION_FIELD, null);
- writer.writeAttribute("value", "false", null); //immediate command components make this value true when they're clicked
- writer.endElement("input");
- }
+ private void encodeBypassCVField(FacesContext facesContext, UIComponent component) throws IOException{
+ ResponseWriter writer = facesContext.getResponseWriter();
+
+ writer.startElement("input", component);
+ writer.writeAttribute("type", "hidden", null);
+ writer.writeAttribute("id", CVUtils.BYPASS_CLIENT_VALIDATION_FIELD, null);
+ writer.writeAttribute("name", CVUtils.BYPASS_CLIENT_VALIDATION_FIELD, null);
+ writer.writeAttribute("value", "false", null); //immediate command components make this value true when they're clicked
+ writer.endElement("input");
+ }
}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/validator/ex/DoubleRangeValidator.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/validator/ex/DoubleRangeValidator.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/validator/ex/DoubleRangeValidator.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/validator/ex/DoubleRangeValidator.java Thu Jul 3 14:58:05 2008
@@ -26,11 +26,11 @@
*/
public class DoubleRangeValidator extends javax.faces.validator.DoubleRangeValidator implements ClientValidator{
- public String getScriptFunction() {
- return "tomahawk.DoubleRangeValidator(" + getMinimum() + "," + getMaximum() + ")";
- }
+ public String getScriptFunction() {
+ return "tomahawk.DoubleRangeValidator(" + getMinimum() + "," + getMaximum() + ")";
+ }
- public String getScriptResource() {
- return null;
- }
+ public String getScriptResource() {
+ return null;
+ }
}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/validator/ex/LengthValidator.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/validator/ex/LengthValidator.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/validator/ex/LengthValidator.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/validator/ex/LengthValidator.java Thu Jul 3 14:58:05 2008
@@ -26,12 +26,12 @@
*/
public class LengthValidator extends javax.faces.validator.LengthValidator implements ClientValidator{
- public String getScriptFunction() {
- return "tomahawk.LengthValidator(" + getMinimum() + "," + getMaximum() + ")";
- }
+ public String getScriptFunction() {
+ return "tomahawk.LengthValidator(" + getMinimum() + "," + getMaximum() + ")";
+ }
- public String getScriptResource() {
- return null;
- }
+ public String getScriptResource() {
+ return null;
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/validator/ex/LongRangeValidator.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/validator/ex/LongRangeValidator.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/validator/ex/LongRangeValidator.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/validator/ex/LongRangeValidator.java Thu Jul 3 14:58:05 2008
@@ -26,11 +26,11 @@
*/
public class LongRangeValidator extends javax.faces.validator.LongRangeValidator implements ClientValidator{
- public String getScriptFunction() {
- return "tomahawk.LongRangeValidator(" + getMinimum() + "," + getMaximum() + ")";
- }
+ public String getScriptFunction() {
+ return "tomahawk.LongRangeValidator(" + getMinimum() + "," + getMaximum() + ")";
+ }
- public String getScriptResource() {
- return null;
- }
+ public String getScriptResource() {
+ return null;
+ }
}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/convertNumber/TypedNumberConverterTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/convertNumber/TypedNumberConverterTest.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/convertNumber/TypedNumberConverterTest.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/convertNumber/TypedNumberConverterTest.java Thu Jul 3 14:58:05 2008
@@ -28,45 +28,45 @@
import org.apache.shale.test.base.AbstractJsfTestCase;
/**
- * @author cagatay (latest modification by $Author:$)
+ * @author cagatay (latest modification by $Author$)
* @version $Revision$ $Date$
*/
public class TypedNumberConverterTest extends AbstractJsfTestCase{
-
- private TypedNumberConverter converter;
-
- public TypedNumberConverterTest(String testName) {
- super(testName);
- }
-
- public void setUp() throws Exception{
- super.setUp();
- converter = new TypedNumberConverter();
- }
-
- public void tearDown() throws Exception{
- super.tearDown();
- converter = null;
- }
-
- public static Test suite() {
- return new TestSuite(TypedNumberConverterTest.class);
- }
-
- public void testSeverityLevelOfMessageShouldBeErrorInCaseConversionFails() {
- UIInput input = new UIInput();
- input.setId("txt_test");
-
- converter.setIntegerOnly(true);
-
- try {
- converter.getAsObject(facesContext, input, "test_invalid_input");
-
- fail();
- }catch (ConverterException exception) {
- FacesMessage facesMessage = exception.getFacesMessage();
- assertEquals(FacesMessage.SEVERITY_ERROR, facesMessage.getSeverity());
- }
-
- }
+
+ private TypedNumberConverter converter;
+
+ public TypedNumberConverterTest(String testName) {
+ super(testName);
+ }
+
+ public void setUp() throws Exception{
+ super.setUp();
+ converter = new TypedNumberConverter();
+ }
+
+ public void tearDown() throws Exception{
+ super.tearDown();
+ converter = null;
+ }
+
+ public static Test suite() {
+ return new TestSuite(TypedNumberConverterTest.class);
+ }
+
+ public void testSeverityLevelOfMessageShouldBeErrorInCaseConversionFails() {
+ UIInput input = new UIInput();
+ input.setId("txt_test");
+
+ converter.setIntegerOnly(true);
+
+ try {
+ converter.getAsObject(facesContext, input, "test_invalid_input");
+
+ fail();
+ }catch (ConverterException exception) {
+ FacesMessage facesMessage = exception.getFacesMessage();
+ assertEquals(FacesMessage.SEVERITY_ERROR, facesMessage.getSeverity());
+ }
+
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/security/SecurityContextPropertyResolverTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/security/SecurityContextPropertyResolverTest.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/security/SecurityContextPropertyResolverTest.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/security/SecurityContextPropertyResolverTest.java Thu Jul 3 14:58:05 2008
@@ -31,49 +31,49 @@
*/
public class SecurityContextPropertyResolverTest extends AbstractJsfTestCase{
- protected SecurityContextPropertyResolver resolver;
-
- public SecurityContextPropertyResolverTest(String testName) {
- super(testName);
- }
-
- public void setUp() throws Exception{
- super.setUp();
- resolver = new SecurityContextPropertyResolver(null);
- }
-
- public void tearDown() throws Exception{
- super.tearDown();
- resolver = null;
- }
-
- public static Test suite() {
- return new TestSuite(SecurityContextPropertyResolverTest.class);
- }
-
- //#{securityContext.remoteUser}
- public void testRemoteUser() {
- request.setUserPrincipal(new TestPrincipalImpl("Ronaldinho"));
-
- SecurityContext securityContext = new SecurityContextImpl();
- String user = (String) resolver.getValue(securityContext, "remoteUser");
- assertEquals("Ronaldinho", user);
- }
-
- public static class TestPrincipalImpl implements Principal {
+ protected SecurityContextPropertyResolver resolver;
+
+ public SecurityContextPropertyResolverTest(String testName) {
+ super(testName);
+ }
+
+ public void setUp() throws Exception{
+ super.setUp();
+ resolver = new SecurityContextPropertyResolver(null);
+ }
+
+ public void tearDown() throws Exception{
+ super.tearDown();
+ resolver = null;
+ }
+
+ public static Test suite() {
+ return new TestSuite(SecurityContextPropertyResolverTest.class);
+ }
+
+ //#{securityContext.remoteUser}
+ public void testRemoteUser() {
+ request.setUserPrincipal(new TestPrincipalImpl("Ronaldinho"));
+
+ SecurityContext securityContext = new SecurityContextImpl();
+ String user = (String) resolver.getValue(securityContext, "remoteUser");
+ assertEquals("Ronaldinho", user);
+ }
+
+ public static class TestPrincipalImpl implements Principal {
- private String _name;
+ private String _name;
- public TestPrincipalImpl() {
- // NoOp
- }
+ public TestPrincipalImpl() {
+ // NoOp
+ }
- public TestPrincipalImpl(String name) {
- this._name = name;
- }
+ public TestPrincipalImpl(String name) {
+ this._name = name;
+ }
- public String getName() {
- return _name;
- }
- }
+ public String getName() {
+ return _name;
+ }
+ }
}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/security/SecurityContextVariableResolverTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/security/SecurityContextVariableResolverTest.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/security/SecurityContextVariableResolverTest.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/security/SecurityContextVariableResolverTest.java Thu Jul 3 14:58:05 2008
@@ -31,46 +31,46 @@
*/
public class SecurityContextVariableResolverTest extends AbstractJsfTestCase{
- protected SecurityContextVariableResolver resolver;
-
- public SecurityContextVariableResolverTest(String testName) {
- super(testName);
- }
-
- public void setUp() throws Exception{
- super.setUp();
- resolver = new SecurityContextVariableResolver(null);
- }
-
- public void tearDown() throws Exception{
- super.tearDown();
- resolver = null;
- }
-
- public static Test suite() {
- return new TestSuite(SecurityContextVariableResolverTest.class);
- }
-
- public void testSecurityContextImplIsDefaultImplWhenNoCustomImplIsConfigured() {
- SecurityContext securityContext = (SecurityContext)resolver.resolveVariable(facesContext, "securityContext");
- assertTrue(securityContext instanceof SecurityContextImpl);
- }
-
- public void testSecurityContextImplIsCustomWhenCustomImplIsConfigured() {
- servletContext.addInitParameter("org.apache.myfaces.SECURITY_CONTEXT", "org.apache.myfaces.custom.security.TestSecurityContextImpl");
- SecurityContext securityContext = (SecurityContext)resolver.resolveVariable(facesContext, "securityContext");
- assertFalse(securityContext instanceof SecurityContextImpl);
- assertTrue(securityContext instanceof TestSecurityContextImpl);
- }
-
- public void testExceptionMustBeThrownWhenAnInvalidImplIsConfigured() {
- servletContext.addInitParameter("org.apache.myfaces.SECURITY_CONTEXT", "this.class.does.not.exist");
- try {
- resolver.resolveVariable(facesContext, "securityContext");
- }catch(EvaluationException evaluationException) {
- return;
- }
- fail();
-
- }
+ protected SecurityContextVariableResolver resolver;
+
+ public SecurityContextVariableResolverTest(String testName) {
+ super(testName);
+ }
+
+ public void setUp() throws Exception{
+ super.setUp();
+ resolver = new SecurityContextVariableResolver(null);
+ }
+
+ public void tearDown() throws Exception{
+ super.tearDown();
+ resolver = null;
+ }
+
+ public static Test suite() {
+ return new TestSuite(SecurityContextVariableResolverTest.class);
+ }
+
+ public void testSecurityContextImplIsDefaultImplWhenNoCustomImplIsConfigured() {
+ SecurityContext securityContext = (SecurityContext)resolver.resolveVariable(facesContext, "securityContext");
+ assertTrue(securityContext instanceof SecurityContextImpl);
+ }
+
+ public void testSecurityContextImplIsCustomWhenCustomImplIsConfigured() {
+ servletContext.addInitParameter("org.apache.myfaces.SECURITY_CONTEXT", "org.apache.myfaces.custom.security.TestSecurityContextImpl");
+ SecurityContext securityContext = (SecurityContext)resolver.resolveVariable(facesContext, "securityContext");
+ assertFalse(securityContext instanceof SecurityContextImpl);
+ assertTrue(securityContext instanceof TestSecurityContextImpl);
+ }
+
+ public void testExceptionMustBeThrownWhenAnInvalidImplIsConfigured() {
+ servletContext.addInitParameter("org.apache.myfaces.SECURITY_CONTEXT", "this.class.does.not.exist");
+ try {
+ resolver.resolveVariable(facesContext, "securityContext");
+ }catch(EvaluationException evaluationException) {
+ return;
+ }
+ fail();
+
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/security/TestSecurityContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/security/TestSecurityContextImpl.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/security/TestSecurityContextImpl.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/security/TestSecurityContextImpl.java Thu Jul 3 14:58:05 2008
@@ -23,16 +23,16 @@
* @version $Revision$ $Date$
*/
public class TestSecurityContextImpl extends SecurityContext{
-
- public String getAuthType() {
- return null;
- }
+
+ public String getAuthType() {
+ return null;
+ }
- public String getRemoteUser() {
- return null;
- }
+ public String getRemoteUser() {
+ return null;
+ }
- public boolean ifGranted(String role) {
- return false;
- }
+ public boolean ifGranted(String role) {
+ return false;
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/util/ComponentUtilsTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/util/ComponentUtilsTest.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/util/ComponentUtilsTest.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/custom/util/ComponentUtilsTest.java Thu Jul 3 14:58:05 2008
@@ -28,18 +28,18 @@
*/
public class ComponentUtilsTest extends TestCase{
- public void testDecorateEventAttribute() {
- HtmlCommandButton button = new HtmlCommandButton();
- button.setId("testButton");
-
- ComponentUtils.decorateEventAttribute(button, "onclick", "alert('Whad up?');");
- assertEquals("alert('Whad up?');", (String) button.getAttributes().get("onclick"));
-
- //Second try to decorate with same value
- ComponentUtils.decorateEventAttribute(button, "onclick", "alert('Whad up?');");
- assertEquals("alert('Whad up?');", (String) button.getAttributes().get("onclick"));
-
- ComponentUtils.decorateEventAttribute(button, "onclick", "return false;");
- assertEquals("alert('Whad up?');return false;", (String) button.getAttributes().get("onclick"));
- }
+ public void testDecorateEventAttribute() {
+ HtmlCommandButton button = new HtmlCommandButton();
+ button.setId("testButton");
+
+ ComponentUtils.decorateEventAttribute(button, "onclick", "alert('Whad up?');");
+ assertEquals("alert('Whad up?');", (String) button.getAttributes().get("onclick"));
+
+ //Second try to decorate with same value
+ ComponentUtils.decorateEventAttribute(button, "onclick", "alert('Whad up?');");
+ assertEquals("alert('Whad up?');", (String) button.getAttributes().get("onclick"));
+
+ ComponentUtils.decorateEventAttribute(button, "onclick", "return false;");
+ assertEquals("alert('Whad up?');return false;", (String) button.getAttributes().get("onclick"));
+ }
}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/test/AbstractTagLibTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/test/AbstractTagLibTestCase.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/test/AbstractTagLibTestCase.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/test/AbstractTagLibTestCase.java Thu Jul 3 14:58:05 2008
@@ -51,190 +51,190 @@
*/
public abstract class AbstractTagLibTestCase extends TestCase {
- private static Log log = LogFactory.getLog(AbstractTagLibTestCase.class);
+ private static Log log = LogFactory.getLog(AbstractTagLibTestCase.class);
- protected Tld[] tlds;
+ protected Tld[] tlds;
- protected String[] tldPaths;
-
- private ClassLoader classLoader = getClass().getClassLoader();
+ protected String[] tldPaths;
+
+ private ClassLoader classLoader = getClass().getClassLoader();
- /**
- * Unmarshall TLDs to an object model. TLDs are supplied by a subclass.
- */
+ /**
+ * Unmarshall TLDs to an object model. TLDs are supplied by a subclass.
+ */
- protected void setUp() throws Exception {
+ protected void setUp() throws Exception {
- if (tldPaths == null)
- throw new NullPointerException(
- "tldPaths cannot point to null before setUp() is called");
+ if (tldPaths == null)
+ throw new NullPointerException(
+ "tldPaths cannot point to null before setUp() is called");
- int length = tldPaths.length;
+ int length = tldPaths.length;
- if (length == 0)
- throw new IllegalStateException(
- "tldPaths should have at least one resource path");
+ if (length == 0)
+ throw new IllegalStateException(
+ "tldPaths should have at least one resource path");
- tlds = new Tld[length];
+ tlds = new Tld[length];
- for (int t = 0; t < length; t++) {
- String name = tldPaths[t];
+ for (int t = 0; t < length; t++) {
+ String name = tldPaths[t];
- InputStream stream = classLoader.getResourceAsStream(name);
+ InputStream stream = classLoader.getResourceAsStream(name);
- if (stream == null)
- throw new NullPointerException(
- "couldn't get an input stream for " + name);
+ if (stream == null)
+ throw new NullPointerException(
+ "couldn't get an input stream for " + name);
- tlds[t] = TldTestUtils.getTld(name, stream);
- stream.close();
- }
- }
+ tlds[t] = TldTestUtils.getTld(name, stream);
+ stream.close();
+ }
+ }
- public void testUniqueTagTestCase() throws Exception {
+ public void testUniqueTagTestCase() throws Exception {
- for (int lib = 0; lib < tlds.length; lib++) {
- Tld tld = tlds[lib];
- List tagNames = new ArrayList();
- Tag[] tags = tld.getTags();
+ for (int lib = 0; lib < tlds.length; lib++) {
+ Tld tld = tlds[lib];
+ List tagNames = new ArrayList();
+ Tag[] tags = tld.getTags();
- for (int t = 0; t < tags.length; t++) {
- Tag tag = tags[t];
+ for (int t = 0; t < tags.length; t++) {
+ Tag tag = tags[t];
- if (tag == null)
- throw new NullPointerException("tag");
+ if (tag == null)
+ throw new NullPointerException("tag");
- String name = tag.getName();
- String msg = name + " found more than once in " + tldPaths[lib];
- assertFalse(msg, tagNames.contains(name));
- tagNames.add(name);
- } // end t
- } // end lib
- }
+ String name = tag.getName();
+ String msg = name + " found more than once in " + tldPaths[lib];
+ assertFalse(msg, tagNames.contains(name));
+ tagNames.add(name);
+ } // end t
+ } // end lib
+ }
- public void testUniqueTagAttributes() throws Exception {
+ public void testUniqueTagAttributes() throws Exception {
- for (int lib = 0; lib < tlds.length; lib++) {
- Tld tld = tlds[lib];
- Tag[] tags = tld.getTags();
+ for (int lib = 0; lib < tlds.length; lib++) {
+ Tld tld = tlds[lib];
+ Tag[] tags = tld.getTags();
- for (int t = 0; t < tags.length; t++) {
+ for (int t = 0; t < tags.length; t++) {
- Tag tag = tags[t];
- assertUniqueTagAttributes(tag, tldPaths[lib]);
+ Tag tag = tags[t];
+ assertUniqueTagAttributes(tag, tldPaths[lib]);
- } // end t
- } // end lib
- }
+ } // end t
+ } // end lib
+ }
- private void assertUniqueTagAttributes(final Tag tag, final String path) {
+ private void assertUniqueTagAttributes(final Tag tag, final String path) {
- List attributeNames = new ArrayList();
- TagAttribute[] atts = tag.getAttributes();
- String tagName = tag.getName();
+ List attributeNames = new ArrayList();
+ TagAttribute[] atts = tag.getAttributes();
+ String tagName = tag.getName();
- for (int a = 0; a < atts.length;) {
+ for (int a = 0; a < atts.length;) {
- TagAttribute att = atts[a++];
- String name = att.getAttributeName();
- String msg = " @" + name + " of " + path + ":" + tagName
- + " is duplicated.";
- assertFalse(msg, attributeNames.contains(name));
- attributeNames.add(name);
+ TagAttribute att = atts[a++];
+ String name = att.getAttributeName();
+ String msg = " @" + name + " of " + path + ":" + tagName
+ + " is duplicated.";
+ assertFalse(msg, attributeNames.contains(name));
+ attributeNames.add(name);
- } // end a
+ } // end a
- }
+ }
- /**
- * Make sure the class exists. Make sure there is a setter for each
- * attribute.
- */
+ /**
+ * Make sure the class exists. Make sure there is a setter for each
+ * attribute.
+ */
- public void testSetters() throws Exception {
+ public void testSetters() throws Exception {
- for (int t = 0; t < tlds.length; t++) {
- Tld tld = tlds[t];
- Tag[] tags = tld.getTags();
+ for (int t = 0; t < tlds.length; t++) {
+ Tld tld = tlds[t];
+ Tag[] tags = tld.getTags();
- for (int s = 0; s < tags.length; s++) {
- Tag tag = tags[s];
- String filename = tld.getFilename();
+ for (int s = 0; s < tags.length; s++) {
+ Tag tag = tags[s];
+ String filename = tld.getFilename();
- Object object = TldTestUtils.makeTagClassInstance(tag,
- filename, classLoader);
+ Object object = TldTestUtils.makeTagClassInstance(tag,
+ filename, classLoader);
log.debug("filename = " + filename + " ; tag = " + tag.getName());
assertSetters(tag, filename, object);
- } // end for tag
- } // end for lib
+ } // end for tag
+ } // end for lib
- }
+ }
- private void assertSetters(final Tag tag, final String path,
- final Object object) {
+ private void assertSetters(final Tag tag, final String path,
+ final Object object) {
- TagAttribute[] attributes = tag.getAttributes();
- String tagName = tag.getName();
+ TagAttribute[] attributes = tag.getAttributes();
+ String tagName = tag.getName();
- for (int a = 0; a < attributes.length; a++) {
- TagAttribute attribute = attributes[a];
- String name = attribute.getAttributeName();
+ for (int a = 0; a < attributes.length; a++) {
+ TagAttribute attribute = attributes[a];
+ String name = attribute.getAttributeName();
- if (name == null || "".equals(name.trim()))
- throw new IllegalStateException(path + ":" + tagName
- + " has a nameless attribute ");
+ if (name == null || "".equals(name.trim()))
+ throw new IllegalStateException(path + ":" + tagName
+ + " has a nameless attribute ");
- String msg = path + ":" + tagName + "@" + name
- + " exists, but " + object.getClass().getName()
- + " has no setter.";
-
- assertTrue(msg, PropertyUtils.isWriteable(object, name));
- } // end for attributes
+ String msg = path + ":" + tagName + "@" + name
+ + " exists, but " + object.getClass().getName()
+ + " has no setter.";
+
+ assertTrue(msg, PropertyUtils.isWriteable(object, name));
+ } // end for attributes
- }
+ }
- private static class TldTestUtils {
- private static Log log = LogFactory.getLog(TldTestUtils.class);
+ private static class TldTestUtils {
+ private static Log log = LogFactory.getLog(TldTestUtils.class);
- private static DocumentBuilderFactory dbf = DocumentBuilderFactory
- .newInstance();
+ private static DocumentBuilderFactory dbf = DocumentBuilderFactory
+ .newInstance();
- public static Tld getTld(String name, InputStream stream)
- throws Exception {
- if (stream == null)
- log.error(" input stream is null ");
+ public static Tld getTld(String name, InputStream stream)
+ throws Exception {
+ if (stream == null)
+ log.error(" input stream is null ");
- DocumentBuilder db = dbf.newDocumentBuilder();
- Document doc = db.parse(stream);
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.parse(stream);
- return TldParser.parse(doc, name);
- }
+ return TldParser.parse(doc, name);
+ }
- public static Object makeTagClassInstance(Tag tag, String filename,
- ClassLoader classLoader) throws Exception {
+ public static Object makeTagClassInstance(Tag tag, String filename,
+ ClassLoader classLoader) throws Exception {
- String clazzName = tag.getTagClass();
+ String clazzName = tag.getTagClass();
- if (clazzName == null || "".equals(clazzName.trim()))
- throw new NullPointerException(tag.getName()
- + " is missing a tag class.");
+ if (clazzName == null || "".equals(clazzName.trim()))
+ throw new NullPointerException(tag.getName()
+ + " is missing a tag class.");
- try {
+ try {
- Class clazz = classLoader.loadClass(clazzName);
- return clazz.newInstance();
+ Class clazz = classLoader.loadClass(clazzName);
+ return clazz.newInstance();
- } catch (ClassNotFoundException e) {
- throw new ClassNotFoundException(clazzName);
- } catch (IllegalAccessException ie) {
- throw new IllegalAccessException(clazzName);
- } catch (InstantiationException iste) {
- throw new InstantiationException(clazzName);
- }
+ } catch (ClassNotFoundException e) {
+ throw new ClassNotFoundException(clazzName);
+ } catch (IllegalAccessException ie) {
+ throw new IllegalAccessException(clazzName);
+ } catch (InstantiationException iste) {
+ throw new InstantiationException(clazzName);
+ }
- }
+ }
- }
+ }
}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/test/MyFacesTagLibTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/test/MyFacesTagLibTestCase.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/test/MyFacesTagLibTestCase.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/test/java/org/apache/myfaces/test/MyFacesTagLibTestCase.java Thu Jul 3 14:58:05 2008
@@ -25,19 +25,19 @@
public class MyFacesTagLibTestCase extends AbstractTagLibTestCase {
- protected static final String META_INF = "META-INF/";
+ protected static final String META_INF = "META-INF/";
- public MyFacesTagLibTestCase(){
+ public MyFacesTagLibTestCase(){
- // TODO get the sandbox in here
+ // TODO get the sandbox in here
- tldPaths = new String[3];
- tldPaths[0] = META_INF + "myfaces_html.tld";
- tldPaths[1] = META_INF + "myfaces_core.tld";
- tldPaths[2] = META_INF + "tomahawk.tld";
- tldPaths[2] = META_INF + "myfaces_sandbox.tld";
- // tldPaths[3] = META_INF + "myfaces_sandbox.tld";
+ tldPaths = new String[3];
+ tldPaths[0] = META_INF + "myfaces_html.tld";
+ tldPaths[1] = META_INF + "myfaces_core.tld";
+ tldPaths[2] = META_INF + "tomahawk.tld";
+ tldPaths[2] = META_INF + "myfaces_sandbox.tld";
+ // tldPaths[3] = META_INF + "myfaces_sandbox.tld";
- }
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/ajaxchildcombobox/HtmlAjaxChildComboBoxRenderer.java Thu Jul 3 14:58:05 2008
@@ -54,121 +54,121 @@
*/
public class HtmlAjaxChildComboBoxRenderer extends HtmlMenuRenderer implements AjaxRenderer
{
- private static final String BEGIN_OPTION = "<option>";
- private static final String END_OPTION = "</option>";
- private static final String BEGIN_OPTION_TEXT = "<optionText>";
- private static final String END_OPTION_TEXT = "</optionText>";
- private static final String BEGIN_OPTION_VALUE = "<optionValue>";
- private static final String END_OPTION_VALUE = "</optionValue>";
-
- public static final int DEFAULT_MAX_SUGGESTED_ITEMS = 200;
-
- private static Log log = LogFactory.getLog(HtmlAjaxChildComboBoxRenderer.class);
-
- // Adds the javascript files needed by Dojo and the custom javascript for
- // this
- // component
- private void encodeJavascript(FacesContext context, UIComponent component)
- throws IOException
- {
- String javascriptLocation = (String) component.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
- DojoUtils.addMainInclude(context, component, javascriptLocation, new DojoConfig());
- DojoUtils.addRequire(context, component, "dojo.event.*");
- // not required - and results in an error
- // DojoUtils.addRequire(context, component, "dojo.io.bind");
-
- AddResource addResource = AddResourceFactory.getInstance(context);
-
- addResource.addJavaScriptAtPosition(context,
- AddResource.HEADER_BEGIN, AjaxChildComboBox.class, "javascript/ajaxChildComboBox.js");
- }
-
- public void encodeEnd(FacesContext context, UIComponent component) throws IOException
- {
- RendererUtils.checkParamValidity(context, component, AjaxChildComboBox.class);
-
- AjaxChildComboBox childComboBox = (AjaxChildComboBox) component;
-
- super.encodeEnd(context, component);
-
- String clientId = component.getClientId(context);
-
- UIComponent parentComboBox = this.getParentComboBox(childComboBox);
- if (parentComboBox == null)
- {
- log.error("Could not find parent combo box for AjaxChildComboBox " +
- childComboBox.getClientId(context));
- return;
- }
-
- encodeJavascript(context, component);
-
- ResponseWriter writer = context.getResponseWriter();
-
- // Begin: Write out the javascript that hooks up this component with the
- // parent combo-box
- writer.startElement(HTML.SCRIPT_ELEM, component);
- writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
-
- writer.write("var parentCombo = document.getElementById('" +
- parentComboBox.getClientId(context) + "');");
- HtmlRendererUtils.writePrettyLineSeparator(context);
- writer.write("dojo.event.connect(parentCombo, 'onchange', function(evt) { ");
- HtmlRendererUtils.writePrettyLineSeparator(context);
- writer.write("var targetElement = evt.target;");
- writer.write("var targetValue = targetElement.options[targetElement.selectedIndex].value;");
- HtmlRendererUtils.writePrettyLineSeparator(context);
- writer.write("reloadChildComboBox('" + clientId + "', targetValue);");
- HtmlRendererUtils.writePrettyLineSeparator(context);
- writer.write("});");
- writer.endElement(HTML.SCRIPT_ELEM);
- // End: Javascript
- }
-
-
- // creates the XML response that is sent back to the browser
- public void encodeAjax(FacesContext context, UIComponent uiComponent)
- throws IOException
- {
-
- String parentValue = (String) context.getExternalContext().
- getRequestParameterMap().get("parentValue");
-
- ServletResponse response = (ServletResponse) context.getExternalContext().getResponse();
- PrintWriter writer = response.getWriter();
-
- StringBuffer xml = new StringBuffer();
-
- MethodExpression mb = ((AjaxChildComboBox) uiComponent).getAjaxSelectItemsMethod();
- SelectItem[] options = (SelectItem[])
- mb.invoke(context.getELContext(), new Object[]{parentValue});
+ private static final String BEGIN_OPTION = "<option>";
+ private static final String END_OPTION = "</option>";
+ private static final String BEGIN_OPTION_TEXT = "<optionText>";
+ private static final String END_OPTION_TEXT = "</optionText>";
+ private static final String BEGIN_OPTION_VALUE = "<optionValue>";
+ private static final String END_OPTION_VALUE = "</optionValue>";
+
+ public static final int DEFAULT_MAX_SUGGESTED_ITEMS = 200;
+
+ private static Log log = LogFactory.getLog(HtmlAjaxChildComboBoxRenderer.class);
+
+ // Adds the javascript files needed by Dojo and the custom javascript for
+ // this
+ // component
+ private void encodeJavascript(FacesContext context, UIComponent component)
+ throws IOException
+ {
+ String javascriptLocation = (String) component.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
+ DojoUtils.addMainInclude(context, component, javascriptLocation, new DojoConfig());
+ DojoUtils.addRequire(context, component, "dojo.event.*");
+ // not required - and results in an error
+ // DojoUtils.addRequire(context, component, "dojo.io.bind");
+
+ AddResource addResource = AddResourceFactory.getInstance(context);
+
+ addResource.addJavaScriptAtPosition(context,
+ AddResource.HEADER_BEGIN, AjaxChildComboBox.class, "javascript/ajaxChildComboBox.js");
+ }
+
+ public void encodeEnd(FacesContext context, UIComponent component) throws IOException
+ {
+ RendererUtils.checkParamValidity(context, component, AjaxChildComboBox.class);
+
+ AjaxChildComboBox childComboBox = (AjaxChildComboBox) component;
+
+ super.encodeEnd(context, component);
+
+ String clientId = component.getClientId(context);
+
+ UIComponent parentComboBox = this.getParentComboBox(childComboBox);
+ if (parentComboBox == null)
+ {
+ log.error("Could not find parent combo box for AjaxChildComboBox " +
+ childComboBox.getClientId(context));
+ return;
+ }
+
+ encodeJavascript(context, component);
+
+ ResponseWriter writer = context.getResponseWriter();
+
+ // Begin: Write out the javascript that hooks up this component with the
+ // parent combo-box
+ writer.startElement(HTML.SCRIPT_ELEM, component);
+ writer.writeAttribute(HTML.SCRIPT_TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
+
+ writer.write("var parentCombo = document.getElementById('" +
+ parentComboBox.getClientId(context) + "');");
+ HtmlRendererUtils.writePrettyLineSeparator(context);
+ writer.write("dojo.event.connect(parentCombo, 'onchange', function(evt) { ");
+ HtmlRendererUtils.writePrettyLineSeparator(context);
+ writer.write("var targetElement = evt.target;");
+ writer.write("var targetValue = targetElement.options[targetElement.selectedIndex].value;");
+ HtmlRendererUtils.writePrettyLineSeparator(context);
+ writer.write("reloadChildComboBox('" + clientId + "', targetValue);");
+ HtmlRendererUtils.writePrettyLineSeparator(context);
+ writer.write("});");
+ writer.endElement(HTML.SCRIPT_ELEM);
+ // End: Javascript
+ }
+
+
+ // creates the XML response that is sent back to the browser
+ public void encodeAjax(FacesContext context, UIComponent uiComponent)
+ throws IOException
+ {
+
+ String parentValue = (String) context.getExternalContext().
+ getRequestParameterMap().get("parentValue");
+
+ ServletResponse response = (ServletResponse) context.getExternalContext().getResponse();
+ PrintWriter writer = response.getWriter();
+
+ StringBuffer xml = new StringBuffer();
+
+ MethodExpression mb = ((AjaxChildComboBox) uiComponent).getAjaxSelectItemsMethod();
+ SelectItem[] options = (SelectItem[])
+ mb.invoke(context.getELContext(), new Object[]{parentValue});
xml.append("<?xml version=\"1.0\"?>\n");
xml.append("<response>\n");
for (int i = 0; i < options.length; i++)
- {
- xml.append(BEGIN_OPTION);
- xml.append(BEGIN_OPTION_TEXT).append(options[i].getLabel()).append(END_OPTION_TEXT);
- xml.append(BEGIN_OPTION_VALUE).append(options[i].getValue()).append(END_OPTION_VALUE);
- xml.append(END_OPTION);
- }
+ {
+ xml.append(BEGIN_OPTION);
+ xml.append(BEGIN_OPTION_TEXT).append(options[i].getLabel()).append(END_OPTION_TEXT);
+ xml.append(BEGIN_OPTION_VALUE).append(options[i].getValue()).append(END_OPTION_VALUE);
+ xml.append(END_OPTION);
+ }
xml.append("</response>");
writer.write(xml.toString());
- }
+ }
- private UIComponent getParentComboBox(AjaxChildComboBox comboBox)
- {
- String parentId = comboBox.getParentComboBox();
-
- UIComponent parentComboBox = comboBox.findComponent(parentId);
- if (parentComboBox != null)
- {
- return parentComboBox;
- }
-
- // try searching from the very root of the component tree
- return comboBox.findComponent(UINamingContainer.SEPARATOR_CHAR + parentId);
- }
+ private UIComponent getParentComboBox(AjaxChildComboBox comboBox)
+ {
+ String parentId = comboBox.getParentComboBox();
+
+ UIComponent parentComboBox = comboBox.findComponent(parentId);
+ if (parentComboBox != null)
+ {
+ return parentComboBox;
+ }
+
+ // try searching from the very root of the component tree
+ return comboBox.findComponent(UINamingContainer.SEPARATOR_CHAR + parentId);
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/conversation/UIConversation.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/conversation/UIConversation.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/conversation/UIConversation.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/conversation/UIConversation.java Thu Jul 3 14:58:05 2008
@@ -36,42 +36,42 @@
*/
public class UIConversation extends AbstractConversationComponent
{
- private final static Log log = LogFactory.getLog(UIConversation.class);
+ private final static Log log = LogFactory.getLog(UIConversation.class);
- public static final String COMPONENT_TYPE = "org.apache.myfaces.Conversation";
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.Conversation";
- public void encodeBegin(FacesContext context) throws IOException
- {
- super.encodeBegin(context);
-
- UIComponent cmp = getParent();
- if (cmp instanceof UIStartConversation)
- {
- // start conversation should to the work
- return;
- }
-
- if (getName() == null)
- {
- throw new IllegalArgumentException("conversation name (attribute name=) required if used outside of startConversation tag");
- }
-
- elevateBean(context, getName(), getBeanBinding());
- }
-
- ValueBinding getBeanBinding()
- {
- return getValueBinding("value");
- }
-
- public static void elevateBean(FacesContext context, String conversationName, ValueBinding valueBinding)
- {
- Conversation conversation = ConversationManager.getInstance().getConversation(conversationName);
- if (conversation == null)
- {
- log.debug("no conversation named '" + conversationName + "' running - can't elevate bean '" + valueBinding.getExpressionString());
- return;
- }
- ConversationManager.getInstance().getConversationBeanElevator().elevateBean(context, conversation, valueBinding);
- }
+ public void encodeBegin(FacesContext context) throws IOException
+ {
+ super.encodeBegin(context);
+
+ UIComponent cmp = getParent();
+ if (cmp instanceof UIStartConversation)
+ {
+ // start conversation should to the work
+ return;
+ }
+
+ if (getName() == null)
+ {
+ throw new IllegalArgumentException("conversation name (attribute name=) required if used outside of startConversation tag");
+ }
+
+ elevateBean(context, getName(), getBeanBinding());
+ }
+
+ ValueBinding getBeanBinding()
+ {
+ return getValueBinding("value");
+ }
+
+ public static void elevateBean(FacesContext context, String conversationName, ValueBinding valueBinding)
+ {
+ Conversation conversation = ConversationManager.getInstance().getConversation(conversationName);
+ if (conversation == null)
+ {
+ log.debug("no conversation named '" + conversationName + "' running - can't elevate bean '" + valueBinding.getExpressionString());
+ return;
+ }
+ ConversationManager.getInstance().getConversationBeanElevator().elevateBean(context, conversation, valueBinding);
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/conversation/UIEndConversation.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/conversation/UIEndConversation.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/conversation/UIEndConversation.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/conversation/UIEndConversation.java Thu Jul 3 14:58:05 2008
@@ -35,187 +35,187 @@
*/
public class UIEndConversation extends AbstractConversationComponent
{
- public static final String COMPONENT_TYPE = "org.apache.myfaces.EndConversation";
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.EndConversation";
- private String onOutcome;
- private String errorOutcome;
- private Boolean restart;
- private MethodBinding restartAction;
-
- private boolean inited = false;
-
- /*
- public static class ConversationEndAction extends AbstractConversationActionListener
- {
- public void doConversationAction(AbstractConversationComponent abstractConversationComponent)
- {
- ConversationManager.getInstance().registerEndConversation(getConversationName());
- }
- }
- */
-
- public void encodeBegin(FacesContext context) throws IOException
- {
- super.encodeBegin(context);
-
- UICommand command = ConversationUtils.findParentCommand(this);
- if (command != null)
- {
- if (!inited)
- {
- /*
- ConversationEndAction actionListener = new ConversationEndAction();
- actionListener.setConversationName(getName());
- command.addActionListener(actionListener);
- */
- MethodBinding original = command.getAction();
- command.setAction(new EndConversationMethodBindingFacade(
- getName(),
- getOnOutcomes(),
- original,
- getErrorOutcome(),
- getRestart(),
- getRestartAction()));
- inited = true;
- }
- }
- else
- {
- ConversationUtils.endAndRestartConversation(context,
- getName(),
- getRestart(),
- getRestartAction());
- }
- }
-
- private Collection getOnOutcomes()
- {
- String onOutcome = getOnOutcome();
- if (onOutcome == null || onOutcome.trim().length() < 1)
- {
- return null;
- }
-
- return Arrays.asList(StringUtils.trim(StringUtils.splitShortString(onOutcome, ',')));
- }
-
- public void restoreState(FacesContext context, Object state)
- {
- Object[] states = (Object[]) state;
- super.restoreState(context, states[0]);
- inited = ((Boolean) states[1]).booleanValue();
- onOutcome = (String) states[2];
- errorOutcome = (String) states[3];
- restart = (Boolean) states[4];
- restartAction = (MethodBinding) restoreAttachedState(context, states[5]);
- }
-
- public Object saveState(FacesContext context)
- {
- return new Object[]
- {
- super.saveState(context),
- inited ? Boolean.TRUE : Boolean.FALSE,
- onOutcome,
- errorOutcome,
- restart,
- saveAttachedState(context, restartAction)
- };
- }
-
- /**
- * end the conversation only if the action outcome matches the given onOutcome.
- *
- * This can be a comma separated list.
- *
- * @JSFProperty
- * @return
- */
- public String getOnOutcome()
- {
- if (onOutcome != null)
- {
- return onOutcome;
- }
- ValueBinding vb = getValueBinding("onOutcome");
- if (vb == null)
- {
- return null;
- }
- return (String) vb.getValue(getFacesContext());
- }
-
- public void setOnOutcome(String onOutcome)
- {
- this.onOutcome = onOutcome;
- }
-
- /**
- * on exception use the given outcome for further navigation
- *
- * @JSFProperty
- * @return
- */
- public String getErrorOutcome()
- {
- if (errorOutcome != null)
- {
- return errorOutcome;
- }
- ValueBinding vb = getValueBinding("errorOutcome");
- if (vb == null)
- {
- return null;
- }
- return (String) vb.getValue(getFacesContext());
- }
-
- public void setErrorOutcome(String errorOutcome)
- {
- this.errorOutcome = errorOutcome;
- }
-
- /**
- * true|false|valueBinding - true if the conversation should be restarted immediately
- *
- * @JSFProperty
- * @return
- */
- public Boolean getRestart()
- {
- if (restart != null)
- {
- return restart;
- }
- ValueBinding vb = getValueBinding("restart");
- if (vb == null)
- {
- return null;
- }
- return (Boolean) vb.getValue(getFacesContext());
- }
-
- public void setRestart(Boolean restart)
- {
- this.restart = restart;
- }
-
- /**
- * the action which should be called in case of a restart
- *
- * @JSFProperty
- * methodSignature = "java.lang.String"
- * returnSignature = "void"
- * stateHolder = "true"
- * @return
- */
- public MethodBinding getRestartAction()
- {
- return restartAction;
- }
-
- public void setRestartAction(MethodBinding restartAction)
- {
- this.restartAction = restartAction;
- }
+ private String onOutcome;
+ private String errorOutcome;
+ private Boolean restart;
+ private MethodBinding restartAction;
+
+ private boolean inited = false;
+
+ /*
+ public static class ConversationEndAction extends AbstractConversationActionListener
+ {
+ public void doConversationAction(AbstractConversationComponent abstractConversationComponent)
+ {
+ ConversationManager.getInstance().registerEndConversation(getConversationName());
+ }
+ }
+ */
+
+ public void encodeBegin(FacesContext context) throws IOException
+ {
+ super.encodeBegin(context);
+
+ UICommand command = ConversationUtils.findParentCommand(this);
+ if (command != null)
+ {
+ if (!inited)
+ {
+ /*
+ ConversationEndAction actionListener = new ConversationEndAction();
+ actionListener.setConversationName(getName());
+ command.addActionListener(actionListener);
+ */
+ MethodBinding original = command.getAction();
+ command.setAction(new EndConversationMethodBindingFacade(
+ getName(),
+ getOnOutcomes(),
+ original,
+ getErrorOutcome(),
+ getRestart(),
+ getRestartAction()));
+ inited = true;
+ }
+ }
+ else
+ {
+ ConversationUtils.endAndRestartConversation(context,
+ getName(),
+ getRestart(),
+ getRestartAction());
+ }
+ }
+
+ private Collection getOnOutcomes()
+ {
+ String onOutcome = getOnOutcome();
+ if (onOutcome == null || onOutcome.trim().length() < 1)
+ {
+ return null;
+ }
+
+ return Arrays.asList(StringUtils.trim(StringUtils.splitShortString(onOutcome, ',')));
+ }
+
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object[] states = (Object[]) state;
+ super.restoreState(context, states[0]);
+ inited = ((Boolean) states[1]).booleanValue();
+ onOutcome = (String) states[2];
+ errorOutcome = (String) states[3];
+ restart = (Boolean) states[4];
+ restartAction = (MethodBinding) restoreAttachedState(context, states[5]);
+ }
+
+ public Object saveState(FacesContext context)
+ {
+ return new Object[]
+ {
+ super.saveState(context),
+ inited ? Boolean.TRUE : Boolean.FALSE,
+ onOutcome,
+ errorOutcome,
+ restart,
+ saveAttachedState(context, restartAction)
+ };
+ }
+
+ /**
+ * end the conversation only if the action outcome matches the given onOutcome.
+ *
+ * This can be a comma separated list.
+ *
+ * @JSFProperty
+ * @return
+ */
+ public String getOnOutcome()
+ {
+ if (onOutcome != null)
+ {
+ return onOutcome;
+ }
+ ValueBinding vb = getValueBinding("onOutcome");
+ if (vb == null)
+ {
+ return null;
+ }
+ return (String) vb.getValue(getFacesContext());
+ }
+
+ public void setOnOutcome(String onOutcome)
+ {
+ this.onOutcome = onOutcome;
+ }
+
+ /**
+ * on exception use the given outcome for further navigation
+ *
+ * @JSFProperty
+ * @return
+ */
+ public String getErrorOutcome()
+ {
+ if (errorOutcome != null)
+ {
+ return errorOutcome;
+ }
+ ValueBinding vb = getValueBinding("errorOutcome");
+ if (vb == null)
+ {
+ return null;
+ }
+ return (String) vb.getValue(getFacesContext());
+ }
+
+ public void setErrorOutcome(String errorOutcome)
+ {
+ this.errorOutcome = errorOutcome;
+ }
+
+ /**
+ * true|false|valueBinding - true if the conversation should be restarted immediately
+ *
+ * @JSFProperty
+ * @return
+ */
+ public Boolean getRestart()
+ {
+ if (restart != null)
+ {
+ return restart;
+ }
+ ValueBinding vb = getValueBinding("restart");
+ if (vb == null)
+ {
+ return null;
+ }
+ return (Boolean) vb.getValue(getFacesContext());
+ }
+
+ public void setRestart(Boolean restart)
+ {
+ this.restart = restart;
+ }
+
+ /**
+ * the action which should be called in case of a restart
+ *
+ * @JSFProperty
+ * methodSignature = "java.lang.String"
+ * returnSignature = "void"
+ * stateHolder = "true"
+ * @return
+ */
+ public MethodBinding getRestartAction()
+ {
+ return restartAction;
+ }
+
+ public void setRestartAction(MethodBinding restartAction)
+ {
+ this.restartAction = restartAction;
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/conversation/UIEnsureConversation.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/conversation/UIEnsureConversation.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/conversation/UIEnsureConversation.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/conversation/UIEnsureConversation.java Thu Jul 3 14:58:05 2008
@@ -42,130 +42,130 @@
*/
public class UIEnsureConversation extends AbstractConversationComponent
{
- public static final String COMPONENT_TYPE = "org.apache.myfaces.EnsureConversation";
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.EnsureConversation";
- private String redirectTo;
- private Boolean preCheck;
+ private String redirectTo;
+ private Boolean preCheck;
- public void encodeBegin(FacesContext context) throws IOException
- {
- super.encodeBegin(context);
-
- checkConversation(context, getName());
- }
-
- public void decode(FacesContext context)
- {
- super.decode(context);
-
- try
- {
- checkConversation(context, getName());
- }
- catch (IOException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public void restoreState(FacesContext context, Object state)
- {
- Object[] states = (Object[]) state;
-
- super.restoreState(context, states[0]);
- redirectTo = (String) states[1];
- preCheck = (Boolean) states[2];
- }
-
- public Object saveState(FacesContext context)
- {
- return new Object[]
- {
- super.saveState(context),
- redirectTo,
- preCheck
- };
- }
-
- protected void checkConversation(FacesContext context, String name) throws IOException
- {
- ConversationManager conversationManager = ConversationManager.getInstance();
-
- if (Boolean.TRUE.equals(preCheck))
- {
- String actionResult = (String) getAction().invoke(context, null);
- if (actionResult == null)
- {
- // no further action, maybe the user started a conversation
- return;
- }
-
- conversationManager.getMessager().setConversationNotActive(context, getName());
- return;
- }
- else if (!conversationManager.hasConversation(name))
- {
- if (getAction() != null)
- {
- String actionResult = (String) getAction().invoke(context, null);
- if (actionResult == null)
- {
- // no further action, maybe the user started a conversation
- return;
- }
- conversationManager.getMessager().setConversationNotActive(context, getName());
-
- // hopefully the user configured the navigation as redirect ...
- context.getApplication().getNavigationHandler().handleNavigation(context, null, actionResult);
- }
- else
- {
- conversationManager.getMessager().setConversationNotActive(context, getName());
-
- String actionUrl = context.getApplication().getViewHandler().getActionURL(
- context, getRedirectTo());
- String encodedActionUrl = context.getExternalContext().encodeActionURL(actionUrl);
-
- // XXX: figure out a way to avoid this ==>
- RedirectTrackerManager manager = RedirectTrackerManager.getInstance(context);
- if (manager != null)
- {
- encodedActionUrl = manager.trackRedirect(context, encodedActionUrl);
- }
- // XXX: figure out a way to avoid this <==
-
- context.getExternalContext().redirect(encodedActionUrl);
- }
-
- return;
- }
- }
-
- /**
- * redirect to the given view if the conversation is not running
- *
- * @JSFProperty
- * @return
- */
- public String getRedirectTo()
- {
- if (redirectTo != null)
- {
- return redirectTo;
- }
- ValueBinding vb = getValueBinding("redirectTo");
- if (vb == null)
- {
- return null;
- }
- return (String) vb.getValue(getFacesContext());
- }
-
- public void setRedirectTo(String redirectTo)
- {
- this.redirectTo = redirectTo;
- }
-
+ public void encodeBegin(FacesContext context) throws IOException
+ {
+ super.encodeBegin(context);
+
+ checkConversation(context, getName());
+ }
+
+ public void decode(FacesContext context)
+ {
+ super.decode(context);
+
+ try
+ {
+ checkConversation(context, getName());
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object[] states = (Object[]) state;
+
+ super.restoreState(context, states[0]);
+ redirectTo = (String) states[1];
+ preCheck = (Boolean) states[2];
+ }
+
+ public Object saveState(FacesContext context)
+ {
+ return new Object[]
+ {
+ super.saveState(context),
+ redirectTo,
+ preCheck
+ };
+ }
+
+ protected void checkConversation(FacesContext context, String name) throws IOException
+ {
+ ConversationManager conversationManager = ConversationManager.getInstance();
+
+ if (Boolean.TRUE.equals(preCheck))
+ {
+ String actionResult = (String) getAction().invoke(context, null);
+ if (actionResult == null)
+ {
+ // no further action, maybe the user started a conversation
+ return;
+ }
+
+ conversationManager.getMessager().setConversationNotActive(context, getName());
+ return;
+ }
+ else if (!conversationManager.hasConversation(name))
+ {
+ if (getAction() != null)
+ {
+ String actionResult = (String) getAction().invoke(context, null);
+ if (actionResult == null)
+ {
+ // no further action, maybe the user started a conversation
+ return;
+ }
+ conversationManager.getMessager().setConversationNotActive(context, getName());
+
+ // hopefully the user configured the navigation as redirect ...
+ context.getApplication().getNavigationHandler().handleNavigation(context, null, actionResult);
+ }
+ else
+ {
+ conversationManager.getMessager().setConversationNotActive(context, getName());
+
+ String actionUrl = context.getApplication().getViewHandler().getActionURL(
+ context, getRedirectTo());
+ String encodedActionUrl = context.getExternalContext().encodeActionURL(actionUrl);
+
+ // XXX: figure out a way to avoid this ==>
+ RedirectTrackerManager manager = RedirectTrackerManager.getInstance(context);
+ if (manager != null)
+ {
+ encodedActionUrl = manager.trackRedirect(context, encodedActionUrl);
+ }
+ // XXX: figure out a way to avoid this <==
+
+ context.getExternalContext().redirect(encodedActionUrl);
+ }
+
+ return;
+ }
+ }
+
+ /**
+ * redirect to the given view if the conversation is not running
+ *
+ * @JSFProperty
+ * @return
+ */
+ public String getRedirectTo()
+ {
+ if (redirectTo != null)
+ {
+ return redirectTo;
+ }
+ ValueBinding vb = getValueBinding("redirectTo");
+ if (vb == null)
+ {
+ return null;
+ }
+ return (String) vb.getValue(getFacesContext());
+ }
+
+ public void setRedirectTo(String redirectTo)
+ {
+ this.redirectTo = redirectTo;
+ }
+
/**
* Delegate the check to the action method at all. The user has to check if
* a conversation is running. A action method is mandatory.
Modified: myfaces/tomahawk/trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/conversation/UISeparateConversationContext.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/conversation/UISeparateConversationContext.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/conversation/UISeparateConversationContext.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core12/src/main/java/org/apache/myfaces/custom/conversation/UISeparateConversationContext.java Thu Jul 3 14:58:05 2008
@@ -37,47 +37,47 @@
*/
public class UISeparateConversationContext extends UIComponentBase
{
- public static final String COMPONENT_FAMILY = "javax.faces.Component";
+ public static final String COMPONENT_FAMILY = "javax.faces.Component";
public static final String COMPONENT_TYPE = "org.apache.myfaces.SeparateConversationContext";
private final static ThreadLocal inSeperationMode = new ThreadLocal();
- public static void setInSeparationMode(boolean seperationMode)
- {
- inSeperationMode.set(seperationMode?Boolean.TRUE:Boolean.FALSE);
- }
+ public static void setInSeparationMode(boolean seperationMode)
+ {
+ inSeperationMode.set(seperationMode?Boolean.TRUE:Boolean.FALSE);
+ }
- public static boolean isInSeparationMode()
- {
- return Boolean.TRUE.equals(inSeperationMode.get());
- }
-
+ public static boolean isInSeparationMode()
+ {
+ return Boolean.TRUE.equals(inSeperationMode.get());
+ }
+
public void encodeBegin(FacesContext context) throws IOException
- {
- super.encodeBegin(context);
+ {
+ super.encodeBegin(context);
- setInSeparationMode(true);
- }
+ setInSeparationMode(true);
+ }
- public void encodeChildren(FacesContext context) throws IOException
- {
- try
- {
- RendererUtils.renderChildren(context, this);
- }
- finally
- {
- setInSeparationMode(false);
- }
- }
+ public void encodeChildren(FacesContext context) throws IOException
+ {
+ try
+ {
+ RendererUtils.renderChildren(context, this);
+ }
+ finally
+ {
+ setInSeparationMode(false);
+ }
+ }
public boolean getRendersChildren()
{
- return true;
+ return true;
}
- public String getFamily()
- {
- return COMPONENT_FAMILY;
- }
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
}
\ No newline at end of file