You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by SEAN CHEN <bl...@gmail.com> on 2005/04/26 15:51:03 UTC

Foreach and EngineService can work together?

Hi,

Our application needs show a list of image stored in database.  We implemented
a EngineService to stream images in DB to the page, just like the ChartService 
did in the Tapestry sample application Workbench.  Separately, it is
working fine.
But here is problem when I put it in a Foreach component.

Briefly our implementation like following:

// service define in .application
<service name="StreamImage" class="com.company.service.StreamImageService"/>

// StreamImageService is similar to ChartService

// StreamImageAsset is similar to Chart

// ImageProvider is similar to IChartProvider have the method to the
image as byte[]
public byte[] getImage();

// html.
<table jwcid="@Foreach" source="ognl:images" value="ognl:eachImage">
  <tr><td>Name:</td>
        <td><span jwcid="@Insert" value="ognl:eachImage.name"/></td>
  </tr>
  <tr><td colspan="2"><span jwcid="@Image" image="ognl:imageContent"/></td>
  </tr>
</table>

// page specification.
  <property-specification name="eachImage" type="com.company.ImageDescriptor"
  />

// page class implements ImageProvider

    public abstract ImageDescriptor getEachImage();

    /**
     * return all images as a List.
     */
    public List getImages() {
         ....
    }

    public byte[] getImage() {
         
         String name = getEachImage().getName();  /// ---> here causes
problem in Foreach.
         //... get image from database based on the name.
         // stream it to byte[]
    }

    /**
     * the image asset.
     */
    public IAsset getImageContent() {

        return new StreamImageAsset(getPage().getRequestCycle(), this);
    }


But the problem is the return of getEachImage() in method public
byte[] getImage()
of Page class is Null!  I can get each image name as the Insert
Component did,  BUT
I can not get each image for the Image component because we use an
engine service
to create the IAsset?  Why? How to solve it?

Any idea?


Thanks a lot

Sean

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