Hi Philippe,

Thanks for the prompt response. Unfortunately your example does not help
me. For me it stops at:

jParams.getSession().getAttribute("jahia_session_engineMap");

There is no attribute "jahia_session_engineMap" in the Session. My
session contains the following attributes:

attr: 10_5_nieuwsContainer9_search_handler
attr: 6_8_siteSettings_filter_handler
attr: org.jahia.services.multilang.currentlocale
attr: 13_5_nieuwsContainer12_search_handler
attr: 12_8_nieuwsContainer11_filter_handler
attr: 12_5_nieuwsContainer11_search_handler
attr: 11_5_nieuwsContainer10_filter_handler
attr: fiUser
attr: org.jahia.usermanager.jahiauser
attr: 6_8_siteSettings_sort_handler
attr: 8_5_topMenu_sort_handler
attr: 6_8_siteSettings_search_handler
attr: 8_8_topMenu_search_handler
attr: 10_8_nieuwsContainer9_search_handler
attr: 8_5_topMenu_filter_handler
attr: 11_8_nieuwsContainer10_sort_handler
attr: 11_5_nieuwsContainer10_search_handler
attr: 6_5_siteSettings_sort_handler
attr: 13_8_nieuwsContainer12_filter_handler
attr: 8_8_topMenu_filter_handler
attr: 11_5_nieuwsContainer10_sort_handler
attr: 12_5_nieuwsContainer11_filter_handler
attr: 10_8_nieuwsContainer9_filter_handler
attr: org.jahia.engines.lastenginename
attr: 12_8_nieuwsContainer11_sort_handler
attr: org.apache.struts.action.LOCALE
attr: op
attr: 6_9_siteSettings_filter_handler
attr: 11_8_nieuwsContainer10_filter_handler
attr: 6_5_siteSettings_filter_handler
attr: 12_8_nieuwsContainer11_search_handler
attr: 8_9_topMenu_filter_handler
attr: 8_9_topMenu_sort_handler
attr: 13_5_nieuwsContainer12_filter_handler
attr: 8_9_topMenu_search_handler
attr: 12_5_nieuwsContainer11_sort_handler
attr: 6_9_siteSettings_sort_handler
attr: org.jahia.services.sites.jahiasite
attr: 8_5_topMenu_search_handler
attr: org.jahia.params.lastrequestedpageid
attr: 10_5_nieuwsContainer9_sort_handler
attr: LastPageID
attr: 10_5_nieuwsContainer9_filter_handler
attr: 13_8_nieuwsContainer12_sort_handler
attr: 6_9_siteSettings_search_handler
attr: 11_8_nieuwsContainer10_search_handler
attr: 13_5_nieuwsContainer12_sort_handler
attr: 10_8_nieuwsContainer9_sort_handler
attr: 8_8_topMenu_sort_handler
attr: 6_5_siteSettings_search_handler
attr: 13_8_nieuwsContainer12_search_handler

Should this example work for my version of Jahia? Or do I have to put
the session engine in the Session explicitly?

thanks,
Hilbert

