Re: default values for fields at runtime
"Juan A. Nervion" <[email protected]>
| Newsgroups | gmane.comp.cms.jahia.template |
|---|---|
| Message-ID | <001701c41746$c6952830$32fa25d5@micasa> |
----- Original Message ----- From: "Jurjan-Paul Medema" <[email protected]> To: <[email protected]> Sent: Wednesday, March 31, 2004 10:49 AM Subject: Re: default values for fields at runtime > Phillippe, > > Thanks a lot for this great example and pointer! > > I have to study it a little further before I know exactly how to apply > this stuff (especially with respect to the JavaScript part), but with > this as reference I should be able to work this out. > > Yours, > Jurjan-Paul > > Philippe Vollenweider wrote: > > > Hello, > > > > You should better overide some engine jsp code. > > > > Here is a simple exemple for the field metaDataCreationDate. > > First we specify which jsp we want to use in the add/update Container > > engine > > > > String templatesPath = jParams.settings().getJspContext() + > > "templates/" > > + > > jParams.getSite().getSiteKey() + "/corporate_portal_templates/"; > > > > jData.containers().declareFieldDefProp("metaDataCreationDate", > > > > JahiaFieldDefinitionProperties.FIELD_UPDATE_JSP_FILE_PROP, > > templatesPath + "metadata_dates.jsp"); > > > > Then we declare the container. > > > > jData.containers().declareField( "metaDataCreationDate", "Creation > > Date", FieldTypes.DATE, "<jahia_calendar[dd.mm.yyyy / HH:MM]>" ); > > Vector directoryDocFields = new Vector(); > > directoryDocFields.add( "metaDataCreationDate" ); > > jData.containers().declareContainer( "directoryDocContainer", "Doc > > container", directoryDocFields ); > > > > In metadata_dates.jsp we include the original engine jsp file. But > > after this include you can do what you want, like reaffect some values: > > > > <%@ include file="/jsp/jahia/engines/shared/date_field.jsp"%> > > <SCRIPT type="text/javascript"> > > <!-- > > > > function setValue(txt) { > > > > // We don't report changes because this date value is set > > automatically > > // document.mainForm.datebox.value = txt; > > // var UTC = Date.UTC(document.mainForm.dateYear.value, > > document.mainForm.dateMonth.options[document.mainForm.dateMonth.selectedInde x].value, > > gDay, gHH, gMM, 0, 0); > > // document.mainForm.elements["_<%=theField.getID()%>"].value > > = UTC; > > // > > document.mainForm.elements["_Str<%=theField.getID()%>"].value = txt; > > alert("Sorry, this date is set automatically"); > > > > } > > > > //--> > > </SCRIPT> > > > > > > Please look at the addcontainer engine to see how it exactly works. > > > > Cheers, > > > > Philippe > > > > At 24.03.2004 13:18, you wrote: > > > >> Hello list, > >> > >> I would like to specify default values for container fields in a new > >> container at runtime (the moment before the engine is openened) > >> rather than at 'field declaration time'. > >> > >> Do I need to use an event listener for that? > >> Can somebody point me to an example of how to accomplish this? > >> > >> Thanks a lot! > >> Jurjan-Paul > >> > >> -- > >> ----- ---- --- -- - - - - - - - - > >> J.P. Medema > >> E: [email protected] > >> ----- ---- --- -- - - - - - - - - > >> > >> > > > > -------=[ 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 > > > > > > > > > > -- > ----- ---- --- -- - - - - - - - - > J.P. Medema > E: [email protected] > ----- ---- --- -- - - - - - - - - >