You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by do...@apache.org on 2005/02/12 15:52:12 UTC
svn commit: r153510 [1/3] - in incubator/beehive/trunk/netui:
src/tags-html/org/apache/beehive/netui/tags/html/
test/webapps/drt/coreWeb/bugs/j176/
test/webapps/drt/coreWeb/coretags/form/cases/
test/webapps/drt/testRecorder/config/ test/webapps/drt/testRecorder/tests/
Author: dolander
Date: Sat Feb 12 06:52:08 2005
New Revision: 153510
URL: http://svn.apache.org/viewcvs?view=rev&rev=153510
Log:
Add BVT for the recent Form changes
Final bit of cleanup in the Form
Added:
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/CtFormCases.xml
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/J176.xml
Modified:
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/bugs/j176/Controller.jpf
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/bugs/j176/index.jsp
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/form/cases/Controller.jpf
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/form/cases/html.jsp
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/form/cases/index.jsp
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java?view=diff&r1=153509&r2=153510
==============================================================================
--- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java (original)
+++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java Sat Feb 12 06:52:08 2005
@@ -214,22 +214,22 @@
// @todo: did we support location in 8.1? How?
private String _location = null; // The location hash to append to the url.
private String _text = null; // The body content of this tag (if any).
- private String _beanName = null; // The name of the form bean to (create and) use.
- private boolean _explicitBeanType = false;
+ private String _beanName = null; // The name of the form bean to (create and) use.
+ private boolean _explicitBeanType = false; // Flag indicating that the BeanType was set by setting the attribute
private String _beanType = null; // The type of the form bean to (create and) use.
private String _beanScope = null; // The scope of the form bean to (create and) use.
- private String _realName = null;
- //private String _id = null;
- //private String _formId = null;
+
+ private String _realName = null; // This is the real name of the form if it is to be output
+ private boolean _setRealName = false; // Force the RealName to be output. Contained tags can cause this
+
private String _targetScope; // target page flow scope; see comments on setTargetScope()
private ActionMapping _mapping = null; // The ActionMapping defining where we will be submitting this form
private ActionServlet _servlet = null; // The ActionServlet instance we are associated with
- private HashMap _focusMap;
+ private HashMap _focusMap; // Map allowing setting focus on one of the controls
private ModuleConfig _appConfig = null; // The application configuration for our module.
private FlowController _flowController = null; // The flow controller (page flow or shared flow).
- private boolean _setRealName = false;
private boolean _formSubmit = false;
private Map _params;
@@ -557,7 +557,6 @@
return SKIP_BODY;
// Error out if there is a parent form
- // @todo: should this just be a design time test?
if (getNearestForm() != null) {
registerTagError(Bundle.getString("Tags_FormParentForm"), null);
}
@@ -571,16 +570,8 @@
if (hasErrors())
return SKIP_BODY;
- // Create an appropriate "form" element based on our parameters
- // Generate the form id and save it in addition save any value
- // that was set for tagId.
- //if (_state.id != null)
- // _state.id = getIdForTagId(_state.id);
-
- // we need to create a real name for the form, it will either be the tagId
- // or the generated form id.
-
- //_id = _state.id;
+ // Generate the real name. We generate it here so we can return it to any contained tags if
+ // they need it. If they access it, the most likely will cause the realName to be output
if (_state.id != null) {
_realName = getIdForTagId(_state.id);
}
@@ -598,6 +589,7 @@
scope = PageContext.REQUEST_SCOPE;
}
+ // setup the Bean
Object bean = null;
if (_beanName != null)
bean = pageContext.getAttribute(_beanName, scope);
@@ -632,13 +624,11 @@
if (hasErrors())
return SKIP_BODY;
+ // Call the reset method if we have an ActionForm
if (bean instanceof ActionForm) {
((ActionForm) bean).reset(_mapping, request);
}
- if (bean == null) {
- //Ignore - this is okay if databinding happens in the pageFlow
- }
- else {
+ if (bean != null) {
pageContext.setAttribute(_beanName, bean, scope);
}
}
@@ -649,7 +639,6 @@
// Continue processing this page
return EVAL_BODY_BUFFERED;
-
}
/**
@@ -682,21 +671,14 @@
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
ServletContext servletContext = pageContext.getServletContext();
+ // if we have an Id or a tag is forcing the name, then set the state and generate
+ // the JavaScript
if (_state.id != null || _setRealName) {
String id = _state.id;
_state.name = _realName;
_state.id = _realName;
idScript = renderNameAndId(request,id);
}
- //if (_beanName == null) {
- // _setRealName = true;
- //}
-
- // if tagId is set we need to add a mapping to the 'id'
-
- // create real form name attribute
- //if (_state.id == null && _setRealName)
- // _state.id = _realName;
if (_state.method == null)
_state.method = FORM_POST;
@@ -788,7 +770,6 @@
String focusName = (String) _focusMap.get(_focus);
if (focusName != null) {
- //String formName = (_beanName != null) ? _beanName : _formId;
String formName = _realName;
ScriptRequestState srs = ScriptRequestState.getScriptRequestState(request);
srs.writeFeature(getScriptReporter(), writer, CoreScriptFeature.SET_FOCUS, false, true,
@@ -809,6 +790,13 @@
return EVAL_PAGE;
}
+ /**
+ * This mehtod will render the JavaScript associated with the id lookup if id has
+ * been set.
+ * @param request
+ * @param id
+ * @return
+ */
private String renderNameAndId(HttpServletRequest request,String id)
{
// if id is not set then we need to exit
@@ -928,22 +916,23 @@
_focus = null;
_location = null;
- _targetScope = null;
_text = null;
- _mapping = null;
+
_beanName = null;
- _beanType = null;
_explicitBeanType = false;
+ _beanType = null;
_beanScope = null;
+
_realName = null;
- //_id = null;
- //_formId = null;
+ _setRealName = false;
+
+ _targetScope = null;
+
_mapping = null;
_servlet = null;
_focusMap = null;
_appConfig = null;
_flowController = null;
- _setRealName = false;
_formSubmit = false;
_params = null;
}
Modified: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/bugs/j176/Controller.jpf
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/bugs/j176/Controller.jpf?view=diff&r1=153509&r2=153510
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/bugs/j176/Controller.jpf (original)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/bugs/j176/Controller.jpf Sat Feb 12 06:52:08 2005
@@ -14,6 +14,9 @@
public class Controller extends PageFlowController
{
private String _action;
+ public String getAction() {
+ return _action;
+ }
@Jpf.Action(
forwards={
Modified: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/bugs/j176/index.jsp
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/bugs/j176/index.jsp?view=diff&r1=153509&r2=153510
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/bugs/j176/index.jsp (original)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/bugs/j176/index.jsp Sat Feb 12 06:52:08 2005
@@ -6,10 +6,11 @@
<netui:base/>
</head>
<netui:body>
- <netui:span value="${pageFlow.action}" />
- <netui:scriptContainer generateIdScope="true">
- <netui:form tagId="foo" action="post"></netui:form>
- </netui:scriptContainer>
- <netui:form action="post"></netui:form>
+ <p style="color:green">verify two forms on a page going to
+ the same action produce legal XHTML.
+ </p>
+ <netui:span value="${pageFlow.action}" />
+ <netui:form action="post"></netui:form>
+ <netui:form action="post"></netui:form>
</netui:body>
</netui:html>
Modified: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/form/cases/Controller.jpf
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/form/cases/Controller.jpf?view=diff&r1=153509&r2=153510
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/form/cases/Controller.jpf (original)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/form/cases/Controller.jpf Sat Feb 12 06:52:08 2005
@@ -19,6 +19,8 @@
private String _action;
private String _text;
private String _textPage;
+ public BeanThree useBean;
+ private Bean _direct;
public String getAction()
{
@@ -63,12 +65,12 @@
@Jpf.Action(
forwards = { @Jpf.Forward(name = "index", navigateTo = Jpf.NavigateTo.currentPage)})
- protected Forward post(Bean form)
+ protected Forward post(Bean postForm)
{
dumpRequest();
_action = "post";
- _text = form.getText();
- form.setText("");
+ _text = postForm.getText();
+ postForm.setText("");
return new Forward("index");
}
@@ -83,23 +85,45 @@
@Jpf.Action(
forwards = { @Jpf.Forward(name = "index", navigateTo = Jpf.NavigateTo.currentPage)})
- protected Forward postOverride(Bean form)
+ protected Forward postOverride(Bean postOverForm)
{
dumpRequest();
_action = "postOverride";
- _text = form.getText();
- form.setText("");
+ _text = postOverForm.getText();
+ postOverForm.setText("");
return new Forward("index");
}
@Jpf.Action(
forwards = { @Jpf.Forward(name = "index", navigateTo = Jpf.NavigateTo.currentPage)})
- protected Forward postOverrideNewForm(BeanTwo form)
+ protected Forward postOverrideNewForm(BeanTwo overNewForm)
{
dumpRequest();
_action = "postOverrideNewForm";
- _text = form.getText();
- form.setText("");
+ _text = overNewForm.getText();
+ overNewForm.setText("");
+ return new Forward("index");
+ }
+
+ @Jpf.Action(
+ useFormBean="useBean",
+ forwards = { @Jpf.Forward(name = "index", navigateTo = Jpf.NavigateTo.currentPage)})
+ protected Forward postUseFormBean(BeanThree useForm)
+ {
+ dumpRequest();
+ _action = "useFormBean";
+ _text = useForm.getText();
+ return new Forward("index");
+ }
+
+ @Jpf.Action(
+ forwards = { @Jpf.Forward(name = "index", navigateTo = Jpf.NavigateTo.currentPage)})
+ protected Forward postDirect(Bean directForm)
+ {
+ dumpRequest();
+ _action = "direct";
+ _text = directForm.getText();
+ directForm.setText("");
return new Forward("index");
}
@@ -108,9 +132,19 @@
*/
protected void onCreate()
{
+ useBean = new BeanThree();
+ useBean.setText("Bean Defined");
+
+ _direct = new Bean();
+ _direct.setText("Direct Defined");
+ getRequest().getSession().setAttribute("FormCases",_direct);
}
private void dumpRequest() {
+ // this is just for test purposes...so exit now
+ if (true)
+ return;
+
System.err.println("**************************DUMP**************************");
ServletRequest req = getRequest();
Enumeration e = req.getParameterNames();
@@ -129,6 +163,7 @@
*/
protected void onDestroy(HttpSession session)
{
+ session.removeAttribute("FormCases");
}
public static class Bean extends FormData
@@ -147,6 +182,21 @@
}
public static class BeanTwo extends FormData
+ {
+ private String _text;
+
+ public String getText()
+ {
+ return _text;
+ }
+
+ public void setText(String value)
+ {
+ _text = value;
+ }
+ }
+
+ public static class BeanThree extends FormData
{
private String _text;
Modified: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/form/cases/html.jsp
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/form/cases/html.jsp?view=diff&r1=153509&r2=153510
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/form/cases/html.jsp (original)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/form/cases/html.jsp Sat Feb 12 06:52:08 2005
@@ -1,47 +1,64 @@
<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="netui" uri="http://beehive.apache.org/netui/tags-html-1.0"%>
-<netui:html>
+<netui:html idScope="html">
<head>
<netui:base/>
</head>
<netui:body>
+ <netui:anchor action="begin">xhtml</netui:anchor><br>
Action: <netui:span value="${pageFlow.action}" /><br>
Text: <netui:span value="${pageFlow.text}" />
+ <p style="color:green">This is an HTML generated document that contains
+ six different types of form submits. Each type differs in either how
+ the form is submitted, or how the form binds to the bean.
+ </p>
<table width="100%">
<tr><td width="50%">
<h4>Case One -- Form Submit to an Action</h4>
- <netui:scriptContainer generateIdScope="true">
- <netui:form action="post">
+ <p style="color:green">Normal button submit, and bean on action</p>
+ <netui:form tagId="f1" action="post">
Text: <netui:textBox dataSource="actionForm.text" />
<netui:button value="submit"/>
</netui:form>
- </netui:scriptContainer>
</td><td width="50%">
<h4>Case Two -- Form Submit To PageFlow</h4>
- <netui:scriptContainer generateIdScope="true">
- <netui:form action="postNoForm">
+ <p style="color:green">Normal button submit, binding to page flow</p>
+ <netui:form tagId="f2" action="postNoForm">
Text: <netui:textBox dataSource="pageFlow.textPage" />
<netui:button value="submit"/>
</netui:form>
- </netui:scriptContainer>
</td></tr>
<tr><td width="50%">
<h4>Case Three -- Form Submit Override Action</h4>
- <netui:scriptContainer generateIdScope="true">
- <netui:form action="post">
+ <p style="color:green">Override the action submitted on the button</p>
+ <netui:form tagId="f3" action="post">
Text: <netui:textBox dataSource="actionForm.text" />
<netui:button action="postOverride" value="submit"/>
</netui:form>
- </netui:scriptContainer>
</td><td width="50%">
<h4>Case Four -- Form Submit Override Action/Different Bean</h4>
- <netui:scriptContainer generateIdScope="true">
- <netui:form action="post">
+ <p style="color:green">Override the action and go to a different bean type</p>
+ <netui:form tagId="f4" action="post">
Text: <netui:textBox dataSource="actionForm.text" />
<netui:button action="postOverrideNewForm" value="submit"/>
</netui:form>
- </netui:scriptContainer>
+ </td></tr>
+ <tr><td width="50%">
+ <h4>Case Five -- Form Submit/Action UseBean</h4>
+ <p style="color:green">Normal Submit, the action has a useFormBean binding to a bean</p>
+ <netui:form tagId="f5" action="postUseFormBean">
+ Text: <netui:textBox dataSource="actionForm.text" />
+ <netui:button value="submit"/>
+ </netui:form>
+ </td><td width="50%">
+ <h4>Case Six -- Form Submit Direct Bean Binding</h4>
+ <p style="color:green">Normal Submit, the form tag specifies a bean in the Session</p>
+ <netui:form tagId="f6" action="postDirect" beanName="FormCases"
+ beanType="coretags.form.cases.Controller$Bean" beanScope="session">
+ Text: <netui:textBox dataSource="actionForm.text" />
+ <netui:button value="submit"/>
+ </netui:form>
</td></tr>
</table>
</netui:body>
Modified: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/form/cases/index.jsp
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/form/cases/index.jsp?view=diff&r1=153509&r2=153510
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/form/cases/index.jsp (original)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/coretags/form/cases/index.jsp Sat Feb 12 06:52:08 2005
@@ -1,7 +1,7 @@
<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="netui" uri="http://beehive.apache.org/netui/tags-html-1.0"%>
-<netui:html documentType="xhtml1-transitional">
+<netui:html documentType="xhtml1-transitional" idScope="html">
<head>
<netui:base/>
</head>
@@ -9,40 +9,56 @@
<netui:anchor action="html">html</netui:anchor><br>
Action: <netui:span value="${pageFlow.action}" /><br>
Text: <netui:span value="${pageFlow.text}" />
+ <p style="color:green">This is an XHTML generated document that contains
+ six different types of form submits. Each type differs in either how
+ the form is submitted, or how the form binds to the bean.
+ </p>
<table width="100%">
<tr><td width="50%">
<h4>Case One -- Form Submit to an Action</h4>
- <netui:scriptContainer generateIdScope="true">
- <netui:form action="post">
+ <p style="color:green">Normal button submit, and bean on action</p>
+ <netui:form tagId="f1" action="post">
Text: <netui:textBox dataSource="actionForm.text" />
<netui:button value="submit"/>
</netui:form>
- </netui:scriptContainer>
</td><td width="50%">
<h4>Case Two -- Form Submit To PageFlow</h4>
- <netui:scriptContainer generateIdScope="true">
- <netui:form action="postNoForm">
+ <p style="color:green">Normal button submit, binding to page flow</p>
+ <netui:form tagId="f2" action="postNoForm">
Text: <netui:textBox dataSource="pageFlow.textPage" />
<netui:button value="submit"/>
</netui:form>
- </netui:scriptContainer>
</td></tr>
<tr><td width="50%">
<h4>Case Three -- Form Submit Override Action</h4>
- <netui:scriptContainer generateIdScope="true">
- <netui:form action="post">
+ <p style="color:green">Override the action submitted on the button</p>
+ <netui:form tagId="f3" action="post">
Text: <netui:textBox dataSource="actionForm.text" />
<netui:button action="postOverride" value="submit"/>
</netui:form>
- </netui:scriptContainer>
</td><td width="50%">
<h4>Case Four -- Form Submit Override Action/Different Bean</h4>
- <netui:scriptContainer generateIdScope="true">
- <netui:form action="post">
+ <p style="color:green">Override the action and go to a different bean type</p>
+ <netui:form tagId="f4" action="post">
Text: <netui:textBox dataSource="actionForm.text" />
<netui:button action="postOverrideNewForm" value="submit"/>
</netui:form>
- </netui:scriptContainer>
+ </td></tr>
+ <tr><td width="50%">
+ <h4>Case Five -- Form Submit/Action UseBean</h4>
+ <p style="color:green">Normal Submit, the action has a useFormBean binding to a bean</p>
+ <netui:form tagId="f5" action="postUseFormBean">
+ Text: <netui:textBox dataSource="actionForm.text" />
+ <netui:button value="submit"/>
+ </netui:form>
+ </td><td width="50%">
+ <h4>Case Six -- Form Submit Direct Bean Binding</h4>
+ <p style="color:green">Normal Submit, the form tag specifies a bean in the Session</p>
+ <netui:form tagId="f6" action="postDirect" beanName="FormCases"
+ beanType="coretags.form.cases.Controller$Bean" beanScope="session">
+ Text: <netui:textBox dataSource="actionForm.text" />
+ <netui:button value="submit"/>
+ </netui:form>
</td></tr>
</table>
</netui:body>
Modified: incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml?view=diff&r1=153509&r2=153510
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml (original)
+++ incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml Sat Feb 12 06:52:08 2005
@@ -2207,6 +2207,20 @@
</features>
</test>
<test>
+ <name>CtFormCases</name>
+ <description>All the various cases of form submit</description>
+ <webapp>coreWeb</webapp>
+ <categories>
+ <category>bvt</category>
+ <category>bvt.struts11</category>
+ <category>tags</category>
+ </categories>
+ <features>
+ <feature>Form</feature>
+ <feature>xhtml</feature>
+ </features>
+ </test>
+ <test>
<name>CtFormErrors</name>
<description>Errors produced by the Form tag</description>
<webapp>coreWeb</webapp>
@@ -3860,6 +3874,15 @@
<test>
<name>J166</name>
<description>Demo of how "sticky" tree creation works</description>
+ <webapp>coreWeb</webapp>
+ <categories>
+ <category>bvt</category>
+ <category>jiriBugs</category>
+ </categories>
+ </test>
+ <test>
+ <name>J176</name>
+ <description>Verify that a two forms going to the same action produce valid XHTML</description>
<webapp>coreWeb</webapp>
<categories>
<category>bvt</category>