also,
mav (through bean utils) will do the datatype conversion for you, so instead
of :
public void setTerm(string term) {
this.term = stringToDouble(value);
}
you can just have:
public void setTerm(double term) {
this.term = term;
}
--jim
----- Original Message -----
From: "Eelco Hillenius" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, June 19, 2003 8:26 AM
Subject: Re: [Mav-user] Newbie: Setters appear to not being called...
> Maverick uses Commons BeanUtils to populate its beans (like the
controllers
> in your case). BeanUtils does not populate any fields that do not have a
> getter as well. The solution is to include the getters (like getTerm()
> etc.).
>
> Eelco
>
> ----- Original Message -----
> From: "Kimberley Scott" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Cc: "Kimberley Scott" <[EMAIL PROTECTED]>
> Sent: Thursday, June 19, 2003 2:09 PM
> Subject: [Mav-user] Newbie: Setters appear to not being called...
>
>
> Hiya,
>
> Just started using maverick. Luv it. Gotta slight problem and feeling I'm
> going mad. I think I've got it wrong about how you extend controllers. I
> have this app I'm building, and have a problem where the setters for form
> variables are not being called. I just know I'm doing something wrong, but
> can't see where, and I've re-read the manual supplied (thankyou guys) and
> studied the 'pig' with no luck. I've got cut-down code below and would
love
> any help people can give me:
>
> classes:
> public class ControllerErrorable extends ThrowawayBean2
> {
> ... hasErrors, getErrors etc...
> }
>
> public class Menu extends ControllerErrorable
> {
> ...setters and getters for some menu stuff...
> protected String perform()
> throws Exception
> {
> super.perform();
> ...other stuff
> }
> }
>
> public class Calculator extends Menu
> {
> ...setters and getters for special calculations...
> ...and also:
> public void setTerm(String value)
> {
> System.out.println("Hey! How come I'm not being called?");
> this.term = stringToDouble(value);
> }
> protected String perform()
> throws Exception
> {
> super.perform();
> ...other stuff
> }
> }
>
> maverick.xml:
> <command name="calculator">
> <controller class="com.dcg.ctl.Calculator" />
> <view name="success" path="tools/calculator.jsp">
> <transform path="outerPageWrapper.jsp"/>
> </view>
> </command>
>
> tools/calculator.jsp:
> <form blah blah>
> ...other input...
> <input
> type="text"
> name="term"
> size="4"
> maxlength="4"
> value="<c:out value="${model.longTerm}"/>" />
> ...submit...
> </form>
>
> I must be doing something seriously wrong here, because when I call
> 'calculator.m', the tools/calculator.jsp runs ok. I fill in a value for
the
> input field 'term', and click submit. The 'Menu' class appears to have
it's
> setters and it's perform() called fine. What doesn't seem to be happening
is
> the call to setTerm(String value) within the Calculator controller.
>
> I iterated over the Request and get this:
>
> (iterating over the request parameters)
> 12:48:23,579 INFO [STDOUT] [product] == [bnpl]
> 12:48:23,579 INFO [STDOUT] [period] == [0]
> 12:48:23,579 INFO [STDOUT] [amount] == [0]
> 12:48:23,579 INFO [STDOUT] [action] == [obq]
> 12:48:23,579 INFO [STDOUT] [deposit] == []
> 12:48:23,589 INFO [STDOUT] [term] == [36] <<===
> 12:48:23,589 INFO [STDOUT] [apr] == []
>
> (then called getAction() and getTerm() deliberately within perform()
within
> the Calculator class)
> 12:48:23,579 INFO [STDOUT] action==[obq]
> 12:48:23,579 INFO [STDOUT] term==[0.0] <<==
>
> So 'term' is being sent through. I'm stumped and feeling a tad dim. Can
> anyone help?
>
> Ms Kimberley Scott
> Senior Software Engineer
> DCG Media Ltd
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: INetU
> Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
> INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> [INVALID FOOTER]
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: INetU
> Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
> INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> [INVALID FOOTER]
-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
[INVALID FOOTER]