You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Matthias Wessendorf <ma...@matthias-wessendorf.de> on 2004/06/29 15:22:26 UTC

LazyActionForm

Hello,

are there plans to integrate LazyActionForm form
Nial Pemberton in to struts (or in contrib) ?

since nial is a commiter and it is usefull
to have that functionality *directly* in framework...

regards,
Matthias 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: LazyActionForm

Posted by Ted Husted <hu...@apache.org>.
Since the LazyActionForm <http://www.niallp.pwp.blueyonder.co.uk/> can be validated like any other ActionForm, I don't see the basis for a technical objection. In the documentation, we would want to *strongly* recommend using the validated version, and remind people it is a *bad* practice to pass an ActionForm to the model. They should populate another object from the validated ActionForm and then pass that along (which provides the second layer of firewall).  IMHO, the LazyActionForm may encourage better practices, since people will not be so tempted to use ActionForms as model objects, if they don't have to define things twice (or at least seem to). 

Personally, I think validation and population should be strongly coupled, as it is with the FormProc component (formproc.sf.net). We now treat them as separate steps, but one begs the other. What's missing is an "optional" validator that would let us specify a field that may or may not be present. Then, we could populate only the properties that are specified by the validator form.  

So, if we did want to make the LazyValidatorForm secure, one solution would be to add an "optional" validator. Only the fields specified by a required or optional validator would be accepted, others would be ignored (as they are now). People would not have to specify the fields in the struts-config *and* in the validations.xml, but they would still have to specify them all in validations.xml.

-Ted.

On Wed, 30 Jun 2004 04:35:52 +0100, Niall Pemberton wrote:
> I'm happy to put it into Struts but other committers may object on
> the basis that one of the ActionForm's functions is to act as a
> 'firewall' between the Request and the Action - the
> 'LazyActionForm' circumvents this with all the request parameters
> being populated into it. In my Actions I only take out of them what
> I expect to be there - if you do that its not an issue, but anyone
> who just passed on whatevers in there straight on to their model
> would leave themselves open to attack.
>
> Also the LazyDynaBean/LazyDynaClass objects that the "Lazy"
> ActionForm depends on are more suited to the beanutils project -
> maybe the first step would be to submit these classes to beanutils
> and see if they are happy to accept them.
>
> Niall
>
>
> ----- Original Message -----
> From: "Matthias Wessendorf" <ma...@matthias-wessendorf.de> To:
> <de...@struts.apache.org> Sent: Tuesday, June 29, 2004 2:22 PM
> Subject: LazyActionForm
>
>
>> Hello,
>>
>>
>> are there plans to integrate LazyActionForm form
>> Nial Pemberton in to struts (or in contrib) ?
>>
>>
>> since nial is a commiter and it is usefull
>> to have that functionality *directly* in framework...
>>
>>
>> regards,
>> Matthias
>
>
> --------------------------------------------------------------------
> - To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org For
> additional commands, e-mail: dev-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: LazyActionForm

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
I'm happy to put it into Struts but other committers may object on the basis
that one of the ActionForm's functions is to act as a 'firewall' between the
Request and the Action - the 'LazyActionForm' circumvents this with all the
request parameters being populated into it. In my Actions I only take out of
them what I expect to be there - if you do that its not an issue, but anyone
who just passed on whatevers in there straight on to their model would leave
themselves open to attack.

Also the LazyDynaBean/LazyDynaClass objects that the "Lazy" ActionForm
depends on are more suited to the beanutils project - maybe the first step
would be to submit these classes to beanutils and see if they are happy to
accept them.

Niall

----- Original Message ----- 
From: "Matthias Wessendorf" <ma...@matthias-wessendorf.de>
To: <de...@struts.apache.org>
Sent: Tuesday, June 29, 2004 2:22 PM
Subject: LazyActionForm


> Hello,
>
> are there plans to integrate LazyActionForm form
> Nial Pemberton in to struts (or in contrib) ?
>
> since nial is a commiter and it is usefull
> to have that functionality *directly* in framework...
>
> regards,
> Matthias



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


RE: LazyActionForm

Posted by Mohammad Shoaib <sh...@vmoksha.com>.
I an trying to use LazyDynaction form but I am getting a classcastexception.
Here is the code that I have written ...
Please help I am also providing the code files as an attachment.


<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>

<html:form  action="/myActionPath1">

	<FIELDSET>
	<LEGEND></LEGEND>
	</FIELDSET>
	<hr/>
	<FIELDSET>
	<LEGEND>Module</LEGEND>
	<div id="frmContainer2">
		<div id="frmCol1">
			<div class="odd">
				   <tr>
					<td><html:text tabindex="2" value=""
property="foo" size="20" maxlength="20"/></td>
					<td><html:text  value=""
property="moduleDesc" size="60" tabindex="2" maxlength="40"/></td> 
					<td><img id="plus"
src="images/add_button.gif" alt="" width="13" height="13" border="0"
tabindex="2" onclick="addMore(this)" onKeyPress="addMore(this)"/><img
id="minus" src="images/del_button.gif" alt="" width="13" height="13"
border="0" tabindex="2" onclick="delMe(this)" onKeyPress="delMe(this)">
					</td>
				</tr>
		   </div>
		</div>
	</div>
