Eelco,

Thanks! This is now clear to me. I got confused when I declared a field in
my class using a capital and I was not able to extract it from the model,
other then using a lowercase reference. Should I study the JavaBeans specs
to avoid further 'surprises' or will I be fine knowing this as it is?

Stephan.

-----Original Message-----
From: Eelco Hillenius [mailto:[EMAIL PROTECTED]]
Sent: donderdag 20 februari 2003 21:30
To: [EMAIL PROTECTED]
Subject: Re: [Mav-user] Model doesn't get initialized?


Stephan,

To be short, the basic idea for JavaBeans is that if you have a property, it
starts with a (usually) private or protected defined field. In order to
grant access on your 'bean' to the outside world, It should have a 'getter'
and/ or a 'setter'; resp. to allow reading and writing of the field. The
standard says that a getter be of form: 'getXxx' where where the Xxx stands
for the name of the property, the first character (right after 'get') being
capitalised. An exception to 'getXxx' is the reading of a boolean value,
which should have the form 'isXxx'. This is the only exception. The setters
take form: 'setXxx'.

As '$model.name' tries to find property name, JSTL will look for the method
.getName() in your class. If it's not there it will fail (I don't know and
actually don't care about the case when your field is declared public).

Read more about it: ftp://ftp.javasoft.com/docs/beans/beans.101.pdf

Another thing to know about Java are the code conventions:
http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html

And... before doing anything else, please read at least:
http://java.sun.com/docs/books/tutorial/java/index.html.

Eelco


----- Original Message -----
From: "Stephan Visser" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, February 20, 2003 8:05 PM
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]


-------------------------------------------------------
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]

Reply via email to