You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by o1550762 <o1...@rtrtr.com> on 2012/10/12 01:00:34 UTC
Gallery for each article using hibernate
Hi!
I want to implement gallery for each article using hibernate, and how many
images per article should it have is not mandatory set by some value? I am
here for your opinion what is the best way to implement it, so any help is
greatly appreciated. Thanks in advance. :)
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Gallery-for-each-article-using-hibernate-tp5716817.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Gallery for each article using hibernate
Posted by Lance Java <la...@googlemail.com>.
Rather than tying yourself to hibernate, your gallery component should accept
a parameter of type AssetProvider (or similar name)
public interface AssetProvider {
public List<Asset> getAssets(int startIndex, int maxResults);
public int getAssetCount();
}
I'd probably wrap the component in a zone and use eventlinks for forward and
back which passed the page number in the event.
public class Gallery {
@Inject
private Zone galleryZone;
@Parameter(required=true)
private int itemsPerPage;
@Parameter(required=true)
private AssetProvider assetProvider;
@Property
private int currentPage;
public void onPageChange(int page) {
this.currentPage = currentPage;
return galleryZone.getBody();
}
public List<Assets> getAssets() {
int startIndex = itemsPerPage * currentPage;
return assetProvider.getAssets(startIndex, itemsPerPage);
}
public boolean isShowNext() {
// not tested ;)
return assetProvider.getAssetCount() < (itemsPerPage * currentPage);
}
public boolean isShowPrev() {
return currentPage > 0;
}
}
<t:zone id="galleryZone">
<t:loop source="assets" value="asset">
<${asset}>
</t:loop>
<t:if test="showPrev">
<t:eventlink event="pageChange" zone="galleryZone"
context="${currentPage - 1}">Prev</t:eventlink>
</t:if>
<t:if test="showNext">
<t:eventlink event="pageChange" zone="galleryZone"
context="${currentPage + 1}">Next</t:eventlink>
</t:if>
</t:zone>
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Gallery-for-each-article-using-hibernate-tp5716817p5716837.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Gallery for each article using hibernate
Posted by o1550762 <o1...@rtrtr.com>.
Thanks for the answers. I have chosen to go for LanceJava's solution, but
kcollasi code is very helpful and has contributed me greatly for better
understanding how Tapestry works. :)
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Gallery-for-each-article-using-hibernate-tp5716817p5716993.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org