To answer your question, just look at my constructor. Some of the values of
the domain object are being initialized in there.
Based on your second paragraph, I would think simply creating a new Person
object would work.
private Person person = new Person();
To my surprise it does not. Nor does
public Resolution view() {
setPerson(new Person());
return new ForwardResolution("test.jsp");
}
Which leads me to believe that I must be doing something else wrong.
Any other ideas? I just want to have a few of my select boxes have default
values.
Nathan
On Thu, Sep 18, 2008 at 8:36 AM, Tim Fennell <[EMAIL PROTECTED]> wrote:
> Stripes creates objects on the fly during binding, but won't instantiate
> objects on the fly when it's just trying to read information. From Stripes'
> perspective you've asked to display "person.name" but person is null - why
> would Stripes make up a person and then try to display their name?
> The input tags only read data - they won't instantiate or change the
> ActionBean or model objects hanging off it in any way. So if you want the
> name to show you'll have to add setPerson(new Person()) to your view()
> method.
>
> -t
>
> On Sep 18, 2008, at 10:30 AM, Nathan Maves wrote:
>
> I thought that as well but stripes normally does a great job at creating
> objects for you. Other wise I would think the form tag would have thrown a
> NPE.
>
>
>
> On Wed, Sep 17, 2008 at 11:50 PM, Leonard Gestrin <
> [EMAIL PROTECTED]> wrote:
>
>> Could it because you did not create instance of the class Person?
>>
>> ------------------------------
>>
>> *From:* [EMAIL PROTECTED] [mailto:
>> [EMAIL PROTECTED] *On Behalf Of *Nathan Maves
>> *Sent:* Wednesday, September 17, 2008 10:42 PM
>> *To:* Stripes Users List
>> *Subject:* [Stripes-users] Default values in domain object not being use
>> inform fields
>>
>>
>> based on the jsp and class below why does the form field not get defaulted
>> by the value in the domain model?
>>
>> *jsp*
>> <[EMAIL PROTECTED] prefix="s"
>> uri="http://stripes.sourceforge.net/stripes.tld"%>
>>
>> <[EMAIL PROTECTED] prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
>>
>> <[EMAIL PROTECTED] contentType="text/html" pageEncoding="UTF-8"%>
>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>> "http://www.w3.org/TR/html4/loose.dtd">
>>
>> <html>
>> <head>
>> <meta http-equiv="Content-Type" content="text/html;
>> charset=UTF-8">
>> <title>JSP Page</title>
>> </head>
>> <body>
>> <h2>Hello World!</h2>
>>
>> <s:form beanclass="com.mwt.oclc.stripes.TestAction">
>> Name <s:text name="person.name"/>
>> </s:form>
>> </body>
>> </html>
>>
>>
>> *class*
>> @UrlBinding("/test")
>> public class TestAction implements ActionBean {
>> private ActionBeanContext context;
>>
>> public ActionBeanContext getContext() {
>> return context;
>> }
>>
>> public void setContext(ActionBeanContext context) {
>> this.context = context;
>> }
>>
>> private Person person;
>>
>> public Person getPerson() {
>> return person;
>> }
>>
>> public void setPerson(Person person) {
>> this.person = person;
>> }
>>
>> public Resolution view() {
>> return new ForwardResolution("test.jsp");
>> }
>>
>> class Person {
>> private String name = "nathan";
>>
>> public String getName() {
>> return name;
>> }
>>
>> public void setName(String name) {
>> this.name = name;
>> }
>> }
>> }
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's
>> challenge
>> Build the coolest Linux based applications with Moblin SDK & win great
>> prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the
>> world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> Stripes-users mailing list
>> Stripes-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>>
>>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
>
> http://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users