You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by mu...@fantasymail.de on 2007/01/18 23:52:10 UTC

@BeanForm How do you use it ???

I have tried:
 
<span jwcid="@BeanForm" bean="ognl:foo" properties="ognl:'name'" save="listener:onSave" />

as well as:

<span jwcid="@BeanForm" bean="ognl:foo" beanProperties="ognl:'name'" save="listener:onSave" />

but it comes up with:

ognl.OgnlException
beanProperties
 
java.lang.NullPointerException
Stack Trace:

    * com.domain.components.BeanForm.getBeanProperties(BeanForm.java:149) 

Any pointing in the right direction?

Thanks!

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: @BeanForm for a Cat and its Owner (PropertySelection)

Posted by D&J Gredler <dj...@gmail.com>.
Anything that allows us programmers to be lazier is better, but there are a
couple of questions that would have to be answered:

 1. How does the BeanForm component know what string representation to use
for each object in the list? For example, I can't just assume every object
out there has a getName() method unless I force BeanForm users to implement
a custom interface on their domain objects. Not pretty. And you're not
really supposed to use toString()'s for this kind of thing...

 2. How would the BeanForm component know where to get the list of objects
from? You might have a service / dao framework backing your view that
BeanForm knows nothing about.

 3. If both of the above issues are resolved, how does the BeanForm know to
trigger this one-to-many logic for a specific property? It could certainly
watch for @OneToMany JPA annotations, but in that case not all users would
be getting all the benefits of using the component.

Answer these questions in an elegant way, and you'll have your wish! :-)

Take care,

Daniel


