RE: Model doesn't get initialized?

"Schnitzer, Jeff" <[email protected]>
Newsgroups gmane.comp.web.maverick.general
Message-ID <[email protected]>
Yep, that's exactly right.  The JavaBeans spec says that for a property
"nameOfBeer", the setter is:

public void setNameOfBeer(String value)

and the getter is:

public String getNameOfBeer()

The case matters.  However, some templating languages (like Velocity)
will compensate for you (JSTL doesn't).

It gets a little weirder.  If you have a boolean value, say "lightBeer",
there are two possible getters:

public boolean getLightBeer()
public boolean isLightBeer()

Since it's possible to have both of those methods on a class, one of
them takes precedence over the other (I don't remember which offhand).

Jeff Schnitzer
[email protected]

> -----Original Message-----
> From: Stephan Visser [mailto:[email protected]]
> Sent: Thursday, February 20, 2003 11:05 AM
> To: '[email protected]'
> Subject: RE: [Mav-user] Model doesn't get initialized?
> 
> So, if I understand you correctly, I should expect the following
> behaviour:
> 
> I have a controller class Foo with a String Name and in a JSP that
gets
> activated as a view I have to use $model.name (with lowercase name
i.s.o.
> Name as defined in the class) ??
> 
> If the JavaBean specs (which I'm sorry I'm not familiar with) state
this
> behaviour as standard I't fine by me. Still, I find it pretty
confusing...
> 
> Stephan.
> 
> -----Original Message-----
> From: Vladimir Yusseem [mailto:[email protected]]
> Sent: donderdag 20 februari 2003 19:49
> To: [email protected]
> Subject: Re: [Mav-user] Model doesn't get initialized?
> 
> 
> Also Java seemed to be case sensetive ... :-).
> 
> ----- Original Message -----
> From: "Eelco Hillenius" <[email protected]>
> To: <[email protected]>
> Sent: Thursday, February 20, 2003 8:53 AM
> Subject: RE: [Mav-user] Model doesn't get initialized?
> 
> 
> > Do you know about the JavaBean spec? This is pretty standard Java
> stuff...
> >
> > Eelco
> >
> >
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]]On Behalf Of Stephan
Visser
> > Sent: donderdag 20 februari 2003 12:54
> > To: '[email protected]'
> > Subject: RE: [Mav-user] Model doesn't get initialized?
> >
> >
> > Ok.. I got a bit further now (it actually works) but I am still
> confused...
> >
> > I did the following to my example-code:
> >
> > - Renamed Perform() to perform() (whoooo!!)
> > - Added to the perform method:
> >
this.setName(this.getCtx().getRequest().getParameter("first_name"));
> >
> > Now, I discovered that in my class I actually have a private String
Name
> > (mind the capital N!)
> >
> > From the JSP I can get to the value through <c:out
> value="${model.name}"/>
> > and NOT through <c:out value="${model.Name}"/>..... is that
behaviour I
> > should expect?
> >
> > Anyway, it works now and for the time being I'll just keep all my
fields
> > lowercase to not get mixed up with the $model references from the
> JSP's....
> >
> > Stephan.
> >
> > -----Original Message-----
> > From: Catalin Constantin [mailto:[email protected]]
> > Sent: donderdag 20 februari 2003 12:09
> > To: [email protected]
> > Subject: Re: [Mav-user] Model doesn't get initialized?
> >
> >
> > try
> > <c:out value="${model.name}" /> in the .jsp file
> >
> > Catalin
> >
> > ----- Original Message -----
> > From: Stephan Visser
> > To: '[email protected]'
> > Sent: Thursday, February 20, 2003 1:02 PM
> > Subject: [Mav-user] Model doesn't get initialized?
> >
> >
> > Hi there!
> >
> > I am trying to create a simple example application, using the
friendbook
> as
> > an example. The framework seems to work fine, including LOG4J. I do
have
> a
> > lot of problems when I try to get a controller to work. I have
something
> > like this:
> >
> > package com.maverick.controllers;
> > import org.infohazard.maverick.ctl.ThrowawayBean2;
> >
> > public class TestController extends ThrowawayBean2
> > {
> >   private String name;
> >
> >   public String getname() { return this.name; }
> >   public void setname(String s) { this.name = s; }
> >
> >   public String Perform()
> >   {
> >     return "success";
> >   }
> > }
> >
> > In the maverick.xml I have something like this:
> >
> > <command name="submitname">
> >   <controller class="com.maverick.controllers.TestController" />
> >   <view name="success" path="testform.jsp"/>
> > </command>
> >
> > In my testform.jsp I try to read the value from the model like so:
> >
> > <c:out value="${model.test}" />
> >
> > ...and now for the weird part (and also my question)....
> >
> > NOTHING comes out of the model! Am I overseeing something or doing
> something
> > wrong?? I spent an entire evening trying to figure out how to get
this
> to
> > work, no success. I even tried to explicitly fill the model in the
> > controller using the setModel method.... nothing happens.... I have
> > absolutely no clue ... can anybody help me?
> >
> > Thanks in advance!
> >
> > Stephan.
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
> > The most comprehensive and flexible code editor you can use.
> > Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day
Trial.
> > www.slickedit.com/sourceforge
> > [INVALID FOOTER]
> >
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
> > The most comprehensive and flexible code editor you can use.
> > Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day
Trial.
> > www.slickedit.com/sourceforge
> > [INVALID FOOTER]
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
> > The most comprehensive and flexible code editor you can use.
> > Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day
Trial.
> > www.slickedit.com/sourceforge
> > [INVALID FOOTER]
> >
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
> > The most comprehensive and flexible code editor you can use.
> > Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day
Trial.
> > www.slickedit.com/sourceforge
> > [INVALID FOOTER]
> 
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
> The most comprehensive and flexible code editor you can use.
> Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial.
> www.slickedit.com/sourceforge
> [INVALID FOOTER]
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
> The most comprehensive and flexible code editor you can use.
> Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial.
> www.slickedit.com/sourceforge
> [INVALID FOOTER]


-------------------------------------------------------
This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
The most comprehensive and flexible code editor you can use.
Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial.
www.slickedit.com/sourceforge
[INVALID FOOTER]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.