BoundContentTag
astik <[email protected]>
| Newsgroups | gmane.comp.cms.infoglue.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi all,
I'm using BoundContentTag right now to retrieve explicitly bound
content to a component.
Unlike structure tags, there is no boolean value to set whether or not
we want tio retrieve protected content.
Even org.infoglue.deliver.taglib.content.ChildContentsTag filters
pagcontent to only retrieve accessible content (it use
ContentDeliveryController.isValidContent.
I have to restrict access to bound contents, so that i redefine a new
BoundContentTag to filters content :
public class BoundContentsTag extends ComponentLogicTag {
private static final long serialVersionUID = 7691467626787173363L;
private String propertyName;
private boolean useInheritance = true;
private boolean useRepositoryInheritance = true;
private boolean useStructureInheritance = true;
@SuppressWarnings("unchecked")
public int doEndTag() throws JspException {
List contentList = getComponentLogic().getBoundContents
(propertyName, useInheritance, useRepositoryInheritance,
useStructureInheritance);
TemplateController templateController = getController();
Database db;
try {
db = templateController.getDatabase();
} catch (SystemException e) {
throw new JspException(e);
}
Integer languageId = templateController.getLanguageId();
boolean useLanguageFallback = true;
boolean includeFolders = false;
InfoGluePrincipal infoGluePrincipal = templateController.getPrincipal
();
DeliveryContext deliveryContext =
templateController.getDeliveryContext();
List<ContentVO> resultList = new ArrayList<ContentVO>();
for (Object o : contentList) {
ContentVO content = (ContentVO) o;
try {
boolean isValid =
ContentDeliveryController.getContentDeliveryController().isValidContent
(db, content.getContentId(), languageId, useLanguageFallback,
includeFolders,
infoGluePrincipal, deliveryContext);
if (isValid) {
resultList.add(content);
}
} catch (Exception e) {
throw new JspException(e);
}
}
setResultAttribute(resultList);
return EVAL_PAGE;
}
public void setPropertyName(String propertyName) {
this.propertyName = propertyName;
}
public void setUseInheritance(boolean useInheritance) {
this.useInheritance = useInheritance;
}
public void setUseRepositoryInheritance(boolean
useRepositoryInheritance) {
this.useRepositoryInheritance = useRepositoryInheritance;
}
public void setUseStructureInheritance(boolean
useStructureInheritance) {
this.useStructureInheritance = useStructureInheritance;
}
}
I would gladly see a boolean value in the existing BoundContenttag to
do this for me =)
Even if I mainly use it to display accessible content, I may, someday,
need to display unaccessible content, that why I may like to have the
choice =)
__
Romain
http://blog.astik.info
------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf