It sounds like currentPhoto.id is returning the string "images" and
"classes" rather than a Long.  Might want to check the return type and value
of the getId() method of your Photo class.  I'd be tempted to put a debug
breakpoint in getId() somewhere and watch the value being returned.

On Thu, May 1, 2008 at 7:53 AM, Toby Hobson <[EMAIL PROTECTED]>
wrote:

> I have a strange problem with the pagelink component. I am trying to
> navigate from the start page to the ViewPhoto page but I get an exception:
>
> [ERROR] RequestExceptionHandler Processing of request failed withuncaught
> exception: Exception in
> methodcom.thc.web.pages.ViewPhoto.onActivate(java.lang.Long)
> (atViewPhoto.java:18), parameter #1: Coercion of images to
> typejava.lang.Long (via String --> Long) failed: For input string:"images"
> org.apache.tapestry.runtime.ComponentEventException: Exception inmethod
> com.thc.web.pages.ViewPhoto.onActivate(java.lang.Long)
> (atViewPhoto.java:18), parameter #1: Coercion of images to
> typejava.lang.Long (via String --> Long) failed: For input string:"images"
>    at
> org.apache.tapestry.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageElementImpl.java:1021)
> ...
>
> and
>
> [ERROR] RequestExceptionHandler Processing of request failed withuncaught
> exception: Exception in
> methodcom.thc.web.pages.ViewPhoto.onActivate(java.lang.Long)
> (atViewPhoto.java:18), parameter #1: Coercion of styles to
> typejava.lang.Long (via String --> Long) failed: For input string:"styles"
> org.apache.tapestry.runtime.ComponentEventException: Exception inmethod
> com.thc.web.pages.ViewPhoto.onActivate(java.lang.Long)
> (atViewPhoto.java:18), parameter #1: Coercion of styles to
> typejava.lang.Long (via String --> Long) failed: For input string:"styles"
>    at
> org.apache.tapestry.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageElementImpl.java:1021
>
> I think it's because tapestry is interpreting the ref to styles/style and
> images/x.jpg (in layout.tml) as params to the onActivate method. Do I have
> to use a special tapestry tag for any hrefs in my templates? The page
> renders without any problems if I leave out the onActivate method.
>
> Here's the relevant code
>
> Start.tml:
>
> <t:pagelink page="viewPhoto" context="currentPhoto.id">
> <img alt="#" src="${currentPhoto.imageResource.resource}"
> width="64"height="64" />
> </t:pagelink>
>
> ViewPhoto.java:
>
> package com.thc.web.pages;
> ...
> public class ViewPhoto {
>
>    private Photo photo;
>
>    @Inject
>    private PhotoDao photoDao;
>
>    private Long imageId;
>
>    void onActivate(Long imageId) {
>        this.imageId = imageId;
>        photo = photoDao.findImageById(imageId);
>    }
>
>    Long onPassivate() { return imageId }
>
>    public Photo getPhoto() {
>        return photo;
>    }
>
>    public void setPhoto(Photo photo) {
>        this.photo = photo;
>    }
>
> }
>
> layout.tml
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> <title>Blotterpad</title>
> <link href="styles/style.css" rel="stylesheet" type="text/css" />
> </head>
> <body>
> <form action="#">
> <div id="container">
>    <div id="header">
>  <t:pagelink page="start"><img alt="#" src="images/art_Logo.gif"
> width="269" height="92" /></t:pagelink></div>
>  <div id="login"><a href="#"><img alt="#" src="images/btn_home.jpg"
> width="11" height="10" /></a> | <a href="#"><img alt="#"
> src="images/btn_contact.jpg" width="11" height="8" /></a></div>
>    <div class="clear"></div>
>    <div id="navcontainer">
>    <div style="float:right;"><img alt="#" src="images/art_navbg_right.jpg"
> width="6" height="31" /></div>
>      <div class="menutop">
>        <ul id="cssdropdown">
>          <li class="mainitems"><a t:type="pagelink" page="Start"
> href="#">Home</a></li>
>          <li class="mainitems"><a t:type="pagelink" page="MyPhotos"
> href="#">My Photos</a></li>
>          <li class="mainitems"><a t:type="pagelink" page="MyEditions"
> href="#">My Artwork</a></li>
>          <li class="mainitems"><a t:type="pagelink" page="MyFavourites"
> href="#">My Favorites</a></li>
>          <li class="mainitems"><a t:type="pagelink" page="Search"
> href="#">Search</a></li>
>          <li class="mainitems"><a t:type="pagelink" page="MyAccount"
> href="#">MyAccount</a></li>
>        </ul>
>      </div>
>    </div>
>
>   <!-- content here -->
>   <t:body />
>
>  <div class="clear"></div>
>  <div class="clear"></div>
>  <div id="footer">
>    <div id="navcontainer2">
>        <ul id="navlist">
>        <li><a href="#">Home</a></li>
>        <li><a href="#">Registration</a></li>
>        <li><a href="#">My Galleries</a></li>
>        <li><a href="#">My Favourites</a></li>
>        <li><a href="#">My Editions</a></li>
>        <li><a href="#">My Account</a></li>
>        <li><a href="#">View photo</a></li>
>        <li style="border:0px!important;"><a href="#">Contact Us</a></li>
>        </ul>
>    </div>
> <p style="padding:10px 0px;"><strong>Blotterpad</strong> 2007.All Rights
> reserved</p>
>  </div>
> </div>
> </form>
> </body>
> </html>
>
> The start page generates a link in the form http://myapp/viewphoto/1 as I
> would expect but when i click on the link i get the exception
>
> Thanks!
>
>


-- 
Bill @ PeoplePad

Reply via email to