On Tue, Aug 4, 2009 at 2:25 PM, Bhaarat Sharma<bhaara...@gmail.com> wrote: > thanks wes. so when that url will be clicked the setter will be set. > ...maybe pushing the envelope but is it possible to not click any url but > still set a setter. just like we call a getter. > <s:property value = "%{stuff}"/> > > >
The paradigms are different... in your little example, the getter is called, yes, but you are looking at a "view" of your data, so it sort of makes sense that you can get to getters. I am sure there is a way to get to setters, but what I was trying to get to before is that there doesn't appear to be any good reason to call a setter when you are rendering a view (unless you are going to read that value from the action further down the page, but why use an action property for that)... What I am trying to say is that you send parameters to struts, struts performs some magic (well, not really) that converts those parameters and calls your setters, then struts calls your action's business method (most likely 'public String execute()') and returns a string indicating to struts which view to render. What you're asking is how to call a setter from the last step... What I am saying is that it's only really helpful to call a setter if you are planning on calling an action method afterwards. Calling an action method means making some sort of call back to your server. So, construct an URL that specifies the appropriate parameters, then hit that URL... whether you do it by clicking, async JS, trojan horse, whatever, it doesn't matter. To answer your question (after making the point that it may be useless), you can probably call your setter by doing - <s:property value="%{setStuff('string value')}" /> You might have to do this - <s:property value="%{#top.setStuff('string value')}" /> or <s:property value="%{#action.setStuff('string value')}" /> again, though, I question the point because this will happen after your business method has returned and further requests to your action will result in the creation of a new instance of your action (meaning that setter call will have no discernible purpose, it won't even output anything). -Wes -- Wes Wannemacher Head Engineer, WanTii, Inc. Need Training? Struts, Spring, Maven, Tomcat... Ask me for a quote! --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org