Sorry for the barrage of emails.

It seems like when I changed the Post.toString() method, it changed all of my 
models in the blog page.  Also not sure why this happened.

Thanks for your patience.  I'm really trying to understand this.


On Sep 22, 2012, at 09:25, Stephen Walsh <step...@connectwithawalsh.com> wrote:

> On a related note to this original question.
> 
> Can someone explain the difference between the two lines below?
>       
>       listItem.add(new Label("when", new Model<Post>(blogPost)));
>       listItem.add(new Label("text", blogPost.getText()));
> 
> The first one gives me some random but predictable text: post.Post@497f079e
> The next gives me the actual text of the test post:text1
> 
> I'm not sure why it matters here.  In my details page as you can below, the 
> getters are being used to pull back the necessary data.
> 
> Thanks in advance.
> 
> On Sep 21, 2012, at 19:45, Stephen Walsh <step...@connectwithawalsh.com> 
> wrote:
> 
>> Got this resolved.  I missed a line in my Post class
>> 
>> add(this);
>> 
>> which adds the Post in question to the HashMap.
>> 
>> 
>> On Sep 21, 2012, at 08:38, Stephen Walsh <step...@connectwithawalsh.com> 
>> wrote:
>> 
>>> I attempted your solution Sebastien and did parameters.set("id", 43);  This 
>>> was one of the id's that was showing up in the link when I looked at the 
>>> status bar.  I still got the same error (string value exception) and it 
>>> also said something about a null pointer.  I'm at work and don't have the 
>>> stack trace, but I thought it might be helpful to provide more info.
>>>  
>>> Any other thoughts on this?  Thanks again.
>>>  
>>>  
>>> _____________
>>> Stephen Walsh
>>> 
>>> 
>>> 
>>> On Thu, Sep 20, 2012 at 4:46 PM, Stephen Walsh 
>>> <step...@connectwithawalsh.com> wrote:
>>> Are they not being set when the BlogDetails.link gives the blogPost
>>> object and it set page parameters there?
>>> 
>>> 
>>> 
>>> ______________________________
>>> Stephen Walsh
>>> 
>>> On Sep 20, 2012, at 14:23, Francois Meillet <francois.meil...@gmail.com> 
>>> wrote:
>>> 
>>> > I don't see where you set the parameters...
>>> > parameters.set("id", x);
>>> >
>>> > It has to be done somewhere.
>>> > If parameters.get("id") return null, as null can't be converted to long, 
>>> > you get the exception.
>>> >
>>> > François
>>> >
>>> >
>>> > Le 20 sept. 2012 à 21:16, Stephen Walsh <step...@connectwithawalsh.com> a 
>>> > écrit :
>>> >
>>> >> Thanks for responding.  That would make sense.  Is there any way to
>>> >> identify when or when it couldn't be converted?
>>> >>
>>> >> Does the array that I provided cause this issue?  In my Post class I
>>> >> followed the example code and have the class assigning ids as long.
>>> >>
>>> >> _______________________________________
>>> >> Stephen Walsh | http://connectwithawalsh.com
>>> >>
>>> >>
>>> >>
>>> >> On Thu, Sep 20, 2012 at 12:55 PM, Francois Meillet <
>>> >> francois.meil...@gmail.com> wrote:
>>> >>
>>> >>> parameters.get("id").toLong() throws this exception when id can't be
>>> >>> converted to long.
>>> >>>
>>> >>> François
>>> >>>
>>> >>>
>>> >>> Le 20 sept. 2012 à 19:06, Stephen Walsh <step...@connectwithawalsh.com> 
>>> >>> a
>>> >>> écrit :
>>> >>>
>>> >>>> I am new to Wicket and Java, so forgive any ignorance or lack of
>>> >>> information.
>>> >>>>
>>> >>>> I am modeling a blog type application after the Wicket Examples Library
>>> >>> application and have not had any luck passing the post id to the details
>>> >>> page.  I'm not using the user portion at this point because I'll be 
>>> >>> doing a
>>> >>> role based authorization later.
>>> >>>>
>>> >>>> The blog page populates the array that it is given and provides a link
>>> >>> to the detail page, but this is when the exception is thrown.  Any 
>>> >>> thoughts?
>>> >>>>
>>> >>>> Thanks!
>>> >>>>
>>> >>>> public abstract class BasePage extends WebPage {
>>> >>>>     /**
>>> >>>>      *
>>> >>>>      */
>>> >>>>     private static final long serialVersionUID = 1L;
>>> >>>>
>>> >>>>
>>> >>>>     private String pageTitle = "(no title)";
>>> >>>>
>>> >>>>     /**
>>> >>>>      *
>>> >>>>      * @return pageTitle
>>> >>>>      */
>>> >>>>     public final String getPageTitle() {
>>> >>>>
>>> >>>>             return pageTitle;
>>> >>>>     }
>>> >>>>
>>> >>>>     /**
>>> >>>>      *
>>> >>>>      * @param title
>>> >>>>      */
>>> >>>>     public final void setPageTitle(String title) {
>>> >>>>
>>> >>>>             pageTitle = title;
>>> >>>>     }
>>> >>>>
>>> >>>>     public BasePage() {
>>> >>>>
>>> >>>>             this(new PageParameters());
>>> >>>>     }
>>> >>>>
>>> >>>>     /**
>>> >>>>      *
>>> >>>>      * @param parameters
>>> >>>>      */
>>> >>>>     public BasePage(final PageParameters parameters) {
>>> >>>>
>>> >>>>             super(parameters);
>>> >>>>
>>> >>>>             add(new Label("title", new PropertyModel<String>(this,
>>> >>> "pageTitle")));
>>> >>>>             add(new BookmarkablePageLink("logo", Index.class));
>>> >>>>             add(new BookmarkablePageLink("home", Index.class));
>>> >>>>             add(new BookmarkablePageLink("news", Blog.class));
>>> >>>>             add(new BookmarkablePageLink("contact", ContactUs.class));
>>> >>>>             add(new BookmarkablePageLink("about", About.class));
>>> >>>>             add(new FooterPanel("social"));
>>> >>>>     }
>>> >>>>
>>> >>>>     /**
>>> >>>>      * Construct
>>> >>>>      *
>>> >>>>      * @param model
>>> >>>>      */
>>> >>>>     public BasePage(IModel<?> model) {
>>> >>>>
>>> >>>>             super(model);
>>> >>>>     }
>>> >>>>
>>> >>>> public class Blog extends BasePage {
>>> >>>>
>>> >>>>     /**
>>> >>>>      * Constructor
>>> >>>>      *
>>> >>>>      * @param params
>>> >>>>      */
>>> >>>>     public Blog(final PageParameters paramaters) {
>>> >>>>
>>> >>>>             setPageTitle("News");
>>> >>>>
>>> >>>>             //Add a list of blogPosts
>>> >>>>             final PageableListView<Post> listView;
>>> >>>>             add(listView = new PageableListView<Post>("blogPosts", new
>>> >>> PropertyModel<List<Post>>(this, "blogPosts"), 5) {
>>> >>>>
>>> >>>>                     @Override
>>> >>>>                     public void populateItem(final ListItem<Post>
>>> >>> listItem) {
>>> >>>>                             final Post blogPost =
>>> >>> listItem.getModelObject();
>>> >>>>                             listItem.add(BlogDetails.link("details",
>>> >>> blogPost, getLocalizer().getString("noPostTitle", this)));
>>> >>>>                             listItem.add(new Label("text", new
>>> >>> Model<Post>(blogPost)));
>>> >>>>                             listItem.add(new Label("tags", new
>>> >>> Model<Post>(blogPost)));
>>> >>>>                             listItem.add(removeLink("remove",
>>> >>> listItem));
>>> >>>>                             listItem.add(EditBlogPost.link("edit",
>>> >>> blogPost.getId()));
>>> >>>>                     }
>>> >>>>             });
>>> >>>>             add(new PagingNavigator("navigator", listView));
>>> >>>>     }
>>> >>>>
>>> >>>>     public List<Post> getBlogPosts() {
>>> >>>>             final List<Post> blogPosts = new ArrayList<Post>();
>>> >>>>
>>> >>>>             blogPosts.add(new Post("Post1", "text1", "tag1, tag2,
>>> >>> tag3"));
>>> >>>>             blogPosts.add(new Post("Post2", "text2", "tag1, tag2,
>>> >>> tag3"));
>>> >>>>             blogPosts.add(new Post("Post3", "text3", "tag1, tag2,
>>> >>> tag3"));
>>> >>>>             blogPosts.add(new Post("Post4", "text4", "tag1, tag2,
>>> >>> tag3"));
>>> >>>>             blogPosts.add(new Post("Post5", "text5", "tag1, tag2,
>>> >>> tag3"));
>>> >>>>             blogPosts.add(new Post("Post6", "text6", "tag1, tag2,
>>> >>> tag3"));
>>> >>>>             blogPosts.add(new Post("Post7", "text7", "tag1, tag2,
>>> >>> tag3"));
>>> >>>>             blogPosts.add(new Post("Post8", "text8", "tag1, tag2,
>>> >>> tag3"));
>>> >>>>             blogPosts.add(new Post("Post9", "text9", "tag1, tag2,
>>> >>> tag3"));
>>> >>>>             blogPosts.add(new Post("Post10", "text10", "tag1, tag2,
>>> >>> tag3"));
>>> >>>>
>>> >>>>             return blogPosts;
>>> >>>>
>>> >>>>     }
>>> >>>> }
>>> >>>>
>>> >>>> public class BlogDetails extends BasePage {
>>> >>>>
>>> >>>>     /**
>>> >>>>      *
>>> >>>>      * @param parameters
>>> >>>>      *                      PageParameters
>>> >>>>      * @throws StringValueConversionException
>>> >>>>      */
>>> >>>>     public BlogDetails(final PageParameters parameters) throws
>>> >>> StringValueConversionException {
>>> >>>>             this(Post.get(parameters.get("id").toLong()));
>>> >>>>     }
>>> >>>>
>>> >>>>     public BlogDetails(final Post blogPost) {
>>> >>>>             add(new Label("title", blogPost.getTitle()));
>>> >>>>             add(new Label("text", blogPost.getText()));
>>> >>>>             add(new Label("tags", blogPost.getTags()));
>>> >>>>             add(EditBlogPost.link("edit", blogPost.getId()));
>>> >>>>     }
>>> >>>>
>>> >>>>     /**
>>> >>>>      * Creates an external page link
>>> >>>>      *
>>> >>>>      * @param name
>>> >>>>      *            The name of the link component to create
>>> >>>>      * @param post
>>> >>>>      *            The post to link to
>>> >>>>      * @param noPostTitle
>>> >>>>      *            The title to show if post is null
>>> >>>>      * @return The external page link
>>> >>>>      */
>>> >>>>     public static BookmarkablePageLink<Void> link(final String name,
>>> >>> final Post blogPost, final String noPostTitle) {
>>> >>>>
>>> >>>>             final BookmarkablePageLink<Void> link = new
>>> >>> BookmarkablePageLink<Void>(name, BlogDetails.class);
>>> >>>>
>>> >>>>             if (blogPost != null) {
>>> >>>>
>>> >>>>                     link.getPageParameters().add("id",
>>> >>> blogPost.getId());
>>> >>>>                     link.add(new Label("title", new
>>> >>> Model<Post>(blogPost)));
>>> >>>>             }
>>> >>>>             else {
>>> >>>>
>>> >>>>                     link.add(new Label("title", noPostTitle));
>>> >>>>                     link.setEnabled(false);
>>> >>>>             }
>>> >>>>
>>> >>>>             return link;
>>> >>>>     }
>>> >>>> }
>>> >>>>
>>> >>>>
>>> >>>> ____________________________________
>>> >>>> Stephen Walsh | http://connectwithawalsh.com
>>> >>>
>>> >>>
>>> >>> ---------------------------------------------------------------------
>>> >>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>>> >>> For additional commands, e-mail: users-h...@wicket.apache.org
>>> >
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>>> > For additional commands, e-mail: users-h...@wicket.apache.org
>>> >
>>> 
>> 
> 

Reply via email to