|
Hello Jerome, so you have a main container list, where the containers can hold a sub container list. A field in the sub container list should be preset with a dynamic value depending on a field in its parent container. What you should NOT do is to set a changing value in <content:declareField value=...>, because these declarations must be constant (see the Template Developer Guide for more explanations section "Declaration scope"). If you want to have dynamic default values you may use JEXL expressions for simple requirements (also explained in the Template Developer Guide) or you can do it within the eventlistener.jsp. For instance there is an example in the corporate_portal_templates_v2 blogs\eventlistener.inc, where the "blogAuthor" field is set dynamically, like this: if ( "blogEntries".equals(theContainer.getDefinition().getName()) ){ if ( "addContainerEngineAfterInit".equals(eventName) ) { logger.debug("Start eventlistner for event addContainerEngineAfterInit for entries Container List"); JahiaField theField = theField = theContainer.getField("blogAuthor"); if (theField.getValue() == null || "".equals(theField.getValue())) { String author = jParams.getUser().getUsername(); theField.setValue(author); feh.addUpdatedField(theField.getID(), theField.getLanguageCode()); updatedFields.add(new Integer(theField.getID())); logger.debug("Set value for field [blogAuthor] to [" + theField.getValue() + "]"); } } Although this example would be better solved with a JEXL _expression_ <content:declareField ... value='<jahia-_expression_ expr="currentUser.username" storeMarker="false"/>'/> it is just to demonstrate how it could be done with eventlisteners. In your case, you would need to get ContentContainer parentContainer = theContainer.getContentContainer().getParent(jParams.getEntryLoadRequest()).getParent(jParams.getEntryLoadRequest()) to get the parent container list and then the parent container. With JahiaContainer parentJahiaContainer = parentContainer.getJahiaContainer(jParams, jParams.getEntryLoadRequest()) you will get the current parent container revision (depending on language, workflow) and on that object you can get the wanted field with parentJahiaContainer.getFieldValue("parentFieldName"). Regards, Benjamin On 25.09.2008 12:59 OFFROY, Jerome wrote:
|
_______________________________________________ template_list mailing list [email protected] http://lists.jahia.org/cgi-bin/mailman/listinfo/template_list
