Hello,

I have implemented a custom component to display (Blob) images. While it
works without a problem inside BeanEditForm and BeanDisplay, inside a Grid a
NullPointerException occurs while trying to pass a property of the actual
object (row) at the grid as a parameter to the component.

The relevant parts of the code:

Image.java (component)
******************
public class Image
{
    ...
    @Parameter
    private Blob data;

    public Link getSrc()
    {
        return resources.createEventLink("displayImage", new Object[]{});
    }

    StreamResponse onDisplayImage()
    {
        return new StreamResponse() {
            public String getContentType()
            {
                return "image/jpeg";
            }

            public InputStream getStream() throws IOException
            {
                try {
                    return data.getBinaryStream();
                }
                catch (SQLException e) {
                    throw new IllegalArgumentException(e);
                }
            }

            public void prepareResponse(Response response)
            {
            }
        };
    }
}

Image.tml
*******
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
    < img ... src="${src}"...>
</html>


Edit.tml (page)
***********
...
<t:beaneditform t:id="BookEdit" object="book" model="model"
...
            <t:parameter name="mediumImage">
                <t:image id="literal:book-image-register"
t:alt="literal:bookImage"
                         t:data="book.mediumImage"/>
            </t:parameter>
...
</t:beaneditform>
...

In this page (Edit.tml) there is no problem, and the mediumImage of the book
is passed successfully to the Image component, and displayed. However,
below...


Search.tml (page)
*************
...
<t:grid t:id="BookEdit" t:source="books" row="book" model="model"
...
            <t:parameter name="smallImageCell">
                <t:image id="literal:book-image-register"
t:alt="literal:bookImage"
                         t:data="book.smallImage"/>
            </t:parameter>

            <t:parameter name="titleCell">
                    <t:pageLink t:page="detail"
context="book.id">${book.title}</t:pageLink>
            </t:parameter>
            <t:parameter name="authorsCell">
                 <t:loop source="book.authors" value="author">
                   <div>* ${author.name}</div>
                 </t:loop>
            </t:parameter>
</t:grid>
...

Here (Search.tml), inside the Grid, always NullPointerException is thrown
with the message: "Property 'book' is null in (book.smallImage)". While
there is no problem with the "book.id", "book.title", "book.authors"...

Might this be somehow a problem in tapestry, or am I missing sth. (which is
perhaps more probable)?

Thanks a lot,
iren
-- 
View this message in context: 
http://n2.nabble.com/-T5.0.18--Bug--%3A-Null-property-problem-with-the-custom-component-inside-a-grid-tp2324166p2324166.html
Sent from the Tapestry Users mailing list archive at Nabble.com.


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

Reply via email to