</FIELDSET>
	<html:submit styleClass="button" property="submitaction"
tabindex="11">Save</html:submit>
</html:form>

<script>
	if(document.forms[0].operation.value=="edit")
	{				
		document.onload = disableAllControls(document.forms[0]);
	}
	function addMore(leafEL){
		var curr_node = leafEL.parentNode.parentNode;
		var new_node = curr_node.cloneNode( true );
		new_codeEl = new_node.getElementsByTagName("INPUT")[0];
		new_codeEl.value="";
		new_codeE2 = new_node.getElementsByTagName("INPUT")[1];
		new_codeE2.value="";

		var root_node = curr_node.parentNode;
		root_node.appendChild(new_node); 
	}
	function delMe(leafEL){		
		var root_node = leafEL.parentNode.parentNode.parentNode;

		if(confirm("Do you want to remove this record?")){
			root_node.removeChild(leafEL.parentNode.parentNode);

		}
	}		
</script>

- <!--  ======================================== Form Bean Definitions 
  --> 
- <form-beans>
  <form-bean name="myForm"
type="org.apache.struts.validator.LazyValidatorActionForm" /> 
  </form-beans>
- <!--  ================================= Global Exception Definitions 
  --> 
- <global-exceptions>
- <!-- 
 sample exception handler

        <exception

            key="expired.password"

            type="app.ExpiredPasswordException"

            path="/changePassword.jsp"/>

        end sample 

  --> 
  </global-exceptions>
- <!--  =================================== Global Forward Definitions 
  --> 
- <global-forwards>
- <!--  Default forward to "Welcome" action 
  --> 
- <!--  Demonstrates using index.jsp to forward 
  --> 
  <forward name="welcome" path="/Welcome.do" /> 
  </global-forwards>
- <!--  =================================== Action Mapping Definitions 
  --> 
- <action-mappings>
- <!--  Default "Welcome" action 
  --> 
- <!--  Forwards to Welcome.jsp 
  --> 
  <action path="/Welcome" type="org.apache.struts.actions.ForwardAction"
parameter="/pages/Welcome.jsp" /> 
- <action path="/myActionPath1" type="myPackage.myActionType1" name="myForm"
input="ModuleDetails.jsp">
  <forward name="success" path="ModuleDetails.jsp" /> 
  </action>




SEVERE: No action instance for path /myActionPath1 could be created
java.lang.ClassCastException
        at
org.apache.struts.action.RequestProcessor.processActionCreate(RequestProcess
or.java:326)
        at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:268)
        at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
        at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
       at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:284)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:204)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:257)
        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:151)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
        at
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContext
Valve.java:245)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:199)
        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:151)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:184
)
        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:151)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164
)
        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:149)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:156)
        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:151)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
        at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
        at
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:833)
        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
ction(Http11Protocol.java:732)
        at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:619)
        at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:688)
        at java.lang.Thread.run(Thread.java:534)










-----Original Message-----
From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk] 
Sent: Friday, July 02, 2004 7:09 PM
To: Struts Developers List
Subject: Re: LazyActionForm

I have submitted LazyDynaBean and LazyDynaClass to commons beanutils.

   http://issues.apache.org/bugzilla/show_bug.cgi?id=29879

The version of  LazyDynaBean posted on my web site only dealt with "simple"
properties, but the version submitted to commons now handles mapped and
indexed properties in a "Lazy" way.

Setting a 'mapped' property now adds the mapped property and instantiates a
Map if it doesn't exist.

Setting an 'indexed' property now adds a List property and instantiates a
List if it doesn't exist. Also automatically grows Lists or Arrays if they
are not big enough to accomodate the index being set.

Niall


----- Original Message ----- 
From: "Matthias Wessendorf" <ma...@matthias-wessendorf.de>
To: <de...@struts.apache.org>
Sent: Tuesday, June 29, 2004 2:22 PM
Subject: LazyActionForm


> Hello,
>
> are there plans to integrate LazyActionForm form
> Nial Pemberton in to struts (or in contrib) ?
>
> since nial is a commiter and it is usefull
> to have that functionality *directly* in framework...
>
> regards,
> Matthias
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org

Re: LazyActionForm

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
I have submitted LazyDynaBean and LazyDynaClass to commons beanutils.

   http://issues.apache.org/bugzilla/show_bug.cgi?id=29879

The version of  LazyDynaBean posted on my web site only dealt with "simple"
properties, but the version submitted to commons now handles mapped and
indexed properties in a "Lazy" way.

Setting a 'mapped' property now adds the mapped property and instantiates a
Map if it doesn't exist.

Setting an 'indexed' property now adds a List property and instantiates a
List if it doesn't exist. Also automatically grows Lists or Arrays if they
are not big enough to accomodate the index being set.

Niall


----- Original Message ----- 
From: "Matthias Wessendorf" <ma...@matthias-wessendorf.de>
To: <de...@struts.apache.org>
Sent: Tuesday, June 29, 2004 2:22 PM
Subject: LazyActionForm


> Hello,
>
> are there plans to integrate LazyActionForm form
> Nial Pemberton in to struts (or in contrib) ?
>
> since nial is a commiter and it is usefull
> to have that functionality *directly* in framework...
>
> regards,
> Matthias
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org