struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <new...@pingsite.com>
Subject Re: DynaValidationForm Display In JSP?
Date Wed, 30 Mar 2005 19:20:25 GMT
Scott Purcell wrote:

>That is what I said. Its got to work, or why have it. Anyway, the error, (past my tail
command by now) was the tag could not find a getter for the coversCheckbox element. And of
course it can't, there is none. There needs to be a way to let the html: element know that
this is a DynaValidationForm and now a normal bean. At least I would think so.
>
>And yes, I double checked all my syntax before I posted. Even to double check myself,
I just created a simple CheckboxBean, put my value from the Dyna into there, and called the
new one in the JSP page, and that works. 
>
>So that tells me I am either missing a step, or it does not work that way.
>  
>
I have DynaValidatorActionForms with checkboxes all over the place; 
there is zero reason why it shouldn't work if you have everything 
configured properly.

Did you post your struts-config, JSP, Action class code, and stack 
trace? I'm not totally able to keep up with the list due to volume, so I 
probably missed it. Without it we really can't help much.

Really, this stuff is all pretty much covered in the on-line literature 
and books, 'cuz that's how I figured it all out, and asked here for a 
few  more esoteric questions. What materials are you using for reference 
(besides the mailing list)?

For generic bean utilities you will probably want to look at the Commons 
BeanUtils stuff; it will handle the majority of your data transfer needs 
going from DTOs to forms of various natures.

Oh, I see in your original post that you have most of the necessary 
stuff; what about the action-mapping? Here's a chunk (expurgated; the 
one without the gannet) I use that works just fine:

Bean Definition
-------------------------------------
    <form-bean name="anntypebean" 
type="org.apache.struts.validator.DynaValidatorActionForm">
      <form-property name="clientAnnouncementP" type="java.lang.Boolean"/>
    </form-bean>

action-mapping
-------------------------------------
    <action path="/EventAnnouncementType"
            type="actions.EventAnnouncementType"
            name="anntypebean"
            input="page.EventAnnouncementType"
            scope="request"
            validate="false"
            roles="Admin,Client,Event">
      <set-property property="secure" value="false"/>
      <forward name="next" path="/goto/EventAnnouncementTypes" 
redirect="true"/>
    </action>

Action code
-------------------------------------
// [Ed. Note] I do this rather than BeanUtils.copyProperties because 
it's a Boolean on the page
// but an integer in the database. I've casted from ActionForm to 
DynaActionForm previously.
// And yes, I am a Lisp programmer. Java gives me hives and makes me 
type too much:
// "When Java is your hammer, everything starts to look like a thumb." 
-- Steve Haflich w/o permission
            Boolean clientAnnouncementP = (Boolean) 
form_.get("clientAnnouncementP");

JSP code
-------------------------------------
<%@ taglib prefix="html"  uri="/WEB-INF/tlds/struts-html.tld" %>
<html:form action="/EventAnnouncementType" method="post" styleClass="form">
      <html:checkbox property="clientAnnouncementP" styleClass="formfield"/>
</html:form>

Dave



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


Mime
View raw message