This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
How can I change the value of a bean ? If I want to expose its value, I can use <bean:write.../> but what if I want to change some property value ? I checked the struts-bean library documentation and did not find anything... If there's another library (commons ?) will be suitable as well. Juarez
I suppose you could use the <jsp:setProperty> tag but you don't normally go changing bean values in your JSP when you are working with the Struts framework. Why do you want to do that? Why do you think it should be done in the JSP? [ March 26, 2003: Message edited by: Junilu Lacar ]
Yes, I tried this approach but it did not work. This is a known workaround for fixing the checkboxes problems in Struts (unchecked ones are not included in the request). <html:checkbox name="autorizacaoForm" property="inclusive" value="S"/> <jsp:setProperty name="autorizacaoForm" property="inclusive" value="N"/> This approach does work in a single jsp page but it's not working when using Tiles... I have just checked Class PropertyUtils from commons-beanutils but it doesn't find the right prop (perhaps because I am using a DynaValidatorActionForm and its props are in a Map). Thanks for helping. Juarez
The fix to the checkbox problem is to override the ActionForm.reset method and in there, set the property that corresponds to the checkbox to its default, unchecked value. When the request comes in, only properties that have corresponding request parameter values are set. If the checkbox is unchecked, then the form property will retain the default or unchecked value. Edit #1: This is when you have a regular ActionForm though. Not too sure about the DynaForm. Edit #2: Just read through your other posts and saw that you've tried the reset() approach. I'll have to explore this DynaForm thing because I honestly haven't used it before. [ March 26, 2003: Message edited by: Junilu Lacar ]
Juarez Alvares Barbosa Junior
Joined: Mar 18, 2002
Hi, I have fixed the problem, using the c:set tag of JSTL. The reset is not working due to the fact that the property bound to my checkbox is a String, not a Boolean. Thanks a lot for helping, Juarez