Hi all,
I want to use the uiLabelMap variable in a .js I've created in order to set the defaults of any sort for jQuery plugins like validator. To do that I just included this in the main-decorator (CommonScreens.xml): <set field="layoutSettings.javaScripts[]" value="/images/defaults.js" global="true"/> In this file I put the code like that: jQuery.extend(jQuery.validator.messages, { required: '${uiLabelMap.EcommerceRequired}' }); Of course, this is not properly rendered, so the question is: Would you put all the javascript code in the header.ftl for example? Thanks in advance. Regards, Jonatan Soto |
Hi Jonatan,
you can't put label tags in js files, because they are interpreted by the freemarker parser, which don't parse js files. Some month ago, i created a JS function which can resolve ui Label tags. You can find it in the selectall.js There are two functions, one which takes an JSON array with ui label information and one which only takes a resource and one label. /** * Reads the requiered uiLabels from the uiLabelXml Files * @param requiredLabels JSON Object {resource : [label1, label2 ...], resource2 : [label1, label2, ...]} * @return JSON Object */ function getJSONuiLabels(requiredLabels) { /** * Read the requiered uiLabel from the uiLabelXml Resource * @param uiResource String * @param errUiLabel String * @returns String with Label */ function getJSONuiLabel(uiResource, errUiLabel) { Hope that helps. Have a good day Sascha 2011/7/12 Jonatan Soto <[hidden email]> > Hi all, > > I want to use the uiLabelMap variable in a .js I've created in order to set > the defaults of any sort for jQuery plugins like validator. To do that I > just included this in the main-decorator (CommonScreens.xml): > > <set field="layoutSettings.javaScripts[]" value="/images/defaults.js" > global="true"/> > > In this file I put the code like that: > > jQuery.extend(jQuery.validator.messages, { > required: '${uiLabelMap.EcommerceRequired}' > }); > > > Of course, this is not properly rendered, so the question is: Would you put > all the javascript code in the header.ftl for example? > > Thanks in advance. > > Regards, > > Jonatan Soto > -- Sascha Rodekamp Visit the new german OFBiz Blog: http://www.ofbiz.biz Lynx-Consulting GmbH Johanniskirchplatz 6 D-33615 Bielefeld http://www.lynx.de |
Thanks a lot Sasha!
On Wed, Jul 13, 2011 at 7:52 AM, Sascha Rodekamp <sascha.rodekamp.lynx.de@ googlemail.com> wrote: > Hi Jonatan, > you can't put label tags in js files, because they are interpreted by the > freemarker parser, which don't parse js files. > > Some month ago, i created a JS function which can resolve ui Label tags. > You > can find it in the selectall.js > There are two functions, one which takes an JSON array with ui label > information and one which only takes a resource and one label. > > /** > * Reads the requiered uiLabels from the uiLabelXml Files > * @param requiredLabels JSON Object {resource : [label1, label2 ...], > resource2 : [label1, label2, ...]} > * @return JSON Object > */ > function getJSONuiLabels(requiredLabels) { > > /** > * Read the requiered uiLabel from the uiLabelXml Resource > * @param uiResource String > * @param errUiLabel String > * @returns String with Label > */ > function getJSONuiLabel(uiResource, errUiLabel) { > > Hope that helps. > > Have a good day > Sascha > > > 2011/7/12 Jonatan Soto <[hidden email]> > > > Hi all, > > > > I want to use the uiLabelMap variable in a .js I've created in order to > set > > the defaults of any sort for jQuery plugins like validator. To do that I > > just included this in the main-decorator (CommonScreens.xml): > > > > <set field="layoutSettings.javaScripts[]" value="/images/defaults.js" > > global="true"/> > > > > In this file I put the code like that: > > > > jQuery.extend(jQuery.validator.messages, { > > required: '${uiLabelMap.EcommerceRequired}' > > }); > > > > > > Of course, this is not properly rendered, so the question is: Would you > put > > all the javascript code in the header.ftl for example? > > > > Thanks in advance. > > > > Regards, > > > > Jonatan Soto > > > > > > -- > > Sascha Rodekamp > Visit the new german OFBiz Blog: http://www.ofbiz.biz > Lynx-Consulting GmbH > Johanniskirchplatz 6 > D-33615 Bielefeld > http://www.lynx.de > -- ----- Jonatan Soto |
Free forum by Nabble | Edit this page |