You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by tsuresh <su...@hotmail.com> on 2008/01/13 08:34:58 UTC

Pass page parameters

Hello I have a list of users with links in class UserList. When I click the
link I need to display the  clicked name in another page (DisplayUser). My
code snippet is as follows. When i click the link i get the error : No get
method defined for class: class User expression: link. When I added get/set
methods for link in User class ,it threw NPE. What should I do,please help?

  add(new PropertyListView("rows", userList) {

            protected void populateItem(ListItem item) {
                User user= (User) item.getModelObject();
                item.add(new Link("link") {

                    public void onClick() {
                    User userSelected= (User)  getModelObject();
                     setResponsePage(new
DisplayUser(userSelected.getUserName()));
                    }
                }.add(new Label("name", user.getUserName())));
            }
        });
    }
-- 
View this message in context: http://www.nabble.com/Pass-page-parameters-tp14782931p14782931.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: Pass page parameters

Posted by Martijn Dashorst <ma...@gmail.com>.
You could also do:

add(new Link("foo", item.getModel()) {
});

Martijn

On Jan 13, 2008 9:29 AM, tsuresh <su...@hotmail.com> wrote:
>
> Ok I solved it. I changed the line
>  User userSelected= (User) getModelObject(); to
>   User userSelected= (User) getParent().getModelObject();
> The problem must have been no model set for link.
>
> tsuresh wrote:
> >
> > Hello I have a list of users with links in class UserList. When I click
> > the link I need to display the  clicked name in another page
> > (DisplayUser). My code snippet is as follows. When i click the link i get
> > the error : No get method defined for class: class User expression: link.
> > When I added get/set methods for link in User class ,it threw NPE. What
> > should I do,please help?
> >
> >   add(new PropertyListView("rows", userList) {
> >
> >             protected void populateItem(ListItem item) {
> >                 User user= (User) item.getModelObject();
> >                 item.add(new Link("link") {
> >
> >                     public void onClick() {
> >                     User userSelected= (User)  getModelObject();
> >                      setResponsePage(new
> > DisplayUser(userSelected.getUserName()));
> >                     }
> >                 }.add(new Label("name", user.getUserName())));
> >             }
> >         });
> >     }
> >
>
> --
> View this message in context: http://www.nabble.com/Pass-page-parameters-tp14782931p14783279.html
>
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.0 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0

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


Re: Pass page parameters

Posted by tsuresh <su...@hotmail.com>.
Ok I solved it. I changed the line  
 User userSelected= (User) getModelObject(); to
  User userSelected= (User) getParent().getModelObject();
The problem must have been no model set for link.

tsuresh wrote:
> 
> Hello I have a list of users with links in class UserList. When I click
> the link I need to display the  clicked name in another page
> (DisplayUser). My code snippet is as follows. When i click the link i get
> the error : No get method defined for class: class User expression: link.
> When I added get/set methods for link in User class ,it threw NPE. What
> should I do,please help?
> 
>   add(new PropertyListView("rows", userList) {
> 
>             protected void populateItem(ListItem item) {
>                 User user= (User) item.getModelObject();
>                 item.add(new Link("link") {
> 
>                     public void onClick() {
>                     User userSelected= (User)  getModelObject();
>                      setResponsePage(new
> DisplayUser(userSelected.getUserName()));
>                     }
>                 }.add(new Label("name", user.getUserName())));
>             }
>         });
>     }
> 

-- 
View this message in context: http://www.nabble.com/Pass-page-parameters-tp14782931p14783279.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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