mirror of
https://github.com/apache/struts.git
synced 2026-08-07 07:37:20 +00:00
Added automatic checkbox handling code that detect an unchecked checkbox and
add it as a parameter with a default (usually 'false') value. Uses a specially named hidden field to detect unsubmitted checkboxes. The default unchecked value is overridable for non-boolean value'd checkboxes. Minor source formatting and cleaned out an empty directory. WW-992 WW-1372 WW-1349 git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@442085 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -59,21 +59,21 @@ import com.opensymphony.xwork2.interceptor.Interceptor;
|
||||
* <b>Example struts.xml configuration:</b>
|
||||
*
|
||||
* <pre>
|
||||
* <interceptor-ref name="jsfSetup">
|
||||
* <param name="actionListener"></param>
|
||||
* <param name="defaultRenderKitId"></param>
|
||||
* <param name="supportedLocale"></param>
|
||||
* <param name="defaultLocale"></param>
|
||||
* <param name="messageBundle"></param>
|
||||
* <param name="navigationHandler">org.apache.struts2.jsf.StrutsNavigationHandler</param>
|
||||
* <param name="propertyResolver"></param>
|
||||
* <param name="stateManager"></param>
|
||||
* <param name="variableResolver">
|
||||
* org.apache.myfaces.el.VariableResolverImpl
|
||||
* ,org.apache.struts2.jsf.StrutsVariableResolver
|
||||
* </param>
|
||||
* <param name="viewHandler;">org.apache.shale.tiles.TilesViewHandler</param>
|
||||
* </interceptor-ref>
|
||||
* <interceptor-ref name="jsfSetup">
|
||||
* <param name="actionListener"></param>
|
||||
* <param name="defaultRenderKitId"></param>
|
||||
* <param name="supportedLocale"></param>
|
||||
* <param name="defaultLocale"></param>
|
||||
* <param name="messageBundle"></param>
|
||||
* <param name="navigationHandler">org.apache.struts2.jsf.StrutsNavigationHandler</param>
|
||||
* <param name="propertyResolver"></param>
|
||||
* <param name="stateManager"></param>
|
||||
* <param name="variableResolver">
|
||||
* org.apache.myfaces.el.VariableResolverImpl
|
||||
* ,org.apache.struts2.jsf.StrutsVariableResolver
|
||||
* </param>
|
||||
* <param name="viewHandler;">org.apache.shale.tiles.TilesViewHandler</param>
|
||||
* </interceptor-ref>
|
||||
* </pre>
|
||||
*
|
||||
* <p>
|
||||
@@ -209,16 +209,16 @@ public class FacesSetupInterceptor extends FacesSupport implements Interceptor {
|
||||
* The action invocation
|
||||
*/
|
||||
public String intercept(ActionInvocation invocation) throws Exception {
|
||||
if (facesContextFactory != null)
|
||||
{
|
||||
if (facesContextFactory != null) {
|
||||
if (isFacesAction(invocation)) {
|
||||
|
||||
invocation.getInvocationContext().put(
|
||||
FacesInterceptor.FACES_ENABLED, Boolean.TRUE);
|
||||
|
||||
FacesContext facesContext = facesContextFactory.getFacesContext(
|
||||
ServletActionContext.getServletContext(),
|
||||
ServletActionContext.getRequest(), ServletActionContext
|
||||
FacesContext facesContext = facesContextFactory
|
||||
.getFacesContext(ServletActionContext
|
||||
.getServletContext(), ServletActionContext
|
||||
.getRequest(), ServletActionContext
|
||||
.getResponse(), lifecycle);
|
||||
|
||||
setLifecycle(lifecycle);
|
||||
@@ -230,7 +230,8 @@ public class FacesSetupInterceptor extends FacesSupport implements Interceptor {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new StrutsException("Unable to initialize jsf interceptors probably due missing JSF implementation libraries",
|
||||
throw new StrutsException(
|
||||
"Unable to initialize jsf interceptors probably due missing JSF implementation libraries",
|
||||
invocation.getProxy().getConfig());
|
||||
}
|
||||
return invocation.invoke();
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
<interceptor name="validation" class="com.opensymphony.xwork2.validator.ValidationInterceptor"/>
|
||||
<interceptor name="workflow" class="com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor"/>
|
||||
<interceptor name="store" class="org.apache.struts2.interceptor.MessageStoreInterceptor" />
|
||||
<interceptor name="checkbox" class="org.apache.struts2.interceptor.CheckboxInterceptor" />
|
||||
|
||||
<!-- JSF interceptors, one per lifecycle phase -->
|
||||
<interceptor class="org.apache.struts2.jsf.FacesSetupInterceptor" name="jsfSetup" />
|
||||
@@ -156,6 +157,7 @@
|
||||
<interceptor-ref name="model-driven"/>
|
||||
<interceptor-ref name="fileUpload"/>
|
||||
<interceptor-ref name="static-params"/>
|
||||
<interceptor-ref name="checkbox"/>
|
||||
<interceptor-ref name="params"/>
|
||||
<interceptor-ref name="conversionError"/>
|
||||
<interceptor-ref name="validation">
|
||||
|
||||
@@ -26,3 +26,4 @@
|
||||
<#include "/${parameters.templateDir}/simple/scripting-events.ftl" />
|
||||
<#include "/${parameters.templateDir}/simple/common-attributes.ftl" />
|
||||
/>
|
||||
<input type="hidden" name="__checkbox_${parameters.name?html}" value="${parameters.fieldValue?html}"/>
|
||||
@@ -3,6 +3,7 @@
|
||||
</td>
|
||||
<td valign="top" align="left">
|
||||
<input type="checkbox" name="foo" value="baz" checked="checked" id="someId" title="mytitle" onfocus="test();"/>
|
||||
<input type="hidden" name="__checkbox_foo" value="baz"/>
|
||||
<label for="someId" class="checkboxLabel">mylabel</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
</td>
|
||||
<td valign="top" align="left">
|
||||
<input type="checkbox" name="foo" value="baz" id="foo" title="mytitle"/>
|
||||
<input type="hidden" name="__checkbox_foo" value="baz"/>
|
||||
<label for="foo" class="checkboxLabel">mylabel</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
</td>
|
||||
<td valign="top" align="left">
|
||||
<input type="checkbox" name="foo" value="baz" checked="checked" id="foo" title="mytitle" onclick="test();" ondblclick="test();"/>
|
||||
<input type="hidden" name="__checkbox_foo" value="baz"/>
|
||||
<label for="foo" class="checkboxErrorLabel">mylabel</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -6,5 +6,6 @@
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input type="checkbox" name="foo" value="baz" checked="checked" id="someId" title="mytitle" onfocus="test();"/>
|
||||
<input type="hidden" name="__checkbox_foo" value="baz"/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -4,5 +4,6 @@
|
||||
</td>
|
||||
<td valign="top" align="left">
|
||||
<input type="checkbox" name="foo" value="baz" checked="checked" id="someId" title="mytitle" onfocus="test();"/>
|
||||
<input type="hidden" name="__checkbox_foo" value="baz"/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user