Hi,
you can put the localized messages into a javascript object.
Different languages into different files like java resourceBundles.
e.g.:
-------- file messages_en.js ------------------------
var Messages = {
required: "Value required",
invalid: "Invalid Value"
}
-------- /file messages_en.js ------------------------
-------- file messages_de.js ------------------------
var Messages = {
required: "Wert wird benötigt",
invalid: "Ungültiger Wert"
}
-------- /file messages_de.js ------------------------
add the relevant file:
<tc:script file="messages_#{facesContext.viewRoot.locale.language}.js" />
and use this in your script:
alert(Messages.required);
Regards,
Volker
2007/3/12, madan chowdary <[EMAIL PROTECTED]>:
Hi Volker,
I Tried the same with onclick attribute in <tc:button/>
<tc:button action="#{order.buyOrder}" onclick="validateForm"
id="buyAction"/>
<tc:script>
function validateForm(){
var element = document.getElementById(<id>);
if(element.value == ""){
alert(" Value required "); ///////---> Need Internationalization
here (English , Spanish etc..)
}
else{
tobago.submitAction('page:buyAction',true);
}
}
</tc:script>
The above code worked fined, but the problem is the text in the alert
message should be in i18n format.
This is the problem i am facing.
Regards,
Madan
----- Original Message ----
From: Volker Weber <[EMAIL PROTECTED]>
To: MyFaces Discussion <[email protected]>
Sent: Monday, 12 March, 2007 3:25:40 PM
Subject: Re: [ Tobago ] No Page Refresh while validation
Hi,
you need to wait for the next nightly build, or build tobago yourself
from current sources.
<tc:script onsubmit="doValidation();">
function doValidation() {
// do your validation stuff here. e.g.
var element = document.getElementById(<id>);
if (element.value == "" ) {
alert("value is required for " + <id>);
// return false for cancel submitting
return false;
}
// return true for continue submitting
return true;
}
</tc:script>
Regards,
Volker
2007/3/12, madan chowdary <[EMAIL PROTECTED]>:
>
> Hi Volker,
>
> Can u explain with an example.
>
> Regards,
> Madan
>
> ----- Original Message ----
> From: Volker Weber <[EMAIL PROTECTED]>
> To: MyFaces Discussion <[email protected]>
> Sent: Monday, 12 March, 2007 2:50:22 PM
> Subject: Re: [ Tobago ] No Page Refresh while validation
>
> Hi Madan,
>
> i just commited the ability to add javascript functions for executing on
> submit
> https://issues.apache.org/jira/browse/TOBAGO-311
>
> you can use this for your client-side validation.
>
> Regards,
> Volker
>
> 2007/3/11, madan chowdary <[EMAIL PROTECTED]>:
> >
> > Hi Jorn,
> >
> > Can u please explain with a simple example .
> >
> > There are many validations i should be doing in the same form wihout
> > refreshing my page.
> >
> > Some of the validations are as such,
> > 1) All the fields are required.
> > 2) Address Validation, which should be done using an Ajax call to
NRGSoft,
> > which is a paid service for address validation.
> > 3) Have to check if the details entered by the user already exists in
the
> > DB, so have to use the renderPartially and get back the result.
> >
> > So i need to alert the user if any of these fails. and it should be done
> > through JavaScript Alert.
> >
> > I tried to place the results which come back with Ajax request in
> > <tc:hidden/> . but based upon the conditions i need to set the value. As
> > there's no " rendered " attribute i was not able to use this hidden.
> >
> > >> You'd have to somehow render that message into your JavaScript when
> > rendering the view.
> >
> > Can u also explain me how can i do this ?
> >
> > Regards,
> > Madan
> >
> >
> >
> >
> >
> > ----- Original Message ----
> > From: Jörn Zaefferer <[EMAIL PROTECTED]>
> > To: MyFaces Discussion <[email protected]>
> > Sent: Sunday, 11 March, 2007 3:05:05 PM
> > Subject: Re: [ Tobago ] No Page Refresh while validation
> >
> > JavaScript based form-validation should always start with the submit
> event:
> > When a user presses enter inside one form field, the form is submitted
> > without triggering your onclick event.
> >
> > In your case it should be possible to use JSF's built-in localization
> > features. You'd have to somehow render that message into your JavaScript
> > when rendering the view.
> >
> >
> > ________________________________
> > Here's a new way to find what you're looking for - Yahoo! Answers
>
>
> ________________________________
> Here's a new way to find what you're looking for - Yahoo! Answers
________________________________
Here's a new way to find what you're looking for - Yahoo! Answers