|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
How to get collection for field editorI have created a field editor so that I can have a field where the pulldown list values are based on the collection name for the document being edited. I have the field editor working and it creates my custom pulldown list but I can't figure out how to get the collection name before I populate the list. I see there is a Context object that probably has the value I need but I am not sure how to get the value from the Context.
I got the collection name from the load(Document document) method of the FieldEditor interface but this is called after the init method where I set the list values. I later found that this method is not even called if there is not already a value in the field (from comments and log messages). Any help on how to get to the collection in the init method of the FieldEditor is appreciated. Thanks, Lou |
|
|
Re: How to get collection for field editorIt took me a little while to figure this out but I have it now. The key part I was missing was to get the objectModel from the Cocoon context. I found this by looking through the daisy code. Once I found that I was able to find what I needed through log statements and crawling the the objects within the objectModel. This code in case anyone else needs something similar is here:
private String getCollectionName() { String collectionName = null; try { Map objectModel = ContextHelper.getObjectModel(context); HttpRequest request = (HttpRequest) objectModel.get("request"); SiteConf siteConf = (SiteConf) request.getAttribute("siteConf"); collectionName = siteConf.getName(); } catch (Exception e) { logger.error("Exception getting collection name in FunctionalAreaFieldEditor.", e); } logger.debug("collection name from FunctionalAreaFieldEditor is " + collectionName); return collectionName; }
|
|
|
Re: How to get collection for field editorIf your field editor inherits from the AbstractFieldEditor then you have a documentContext to work from. In the document context you will find the pagecontext which contains the siteconf so no need to go looking in the request attributes.
If you aren't inheriting from the AbstractFieldEditor you can use the WikiHelper class to help you get the siteconf. WikiHelper.getSiteConf(request); Paul On Sat, Sep 5, 2009 at 12:12 AM, Lou Parisi <Lou.Parisi@...> wrote:
_______________________________________________ daisy community mailing list Professional Daisy support: http://outerthought.org/en/services/daisy/support.html mail to: daisy@... list information: http://lists.cocoondev.org/mailman/listinfo/daisy |
| Free embeddable forum powered by Nabble | Forum Help |