On 1/20/07, munich@fantasymail.de <mu...@fantasymail.de> wrote:
>
> Thanks!
>
> But this is the answer I feared :-(
>
> Do you think it would be possible to make the BeanForm component more
> intelligent, that it will do that automatically?
>
> It would only need to call the getName() method on referenced objects....
>
> This way you would save lots of code and even for the most complex object
> a single BeanForm line would do the trick......
>
> I played a round with the cognition framework and I think it was already
> doing something similiar as far as I remember:
>
> http://dev.thelabllc.com/cognition/
>
>
>
> -------- Original-Nachricht --------
> Datum: Sat, 20 Jan 2007 01:40:11 +0100
> Von: "D&J Gredler" <dj...@gmail.com>
> An: "Tapestry users" <us...@tapestry.apache.org>
> Betreff: Re: @BeanForm for a Cat and its Owner (PropertySelection)
>
> > You will need to create a small class that implements
> > IPropertySelectionModel (maybe inside your page class):
> >
> >     private final static class OwnerPropertySelectionModel implements
> > IPropertySelectionModel {
> >         private List<Owner> owners;
> >         public OwnerPropertySelectionModel( List<Owner> owners ) {
> >             this.owners = owners;
> >         }
> >         public int getOptionCount() {
> >             return this.owners.size();
> >         }
> >         public Object getOption( int index ) {
> >             return this.owners.get( index );
> >         }
> >         public String getLabel( int index ) {
> >             Owner owner = this.owners.get( index );
> >             return ( owner != null ? owner.getName() : null );
> >         }
> >         public String getValue( int index ) {
> >             return String.valueOf( index );
> >         }
> >         public Object translateValue( String value ) {
> >             if( value == null ) return null;
> >             else return this.owners.get( Integer.valueOf( value ) );
> >         }
> >     }
> >
> > You will then need to return an instance of this class from a method on
> > your
> > page:
> >
> >     public IPropertySelectionModel getOwnerPSM() {
> >         List<Owner> owners = ...
> >         return new OwnerPropertySelectionModel( owners );
> >     }
> >
> > Then just add another binding to your BeanForm component:
> >
> >    owner_model="ognl:ownerPSM"
> >
> > All of this code was taken from the example webapp, specifically the
> > binding
> > override examples page. Check it out if you get a chance.
> >
> > Take care,
> >
> > Daniel
> >
> >
> > On 1/20/07, munich@fantasymail.de <mu...@fantasymail.de> wrote:
> > >
> > > I got it working now...I saw some helpful additional comments on the
> > > sourceforge page. I used the annotations now and did without a page
> > file.
> > > I also added a library line to the application file. Another error was
> > > that I forgot the PageBeginRender interface so that the object was
> null
> > when
> > > the page loaded as the method to create an empty object was not
> called.
> > >
> > > But another question....I am trying to edit a an object that depends
> on
> > > another object/table which i would like to solve as a
> > > PropertySelection...preferrably without doing a PropertySelectionModel
> > class
> > > for it.
> > >
> > >
> > > E.g.:
> > >
> > > Table with Cats
> > > ~~~~~~~~~~~~~~~
> > >
> > > (mapped to Cat.java)
> > >
> > > id  name       owner_id
> > > 1   Felix        2
> > > 2   Garfield     1
> > >
> > >
> > > Table with Owners
> > > ~~~~~~~~~~~~~~~~~~
> > >
> > > (mapped to Owner.java)
> > >
> > > id  name
> > > 1   Sally
> > > 2   Peter
> > >
> > > So if I want to edit or create a new Cat I want the Owner to be
> > selectable
> > > as PropertySelection.
> > >
> > > <span jwcid="@bf:BeanForm" bean="ognl:cat" save="listener:save"
> > > delete="listener:delete"/>
> > >
> > > Just displays a text field for the owner_id....
> > >
> > >
> > > has anyone got a good example how to do it? Or does it end up gettings
> a
> > > bit messy with lots of coding for a PropertySelectionModel class?
> > >
> > > Thanks!
> > >
> > > -------- Original-Nachricht --------
> > > Datum: Fri, 19 Jan 2007 00:52:55 +0100
> > > Von: "D&J Gredler" <dj...@gmail.com>
> > > An: "Tapestry users" <us...@tapestry.apache.org>
> > > Betreff: Re: @BeanForm How do you use it ???
> > >
> > > > Hi,
> > > >
> > > > What version are you using? Can you post the full stack trace? I
> > looked
> > > at
> > > > the source code and I don't really see how line 149 of BeanForm.java
> > can
> > > > cause a NPE...
> > > >
> > > > Also, what library id are you using in the .application file? Those
> > > > jwcid's
> > > > should probably include the library id, no?
> > > >
> > > > Take care,
> > > >
> > > > Daniel
> > > >
> > > >
> > > > On 1/18/07, munich@fantasymail.de <mu...@fantasymail.de> wrote:
> > > > >
> > > > > I have tried:
> > > > >
> > > > > <span jwcid="@BeanForm" bean="ognl:foo" properties="ognl:'name'"
> > > > > save="listener:onSave" />
> > > > >
> > > > > as well as:
> > > > >
> > > > > <span jwcid="@BeanForm" bean="ognl:foo"
> beanProperties="ognl:'name'"
> > > > > save="listener:onSave" />
> > > > >
> > > > > but it comes up with:
> > > > >
> > > > > ognl.OgnlException
> > > > > beanProperties
> > > > >
> > > > > java.lang.NullPointerException
> > > > > Stack Trace:
> > > > >
> > > > >     *
> > > > com.domain.components.BeanForm.getBeanProperties(BeanForm.java:149)
> > > > >
> > > > > Any pointing in the right direction?
> > > > >
> > > > > Thanks!
> > > > >
> > > > >
> > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > > >
> > > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: @BeanForm for a Cat and its Owner (PropertySelection)

Posted by mu...@fantasymail.de.
Thanks!

But this is the answer I feared :-(

Do you think it would be possible to make the BeanForm component more intelligent, that it will do that automatically?

It would only need to call the getName() method on referenced objects....

This way you would save lots of code and even for the most complex object 
a single BeanForm line would do the trick......

I played a round with the cognition framework and I think it was already doing something similiar as far as I remember:

http://dev.thelabllc.com/cognition/



-------- Original-Nachricht --------
Datum: Sat, 20 Jan 2007 01:40:11 +0100
Von: "D&J Gredler" <dj...@gmail.com>
An: "Tapestry users" <us...@tapestry.apache.org>
Betreff: Re: @BeanForm for a Cat and its Owner (PropertySelection)

> You will need to create a small class that implements
> IPropertySelectionModel (maybe inside your page class):
> 
>     private final static class OwnerPropertySelectionModel implements
> IPropertySelectionModel {
>         private List<Owner> owners;
>         public OwnerPropertySelectionModel( List<Owner> owners ) {
>             this.owners = owners;
>         }
>         public int getOptionCount() {
>             return this.owners.size();
>         }
>         public Object getOption( int index ) {
>             return this.owners.get( index );
>         }
>         public String getLabel( int index ) {
>             Owner owner = this.owners.get( index );
>             return ( owner != null ? owner.getName() : null );
>         }
>         public String getValue( int index ) {
>             return String.valueOf( index );
>         }
>         public Object translateValue( String value ) {
>             if( value == null ) return null;
>             else return this.owners.get( Integer.valueOf( value ) );
>         }
>     }
> 
> You will then need to return an instance of this class from a method on
> your
> page:
> 
>     public IPropertySelectionModel getOwnerPSM() {
>         List<Owner> owners = ...
>         return new OwnerPropertySelectionModel( owners );
>     }
> 
> Then just add another binding to your BeanForm component:
> 
>    owner_model="ognl:ownerPSM"
> 
> All of this code was taken from the example webapp, specifically the
> binding
> override examples page. Check it out if you get a chance.
> 
> Take care,
> 
> Daniel
> 
> 
> On 1/20/07, munich@fantasymail.de <mu...@fantasymail.de> wrote:
> >
> > I got it working now...I saw some helpful additional comments on the
> > sourceforge page. I used the annotations now and did without a page
> file.
> > I also added a library line to the application file. Another error was
> > that I forgot the PageBeginRender interface so that the object was null
> when
> > the page loaded as the method to create an empty object was not called.
> >
> > But another question....I am trying to edit a an object that depends on
> > another object/table which i would like to solve as a
> > PropertySelection...preferrably without doing a PropertySelectionModel
> class
> > for it.
> >
> >
> > E.g.:
> >
> > Table with Cats
> > ~~~~~~~~~~~~~~~
> >
> > (mapped to Cat.java)
> >
> > id  name       owner_id
> > 1   Felix        2
> > 2   Garfield     1
> >
> >
> > Table with Owners
> > ~~~~~~~~~~~~~~~~~~
> >
> > (mapped to Owner.java)
> >
> > id  name
> > 1   Sally
> > 2   Peter
> >
> > So if I want to edit or create a new Cat I want the Owner to be
> selectable
> > as PropertySelection.
> >
> > <span jwcid="@bf:BeanForm" bean="ognl:cat" save="listener:save"
> > delete="listener:delete"/>
> >
> > Just displays a text field for the owner_id....
> >
> >
> > has anyone got a good example how to do it? Or does it end up gettings a
> > bit messy with lots of coding for a PropertySelectionModel class?
> >
> > Thanks!
> >
> > -------- Original-Nachricht --------
> > Datum: Fri, 19 Jan 2007 00:52:55 +0100
> > Von: "D&J Gredler" <dj...@gmail.com>
> > An: "Tapestry users" <us...@tapestry.apache.org>
> > Betreff: Re: @BeanForm How do you use it ???
> >
> > > Hi,
> > >
> > > What version are you using? Can you post the full stack trace? I
> looked
> > at
> > > the source code and I don't really see how line 149 of BeanForm.java
> can
> > > cause a NPE...
> > >
> > > Also, what library id are you using in the .application file? Those
> > > jwcid's
> > > should probably include the library id, no?
> > >
> > > Take care,
> > >
> > > Daniel
> > >
> > >
> > > On 1/18/07, munich@fantasymail.de <mu...@fantasymail.de> wrote:
> > > >
> > > > I have tried:
> > > >
> > > > <span jwcid="@BeanForm" bean="ognl:foo" properties="ognl:'name'"
> > > > save="listener:onSave" />
> > > >
> > > > as well as:
> > > >
> > > > <span jwcid="@BeanForm" bean="ognl:foo" beanProperties="ognl:'name'"
> > > > save="listener:onSave" />
> > > >
> > > > but it comes up with:
> > > >
> > > > ognl.OgnlException
> > > > beanProperties
> > > >
> > > > java.lang.NullPointerException
> > > > Stack Trace:
> > > >
> > > >     *
> > > com.domain.components.BeanForm.getBeanProperties(BeanForm.java:149)
> > > >
> > > > Any pointing in the right direction?
> > > >
> > > > Thanks!
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > >
> > > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: @BeanForm for a Cat and its Owner (PropertySelection)

Posted by D&J Gredler <dj...@gmail.com>.
You will need to create a small class that implements
IPropertySelectionModel (maybe inside your page class):

    private final static class OwnerPropertySelectionModel implements
IPropertySelectionModel {
        private List<Owner> owners;
        public OwnerPropertySelectionModel( List<Owner> owners ) {
            this.owners = owners;
        }
        public int getOptionCount() {
            return this.owners.size();
        }
        public Object getOption( int index ) {
            return this.owners.get( index );
        }
        public String getLabel( int index ) {
            Owner owner = this.owners.get( index );
            return ( owner != null ? owner.getName() : null );
        }
        public String getValue( int index ) {
            return String.valueOf( index );
        }
        public Object translateValue( String value ) {
            if( value == null ) return null;
            else return this.owners.get( Integer.valueOf( value ) );
        }
    }

You will then need to return an instance of this class from a method on your
page:

    public IPropertySelectionModel getOwnerPSM() {
        List<Owner> owners = ...
        return new OwnerPropertySelectionModel( owners );
    }

Then just add another binding to your BeanForm component:

   owner_model="ognl:ownerPSM"

All of this code was taken from the example webapp, specifically the binding
override examples page. Check it out if you get a chance.

Take care,

Daniel


On 1/20/07, munich@fantasymail.de <mu...@fantasymail.de> wrote:
>
> I got it working now...I saw some helpful additional comments on the
> sourceforge page. I used the annotations now and did without a page file.
> I also added a library line to the application file. Another error was
> that I forgot the PageBeginRender interface so that the object was null when
> the page loaded as the method to create an empty object was not called.
>
> But another question....I am trying to edit a an object that depends on
> another object/table which i would like to solve as a
> PropertySelection...preferrably without doing a PropertySelectionModel class
> for it.
>
>
> E.g.:
>
> Table with Cats
> ~~~~~~~~~~~~~~~
>
> (mapped to Cat.java)
>
> id  name       owner_id
> 1   Felix        2
> 2   Garfield     1
>
>
> Table with Owners
> ~~~~~~~~~~~~~~~~~~
>
> (mapped to Owner.java)
>
> id  name
> 1   Sally
> 2   Peter
>
> So if I want to edit or create a new Cat I want the Owner to be selectable
> as PropertySelection.
>
> <span jwcid="@bf:BeanForm" bean="ognl:cat" save="listener:save"
> delete="listener:delete"/>
>
> Just displays a text field for the owner_id....
>
>
> has anyone got a good example how to do it? Or does it end up gettings a
> bit messy with lots of coding for a PropertySelectionModel class?
>
> Thanks!
>
> -------- Original-Nachricht --------
> Datum: Fri, 19 Jan 2007 00:52:55 +0100
> Von: "D&J Gredler" <dj...@gmail.com>
> An: "Tapestry users" <us...@tapestry.apache.org>
> Betreff: Re: @BeanForm How do you use it ???
>
> > Hi,
> >
> > What version are you using? Can you post the full stack trace? I looked
> at
> > the source code and I don't really see how line 149 of BeanForm.java can
> > cause a NPE...
> >
> > Also, what library id are you using in the .application file? Those
> > jwcid's
> > should probably include the library id, no?
> >
> > Take care,
> >
> > Daniel
> >
> >
> > On 1/18/07, munich@fantasymail.de <mu...@fantasymail.de> wrote:
> > >
> > > I have tried:
> > >
> > > <span jwcid="@BeanForm" bean="ognl:foo" properties="ognl:'name'"
> > > save="listener:onSave" />
> > >
> > > as well as:
> > >
> > > <span jwcid="@BeanForm" bean="ognl:foo" beanProperties="ognl:'name'"
> > > save="listener:onSave" />
> > >
> > > but it comes up with:
> > >
> > > ognl.OgnlException
> > > beanProperties
> > >
> > > java.lang.NullPointerException
> > > Stack Trace:
> > >
> > >     *
> > com.domain.components.BeanForm.getBeanProperties(BeanForm.java:149)
> > >
> > > Any pointing in the right direction?
> > >
> > > Thanks!
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

@BeanForm for a Cat and its Owner (PropertySelection)

Posted by mu...@fantasymail.de.
I got it working now...I saw some helpful additional comments on the sourceforge page. I used the annotations now and did without a page file.
I also added a library line to the application file. Another error was that I forgot the PageBeginRender interface so that the object was null when the page loaded as the method to create an empty object was not called.

But another question....I am trying to edit a an object that depends on another object/table which i would like to solve as a PropertySelection...preferrably without doing a PropertySelectionModel class for it.


E.g.:

Table with Cats
~~~~~~~~~~~~~~~

(mapped to Cat.java)

id  name       owner_id
1   Felix        2
2   Garfield     1


Table with Owners
~~~~~~~~~~~~~~~~~~

(mapped to Owner.java)

id  name    
1   Sally        
2   Peter

So if I want to edit or create a new Cat I want the Owner to be selectable as PropertySelection.

<span jwcid="@bf:BeanForm" bean="ognl:cat" save="listener:save" delete="listener:delete"/>

Just displays a text field for the owner_id....


has anyone got a good example how to do it? Or does it end up gettings a bit messy with lots of coding for a PropertySelectionModel class?

Thanks!

-------- Original-Nachricht --------
Datum: Fri, 19 Jan 2007 00:52:55 +0100
Von: "D&J Gredler" <dj...@gmail.com>
An: "Tapestry users" <us...@tapestry.apache.org>
Betreff: Re: @BeanForm How do you use it ???

> Hi,
> 
> What version are you using? Can you post the full stack trace? I looked at
> the source code and I don't really see how line 149 of BeanForm.java can
> cause a NPE...
> 
> Also, what library id are you using in the .application file? Those
> jwcid's
> should probably include the library id, no?
> 
> Take care,
> 
> Daniel
> 
> 
> On 1/18/07, munich@fantasymail.de <mu...@fantasymail.de> wrote:
> >
> > I have tried:
> >
> > <span jwcid="@BeanForm" bean="ognl:foo" properties="ognl:'name'"
> > save="listener:onSave" />
> >
> > as well as:
> >
> > <span jwcid="@BeanForm" bean="ognl:foo" beanProperties="ognl:'name'"
> > save="listener:onSave" />
> >
> > but it comes up with:
> >
> > ognl.OgnlException
> > beanProperties
> >
> > java.lang.NullPointerException
> > Stack Trace:
> >
> >     *
> com.domain.components.BeanForm.getBeanProperties(BeanForm.java:149)
> >
> > Any pointing in the right direction?
> >
> > Thanks!
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: @BeanForm How do you use it ???

Posted by D&J Gredler <dj...@gmail.com>.
Hi,

What version are you using? Can you post the full stack trace? I looked at
the source code and I don't really see how line 149 of BeanForm.java can
cause a NPE...

Also, what library id are you using in the .application file? Those jwcid's
should probably include the library id, no?

Take care,

Daniel


On 1/18/07, munich@fantasymail.de <mu...@fantasymail.de> wrote:
>
> I have tried:
>
> <span jwcid="@BeanForm" bean="ognl:foo" properties="ognl:'name'"
> save="listener:onSave" />
>
> as well as:
>
> <span jwcid="@BeanForm" bean="ognl:foo" beanProperties="ognl:'name'"
> save="listener:onSave" />
>
> but it comes up with:
>
> ognl.OgnlException
> beanProperties
>
> java.lang.NullPointerException
> Stack Trace:
>
>     * com.domain.components.BeanForm.getBeanProperties(BeanForm.java:149)
>
> Any pointing in the right direction?
>
> Thanks!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: No .page files ?

Posted by Simon Raveh <si...@sns-soft.com>.
It is probably using jdk 1.5 and tapestry annotation to specify all the 
page configuration information inside the java source.

Simon

munich@fantasymail.de wrote:
> I am playing around with a HoneycombLib generated Tapestry project....
> There is only an application file and no page files....just java classes - but it works. How come there are no page files anymore?
>
> In the appliction file it only says:
>
>     <meta key="org.apache.tapestry.page-class-packages" value="Domain.pages"/>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


No .page files ?

Posted by mu...@fantasymail.de.
I am playing around with a HoneycombLib generated Tapestry project....
There is only an application file and no page files....just java classes - but it works. How come there are no page files anymore?

In the appliction file it only says:

    <meta key="org.apache.tapestry.page-class-packages" value="Domain.pages"/>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org