On Wed, 2005-12-21 at 15:01 +0100, Philippe Vollenweider wrote:
> Hello,
> 
> You can use an eventlistner to set a default value if no value has 
> been set in the engine. Here is an example where the value set is the 
> actual time.
> 
> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
> <%@ page import="java.util.*" %>
> <%@ page import="org.jahia.content.*" %>
> <%@ page import="org.jahia.data.*" %>
> <%@ page import="org.jahia.data.containers.*" %>
> <%@ page import="org.jahia.data.fields.*" %>
> <%@ page import="org.jahia.data.events.*" %>
> <%@ page import="org.jahia.engines.*" %>
> <%@ page import="org.jahia.engines.categories.*" %>
> <%@ page import="org.jahia.engines.selectpage.*" %>
> <%@ page import="org.jahia.engines.shared.*" %>
> <%@ page import="org.jahia.params.*" %>
> <%@ page import="org.jahia.registries.*" %>
> <%@ page import="org.jahia.services.categories.*" %>
> <%@ page import="org.jahia.services.containers.*" %>
> <%@ page import="org.jahia.services.database.*" %>
> <%@ page import="org.jahia.services.fields.*" %>
> <%@ page import="org.jahia.services.pages.*" %>
> <%@ page import="org.jahia.services.version.*" %>
> <jsp:useBean id="eventsToTrap" class="java.util.Vector" scope="application"/>
> <%// loads the events to trap
> if (eventsToTrap.size() == 0) {
>          eventsToTrap.add("addContainerEngineAfterInit");
>          eventsToTrap.add("addContainerEngineBeforeSave");
>          eventsToTrap.add("containerAdded");
>          eventsToTrap.add("containerUpdated");
> }
> 
> String eventName = (String) request.getAttribute("eventName");
> JahiaEvent jahiaEvent = (JahiaEvent) request.getAttribute("jahiaEvent");
> ParamBean jParams = jahiaEvent.getParams();
> 
> if ( eventsToTrap.contains(eventName)){
>          HashMap engineMap =
>              (HashMap) jParams.getSession().getAttribute( 
> "jahia_session_engineMap" );
>          if (engineMap == null) { return; }
>          String languageCode = (String)engineMap.get("languageCode");
>          HashSet updatedFields = (HashSet)engineMap.get("updated.fields");
>      if (updatedFields == null) {
>              updatedFields = new HashSet();
>              engineMap.put("updated.fields", updatedFields);
>          }
>          JahiaContainer theContainer = (JahiaContainer)jahiaEvent.getObject();
> 
>      if ( "yourContainer".equals(theContainer.getDefinition().getName()) ){
>          if ( "addContainerEngineAfterInit".equals(eventName) ) {
>              JahiaField theField = theContainer.getField("yourDate");
>              if (theField.getObject() == null) {
>                  Calendar cal = 
> Calendar.getInstance(TimeZone.getTimeZone("UTC"));
>                  long now = cal.getTime().getTime();
>                  String nowStr = String.valueOf(now);
>                  theField.setObject(nowStr);
>                  updatedFields.add(new Integer(theField.getID()));
>              }
>          }
>      }
> }
> %>
> 
> Cheers,
> 
> Philippe.
> 
> At 21.12.2005 14:53, you wrote:
> 
> >Hi all,
> >
> >This example has been tried with Jahia 4.0.4.
> >I'm trying to set a default value to a jahia calendar as follows:
> >
> >         java.text.DateFormat dateFormat = new
> >java.text.SimpleDateFormat("dd MMM yyyy / HH:mm");
> >         String publicatieDatum = "<jahia_calendar[dd mon yyyy / HH:MM]>"
> >+ dateFormat.format(new Date());
> >
> >So, the string will look like:
> >
> >"<jahia_calendar[dd mon yyyy / HH:MM]>21 Dec 2005 / 14:48"
> >
> >This should be possible according to the following description:
> >
> >A special tag ("<jahia_calendar[DateFormat]>") to set the date format,
> >followed by a default value.
> >
> >In fact, I *do* see the default value in the date field, however, it is
> >not stored (the date is the publication date of an article).
> >
> >Do I do something wrong, or is this a bug in Jahia?
> >
> >
> >thanks,
> >Hilbert
> 
> -------=[ pvollenweider at jahia dot com ]=---------
> Jahia : A collaborative source CMS and Portal Server
> www.jahia.org Community and product web site
> www.jahia.com Commercial services company
> 
-- 
Drs. Hilbert Schraal
Senior developer

Wisdom
Helperpark 288
9723 ZA GRONINGEN

T + 31 [0]50 368 88 88
F + 31 [0]50 368 88 87
M + 31 [0]65 381 45 82
W www.wisdom.nl

Met ingang van 8 augustus 2005 is de Wisdom Groep (Wisdom en The Missing
Link) gevestigd in de Mediacentrale in Groningen.

Reply via email to