You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Stephen Rufle <sr...@salmonllc.com> on 2009/11/05 20:08:43 UTC

Getting a handle to uiLabelMap in javascript

In an ftl file we can access a property/xml file value as follows
${uiLabelMap.CommonFollowingErrorsOccurred}

Is there a way to do something similar in a javascript function? In a 
separate thread Rishi pointed me to [0], but that only does a show/hide 
of a div that already has a message.

I am doing this

    function showAjaxError(data) {
        var errorMessageList = data['errorMessageList'];
        if (errorMessageList != null){
            var buffer = ['The Following Errors Occurred:'];
            for ( var i = 0; i < errorMessageList.size(); i ++){
                buffer.push(errorMessageList[i]);
            }
            var errorDiv = dojo.query('.ajaxErrorBox');
            errorDiv[0].innerHTML = buffer.join("<br/>");
            errorDiv.style('display', 'block');
        }
        else
        {
            var errorDiv = dojo.query('.ajaxErrorBox');
            errorDiv.style('display', 'none');
        }
    }

I wanted to replace the hard coded value of "The Following Errors 
Occurred:" with the ${uiLabelMap.CommonFollowingErrorsOccurred} from 
messages.ftl. Not sure how I could ever get that value since I realize 
its on the server side of things and I want the value in the client side 
javascript.

[0]https://demo.ofbiz.org/accounting/control/CostCenters

Re: Getting a handle to uiLabelMap in javascript

Posted by Adrian Crum <ad...@hlmksw.com>.
Yes.

-Adrian

Stephen Rufle wrote:
> Are the expand/collapse links you are talking about the ones on?
> https://demo.ofbiz.org/catalog/control/EditProduct?productId=WG-9943
> 
> Adrian Crum wrote:
>> You will have to pass all localized text to the JavaScript function. 
>> For an example, check out how the expand/collapse links are done.
>>
>> -Adrian
>>
>> Stephen Rufle wrote:
>>> In an ftl file we can access a property/xml file value as follows
>>> ${uiLabelMap.CommonFollowingErrorsOccurred}
>>>
>>> Is there a way to do something similar in a javascript function? In a 
>>> separate thread Rishi pointed me to [0], but that only does a 
>>> show/hide of a div that already has a message.
>>>
>>> I am doing this
>>>
>>>    function showAjaxError(data) {
>>>        var errorMessageList = data['errorMessageList'];
>>>        if (errorMessageList != null){
>>>            var buffer = ['The Following Errors Occurred:'];
>>>            for ( var i = 0; i < errorMessageList.size(); i ++){
>>>                buffer.push(errorMessageList[i]);
>>>            }
>>>            var errorDiv = dojo.query('.ajaxErrorBox');
>>>            errorDiv[0].innerHTML = buffer.join("<br/>");
>>>            errorDiv.style('display', 'block');
>>>        }
>>>        else
>>>        {
>>>            var errorDiv = dojo.query('.ajaxErrorBox');
>>>            errorDiv.style('display', 'none');
>>>        }
>>>    }
>>>
>>> I wanted to replace the hard coded value of "The Following Errors 
>>> Occurred:" with the ${uiLabelMap.CommonFollowingErrorsOccurred} from 
>>> messages.ftl. Not sure how I could ever get that value since I 
>>> realize its on the server side of things and I want the value in the 
>>> client side javascript.
>>>
>>> [0]https://demo.ofbiz.org/accounting/control/CostCenters
>>>
>>
>>
> 

Re: Getting a handle to uiLabelMap in javascript

Posted by Stephen Rufle <sr...@salmonllc.com>.
Are the expand/collapse links you are talking about the ones on?
https://demo.ofbiz.org/catalog/control/EditProduct?productId=WG-9943

Adrian Crum wrote:
> You will have to pass all localized text to the JavaScript function. 
> For an example, check out how the expand/collapse links are done.
>
> -Adrian
>
> Stephen Rufle wrote:
>> In an ftl file we can access a property/xml file value as follows
>> ${uiLabelMap.CommonFollowingErrorsOccurred}
>>
>> Is there a way to do something similar in a javascript function? In a 
>> separate thread Rishi pointed me to [0], but that only does a 
>> show/hide of a div that already has a message.
>>
>> I am doing this
>>
>>    function showAjaxError(data) {
>>        var errorMessageList = data['errorMessageList'];
>>        if (errorMessageList != null){
>>            var buffer = ['The Following Errors Occurred:'];
>>            for ( var i = 0; i < errorMessageList.size(); i ++){
>>                buffer.push(errorMessageList[i]);
>>            }
>>            var errorDiv = dojo.query('.ajaxErrorBox');
>>            errorDiv[0].innerHTML = buffer.join("<br/>");
>>            errorDiv.style('display', 'block');
>>        }
>>        else
>>        {
>>            var errorDiv = dojo.query('.ajaxErrorBox');
>>            errorDiv.style('display', 'none');
>>        }
>>    }
>>
>> I wanted to replace the hard coded value of "The Following Errors 
>> Occurred:" with the ${uiLabelMap.CommonFollowingErrorsOccurred} from 
>> messages.ftl. Not sure how I could ever get that value since I 
>> realize its on the server side of things and I want the value in the 
>> client side javascript.
>>
>> [0]https://demo.ofbiz.org/accounting/control/CostCenters
>>
>
>

-- 
Stephen P Rufle
srufle@salmonllc.com
H1:480-626-8022
H2:480-802-7173
Yahoo IM: stephen_rufle
AOL IM: stephen1rufle


Re: Getting a handle to uiLabelMap in javascript

Posted by Adrian Crum <ad...@hlmksw.com>.
You will have to pass all localized text to the JavaScript function. For 
an example, check out how the expand/collapse links are done.

-Adrian

Stephen Rufle wrote:
> In an ftl file we can access a property/xml file value as follows
> ${uiLabelMap.CommonFollowingErrorsOccurred}
> 
> Is there a way to do something similar in a javascript function? In a 
> separate thread Rishi pointed me to [0], but that only does a show/hide 
> of a div that already has a message.
> 
> I am doing this
> 
>    function showAjaxError(data) {
>        var errorMessageList = data['errorMessageList'];
>        if (errorMessageList != null){
>            var buffer = ['The Following Errors Occurred:'];
>            for ( var i = 0; i < errorMessageList.size(); i ++){
>                buffer.push(errorMessageList[i]);
>            }
>            var errorDiv = dojo.query('.ajaxErrorBox');
>            errorDiv[0].innerHTML = buffer.join("<br/>");
>            errorDiv.style('display', 'block');
>        }
>        else
>        {
>            var errorDiv = dojo.query('.ajaxErrorBox');
>            errorDiv.style('display', 'none');
>        }
>    }
> 
> I wanted to replace the hard coded value of "The Following Errors 
> Occurred:" with the ${uiLabelMap.CommonFollowingErrorsOccurred} from 
> messages.ftl. Not sure how I could ever get that value since I realize 
> its on the server side of things and I want the value in the client side 
> javascript.
> 
> [0]https://demo.ofbiz.org/accounting/control/CostCenters
>