bruno 2003/09/03 01:21:52
Modified: src/blocks/woody/conf woody-form.xconf
src/blocks/woody/java/org/apache/cocoon/woody/event
ActionEvent.java
src/blocks/woody/java/org/apache/cocoon/woody/formmodel
ButtonDefinitionBuilder.java
src/blocks/woody/samples/forms carselector_form.xml
form1.xml form2_model.xml
src/blocks/woody/samples/xsl/html woody-default.xsl
Added: src/blocks/woody/java/org/apache/cocoon/woody/formmodel
Action.java ActionDefinition.java
ActionDefinitionBuilder.java
Removed: src/blocks/woody/java/org/apache/cocoon/woody/formmodel
Button.java ButtonDefinition.java
Log:
Renamed the button widget to action widget.
Revision Changes Path
1.3 +1 -0 cocoon-2.1/src/blocks/woody/conf/woody-form.xconf
Index: woody-form.xconf
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/conf/woody-form.xconf,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- woody-form.xconf 12 Aug 2003 12:58:38 -0000 1.2
+++ woody-form.xconf 3 Sep 2003 08:21:51 -0000 1.3
@@ -11,6 +11,7 @@
<widget name="repeater"
src="org.apache.cocoon.woody.formmodel.RepeaterDefinitionBuilder"/>
<widget name="booleanfield"
src="org.apache.cocoon.woody.formmodel.BooleanFieldDefinitionBuilder"/>
<widget name="multivaluefield"
src="org.apache.cocoon.woody.formmodel.MultiValueFieldDefinitionBuilder"/>
+ <widget name="action"
src="org.apache.cocoon.woody.formmodel.ActionDefinitionBuilder"/>
<widget name="button"
src="org.apache.cocoon.woody.formmodel.ButtonDefinitionBuilder"/>
<widget name="aggregatefield"
src="org.apache.cocoon.woody.formmodel.AggregateFieldDefinitionBuilder"/>
<widget name="output"
src="org.apache.cocoon.woody.formmodel.OutputDefinitionBuilder"/>
1.2 +1 -1
cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/event/ActionEvent.java
Index: ActionEvent.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/event/ActionEvent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ActionEvent.java 14 May 2003 11:35:38 -0000 1.1
+++ ActionEvent.java 3 Sep 2003 08:21:51 -0000 1.2
@@ -53,7 +53,7 @@
import org.apache.cocoon.woody.formmodel.Widget;
/**
- * Currently this event originates from a [EMAIL PROTECTED]
org.apache.cocoon.woody.formmodel.Button Button}
+ * Currently this event originates from a [EMAIL PROTECTED]
org.apache.cocoon.woody.formmodel.Action Button}
* widget.
*/
public interface ActionEvent {
1.2 +4 -60
cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/ButtonDefinitionBuilder.java
Index: ButtonDefinitionBuilder.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/ButtonDefinitionBuilder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ButtonDefinitionBuilder.java 14 May 2003 11:35:38 -0000 1.1
+++ ButtonDefinitionBuilder.java 3 Sep 2003 08:21:51 -0000 1.2
@@ -1,70 +1,14 @@
-/*
-
- ============================================================================
- The Apache Software License, Version 1.1
- ============================================================================
-
- Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modifica-
- tion, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- 3. The end-user documentation included with the redistribution, if any, must
- include the following acknowledgment: "This product includes software
- developed by the Apache Software Foundation (http://www.apache.org/)."
- Alternately, this acknowledgment may appear in the software itself, if
- and wherever such third-party acknowledgments normally appear.
-
- 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
- used to endorse or promote products derived from this software without
- prior written permission. For written permission, please contact
- [EMAIL PROTECTED]
-
- 5. Products derived from this software may not be called "Apache", nor may
- "Apache" appear in their name, without prior written permission of the
- Apache Software Foundation.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many individuals
- on behalf of the Apache Software Foundation and was originally created by
- Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
- Software Foundation, please see <http://www.apache.org/>.
-
-*/
package org.apache.cocoon.woody.formmodel;
import org.w3c.dom.Element;
import org.apache.cocoon.woody.util.DomHelper;
/**
- * Builds {ButtonDefinition}s.
+ * The ButtonDefinitionBuilder has been replaced by [EMAIL PROTECTED]
ActionDefinitionBuilder}. This implementation
+ * is only left here to give a warning to users.
*/
-public class ButtonDefinitionBuilder extends AbstractWidgetDefinitionBuilder
{
+public class ButtonDefinitionBuilder implements WidgetDefinitionBuilder {
public WidgetDefinition buildWidgetDefinition(Element widgetElement)
throws Exception {
- ButtonDefinition buttonDefinition = new ButtonDefinition();
- setId(widgetElement, buttonDefinition);
- setLabel(widgetElement, buttonDefinition);
-
- String actionCommand = DomHelper.getAttribute(widgetElement,
"action-command");
- buttonDefinition.setActionCommand(actionCommand);
-
- return buttonDefinition;
+ throw new Exception("The button widget has been renamed to action.
Please update your form definition files. Found at " +
DomHelper.getLocation(widgetElement));
}
}
1.1
cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/Action.java
Index: Action.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.woody.formmodel;
import org.apache.cocoon.woody.FormContext;
import org.apache.cocoon.woody.Constants;
import org.apache.cocoon.woody.event.ActionEvent;
import org.apache.cocoon.xml.AttributesImpl;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import java.util.Locale;
/**
* An Action widget. An Action widget can cause an [EMAIL PROTECTED]
ActionEvent} to be triggered
* on the server side, which will be handled by the [EMAIL PROTECTED]
org.apache.cocoon.woody.FormHandler FormHandler}
* (in case of flowscript this is a javascript function). An Action widget
can e.g. be rendered as a button,
* or as a hidden field which gets its value set by javascript. The Action
widget will generate its associated
* ActionEvent when a requestparameter is present with as name the id of this
Action widget, and as
* value a non-empty value.
*/
public class Action extends AbstractWidget {
private ActionDefinition definition;
public Action(ActionDefinition definition) {
this.definition = definition;
}
public String getId() {
return definition.getId();
}
public void readFromRequest(FormContext formContext) {
String value =
formContext.getRequest().getParameter(getFullyQualifiedId());
if (value != null && value.length() > 0) {
formContext.setActionEvent(new ActionEvent() {
public String getActionCommand() {
return definition.getActionCommand();
}
public Widget getSource() {
return Action.this;
}
});
}
}
public boolean validate(FormContext formContext) {
return true;
}
private static final String ACTION_EL = "action";
private static final String LABEL_EL = "label";
public void generateSaxFragment(ContentHandler contentHandler, Locale
locale) throws SAXException {
AttributesImpl buttonAttrs = new AttributesImpl();
buttonAttrs.addCDATAAttribute("id", getFullyQualifiedId());
contentHandler.startElement(Constants.WI_NS, ACTION_EL,
Constants.WI_PREFIX_COLON + ACTION_EL, buttonAttrs);
contentHandler.startElement(Constants.WI_NS, LABEL_EL,
Constants.WI_PREFIX_COLON + LABEL_EL, Constants.EMPTY_ATTRS);
generateLabel(contentHandler);
contentHandler.endElement(Constants.WI_NS, LABEL_EL,
Constants.WI_PREFIX_COLON + LABEL_EL);
contentHandler.endElement(Constants.WI_NS, ACTION_EL,
Constants.WI_PREFIX_COLON + ACTION_EL);
}
public void generateLabel(ContentHandler contentHandler) throws
SAXException {
definition.generateLabel(contentHandler);
}
}
1.1
cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/ActionDefinition.java
Index: ActionDefinition.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.woody.formmodel;
/**
* The [EMAIL PROTECTED] WidgetDefinition} part of a Action widget, see
[EMAIL PROTECTED] Action} for more information.
*/
public class ActionDefinition extends AbstractWidgetDefinition {
private String actionCommand;
public void setActionCommand(String actionCommand) {
this.actionCommand = actionCommand;
}
public String getActionCommand() {
return actionCommand;
}
public Widget createInstance() {
return new Action(this);
}
}
1.1
cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/ActionDefinitionBuilder.java
Index: ActionDefinitionBuilder.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.woody.formmodel;
import org.w3c.dom.Element;
import org.apache.cocoon.woody.util.DomHelper;
/**
* Builds [EMAIL PROTECTED] ActionDefinition}s.
*/
public class ActionDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
public WidgetDefinition buildWidgetDefinition(Element widgetElement)
throws Exception {
ActionDefinition actionDefinition = new ActionDefinition();
setId(widgetElement, actionDefinition);
setLabel(widgetElement, actionDefinition);
String actionCommand = DomHelper.getAttribute(widgetElement,
"action-command");
actionDefinition.setActionCommand(actionCommand);
return actionDefinition;
}
}
1.2 +2 -2
cocoon-2.1/src/blocks/woody/samples/forms/carselector_form.xml
Index: carselector_form.xml
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/woody/samples/forms/carselector_form.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- carselector_form.xml 28 Jul 2003 16:00:28 -0000 1.1
+++ carselector_form.xml 3 Sep 2003 08:21:52 -0000 1.2
@@ -20,8 +20,8 @@
</wd:selection-list>
</wd:field>
- <wd:button id="updatemodels" action-command="updatemodels">
+ <wd:action id="updatemodels" action-command="updatemodels">
<wd:label>Update models</wd:label>
- </wd:button>
+ </wd:action>
</wd:form>
1.10 +4 -4 cocoon-2.1/src/blocks/woody/samples/forms/form1.xml
Index: form1.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/samples/forms/form1.xml,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- form1.xml 28 Jul 2003 15:58:16 -0000 1.9
+++ form1.xml 3 Sep 2003 08:21:52 -0000 1.10
@@ -204,12 +204,12 @@
</wd:booleanfield>
</wd:repeater>
- <wd:button id="addcontact" action-command="add-contact">
+ <wd:action id="addcontact" action-command="add-contact">
<wd:label>Add contact</wd:label>
- </wd:button>
+ </wd:action>
- <wd:button id="removecontacts" action-command="remove-selected-contacts">
+ <wd:action id="removecontacts" action-command="remove-selected-contacts">
<wd:label>Remove selected contacts</wd:label>
- </wd:button>
+ </wd:action>
</wd:form>
1.6 +4 -4 cocoon-2.1/src/blocks/woody/samples/forms/form2_model.xml
Index: form2_model.xml
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/woody/samples/forms/form2_model.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- form2_model.xml 12 Aug 2003 12:59:10 -0000 1.5
+++ form2_model.xml 3 Sep 2003 08:21:52 -0000 1.6
@@ -107,12 +107,12 @@
</wd:booleanfield>
</wd:repeater>
- <wd:button id="addcontact" action-command="add-contact">
+ <wd:action id="addcontact" action-command="add-contact">
<wd:label>Add contact</wd:label>
- </wd:button>
+ </wd:action>
- <wd:button id="removecontacts" action-command="remove-selected-contacts">
+ <wd:action id="removecontacts" action-command="remove-selected-contacts">
<wd:label>Remove selected contacts</wd:label>
- </wd:button>
+ </wd:action>
</wd:form>
1.11 +1 -1
cocoon-2.1/src/blocks/woody/samples/xsl/html/woody-default.xsl
Index: woody-default.xsl
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/woody/samples/xsl/html/woody-default.xsl,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- woody-default.xsl 18 Aug 2003 19:58:51 -0000 1.10
+++ woody-default.xsl 3 Sep 2003 08:21:52 -0000 1.11
@@ -100,7 +100,7 @@
</input>
</xsl:template>
- <xsl:template match="wi:button">
+ <xsl:template match="wi:action">
<input type="submit" name="[EMAIL PROTECTED]">
<xsl:attribute name="value"><xsl:value-of
select="wi:label/node()"/></xsl:attribute>
</input>