You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Milan Milanovic <mi...@yahoo.com> on 2008/07/22 19:01:32 UTC

[s2] Formatting input textfields

Hi,

I need to format input in textfields that user can enter value like this:
204,05, but now it is like this 204.05.
I have defined this formatting for output already. How can I change this ?

--
Thx, Milan
-- 
View this message in context: http://www.nabble.com/-s2--Formatting-input-textfields-tp18593985p18593985.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [s2] Formatting input textfields

Posted by Milan Milanovic <mi...@yahoo.com>.
Hi,

could you give here your source code for that converter ?

--
Thx, Milan


aretobios wrote:
> 
> I had the same problem. I solved it by creating a custom type conversion
> for bigdecimal fields.
> 
> Take a look 
> http://struts.apache.org/2.0.11.2/docs/type-conversion.html#TypeConversion-ApplyingaTypeConverterforanapplication
> here 
> 
> By creating your own converter you can have fields were the user write
> number with the #.###,## format and the bigdecimals are displayed with the
> same format
> 
>>
>> Hi,
>>
>> I need to format input in textfields that user can enter value like this:
>> 204,05, but now it is like this 204.05.
>> I have defined this formatting for output already. How can I change this
>> ?
>>
>> --
>> Thx, Milan
>> --
>> View this message in context:
>> http://www.nabble.com/-s2--Formatting-input-textfields-tp18593985p18593985.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>  
> 
> John Koutros
> Technology
> 
> PROTONBANK
> 20 Amaliados & Eslin Str., 115 23  Athens, Greece 
> Tel.: +30 210 6970677, +30 211 1081677
> Mob.: +30 693 6104677 FAX: +30 210 90025299
> eMail: j.koutros@proton.gr, Web: www.proton.gr
> 
> --------------------------------------------------------
> 
> 
> This message may contain confidential information and is intended only for
> the individual named. If you are not the named addressee you should not
> disseminate, distribute, alter or copy this e-mail. Please notify the
> sender immediately by e-mail if you have received this e-mail by mistake
> and then delete this e-mail from your system. E-mail transmissions cannot
> be guaranteed to be secure, or error-free or virus-free. Any liability for
> all the above is excluded to the fullest extent permitted by law.
> 
> Αυτό το μήνυμα πιθανόν να περιέχει εμπιστευτικές πληροφορίες και
> προορίζεται μόνο για το άτομο που κατονομάζεται. Εάν δεν είστε ο
> κατονομαζόμενος παραλήπτης, δεν πρέπει να διαδώσετε, να διανείμετε, να
> αλλάξετε ή να αντιγράψετε αυτό το ηλεκτρονικό μήνυμα. Παρακαλώ ειδοποιήστε
> τον αποστολέα αμέσως με ηλεκτρονικό ταχυδρομείο εάν έχετε λάβει αυτό το
> ηλεκτρονικό μήνυμα από λάθος και εν συνεχεία διαγράψτε το από το σύστημά
> σας. Η μετάδοση μέσω ηλεκτρονικού ταχυδρομείου δεν παρέχει εγγυήσεις ως
> προς την ασφάλεια, την έλλειψη λαθών ή τη μετάδοση ιών. Οποιαδήποτε ευθύνη
> σχετικά με τα ανωτέρω αποκλείεται κατά το μέγιστο δυνατό μέτρο που
> επιτρέπει ο νόμος.
> 
> 

-- 
View this message in context: http://www.nabble.com/-s2--Formatting-input-textfields-tp18593985p18607495.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [s2] Formatting input textfields

Posted by jk...@proton.gr.
I had the same problem. I solved it by creating a custom type conversion
for bigdecimal fields.

Take a look <a
href="http://struts.apache.org/2.0.11.2/docs/type-conversion.html#TypeConversion-ApplyingaTypeConverterforanapplication">here</a>

By creating your own converter you can have fields were the user write
number with the #.###,## format and the bigdecimals are displayed with the
same format

>
> Hi,
>
> I need to format input in textfields that user can enter value like this:
> 204,05, but now it is like this 204.05.
> I have defined this formatting for output already. How can I change this ?
>
> --
> Thx, Milan
> --
> View this message in context:
> http://www.nabble.com/-s2--Formatting-input-textfields-tp18593985p18593985.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
 

John Koutros
Technology

PROTONBANK
20 Amaliados & Eslin Str., 115 23  Athens, Greece 
Tel.: +30 210 6970677, +30 211 1081677
Mob.: +30 693 6104677 FAX: +30 210 90025299
eMail: j.koutros@proton.gr, Web: www.proton.gr

--------------------------------------------------------


This message may contain confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute, alter or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and then delete this e-mail from your system. E-mail transmissions cannot be guaranteed to be secure, or error-free or virus-free. Any liability for all the above is excluded to the fullest extent permitted by law.

Αυτό το μήνυμα πιθανόν να περιέχει εμπιστευτικές πληροφορίες και προορίζεται μόνο για το άτομο που κατονομάζεται. Εάν δεν είστε ο κατονομαζόμενος παραλήπτης, δεν πρέπει να διαδώσετε, να διανείμετε, να αλλάξετε ή να αντιγράψετε αυτό το ηλεκτρονικό μήνυμα. Παρακαλώ ειδοποιήστε τον αποστολέα αμέσως με ηλεκτρονικό ταχυδρομείο εάν έχετε λάβει αυτό το ηλεκτρονικό μήνυμα από λάθος και εν συνεχεία διαγράψτε το από το σύστημά σας. Η μετάδοση μέσω ηλεκτρονικού ταχυδρομείου δεν παρέχει εγγυήσεις ως προς την ασφάλεια, την έλλειψη λαθών ή τη μετάδοση ιών. Οποιαδήποτε ευθύνη σχετικά με τα ανωτέρω αποκλείεται κατά το μέγιστο δυνατό μέτρο που επιτρέπει ο νόμος.

RE: [s2] Formatting input textfields

Posted by Milan Milanovic <mi...@yahoo.com>.
Hi John,

Great, thank you VERY much!

--
Regards, Milan 


John Koutros wrote:
> 
> package util;
> 
> import java.math.BigDecimal;
> import java.text.DecimalFormat;
> import java.text.NumberFormat;
> import java.text.ParseException;
> import java.util.Map;
> 
> import org.apache.struts2.util.StrutsTypeConverter;
> 
> import com.opensymphony.xwork2.util.TypeConversionException;
> 
> 
> public class CurrencyBigDecimalConverter extends StrutsTypeConverter {
> 
> 	@SuppressWarnings("unchecked")
> 	@Override
> 	public Object convertFromString(Map contextMap, String[] values, Class
> toClass) {
> 		BigDecimal result = null;
> 		if (values != null) {
> 			if (values.length != 1) {
> 				super.performFallbackConversion(context, values, toClass);
> 			}
> 			
> 			if (values.length > 0) {
> 				NumberFormat formater = new DecimalFormat("#,##0.00");
> 				try{
> 					Number tmpResult = formater.parse(values[0]);
> 					result = new BigDecimal(tmpResult.doubleValue());
> 				} catch (ParseException e) {    }
> 				
> 				if (result == null) { 
> 	                throw new TypeConversionException("Invalid number format:
> "+values[0]); 
> 	            } 
> 			}
> 			
> 			
> 		}
> 		
> 		return result;
> 	}
> 
> 	@SuppressWarnings("unchecked")
> 	@Override
> 	public String convertToString(Map contextMap, Object objectValue) {
> 		if(objectValue instanceof BigDecimal){
> 			NumberFormat formater = new DecimalFormat("#,##0.00");
> 			
> 			BigDecimal value = (BigDecimal) objectValue;
> 			return formater.format(value);
> 		}
> 		else{
> 			return null;
> 		}
> 
> 	}
> 
> }
> 
> -----Original Message-----
> From: Milan Milanovic [mailto:milanmilanovich@yahoo.com] 
> Sent: Wednesday, July 23, 2008 1:02 PM
> To: user@struts.apache.org
> Subject: Re: [s2] Formatting input textfields
> 
> 
> Hi,
> 
> could you give here your source code for that converter ?
> 
> --
> Thx, Milan
> 
> 
> aretobios wrote:
>> 
>> I had the same problem. I solved it by creating a custom type conversion
>> for bigdecimal fields.
>> 
>> Take a look 
>> http://struts.apache.org/2.0.11.2/docs/type-conversion.html#TypeConversion-ApplyingaTypeConverterforanapplication
>> here 
>> 
>> By creating your own converter you can have fields were the user write
>> number with the #.###,## format and the bigdecimals are displayed with
>> the
>> same format
>> 
>>>
>>> Hi,
>>>
>>> I need to format input in textfields that user can enter value like
>>> this:
>>> 204,05, but now it is like this 204.05.
>>> I have defined this formatting for output already. How can I change this
>>> ?
>>>
>>> --
>>> Thx, Milan
>>> --
>>> View this message in context:
>>> http://www.nabble.com/-s2--Formatting-input-textfields-tp18593985p18593985.html
>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>  
>> 
>> John Koutros
>> Technology
>> 
>> PROTONBANK
>> 20 Amaliados & Eslin Str., 115 23  Athens, Greece 
>> Tel.: +30 210 6970677, +30 211 1081677
>> Mob.: +30 693 6104677 FAX: +30 210 90025299
>> eMail: j.koutros@proton.gr, Web: www.proton.gr
>> 
>> --------------------------------------------------------
>> 
>> 
>> This message may contain confidential information and is intended only
>> for
>> the individual named. If you are not the named addressee you should not
>> disseminate, distribute, alter or copy this e-mail. Please notify the
>> sender immediately by e-mail if you have received this e-mail by mistake
>> and then delete this e-mail from your system. E-mail transmissions cannot
>> be guaranteed to be secure, or error-free or virus-free. Any liability
>> for
>> all the above is excluded to the fullest extent permitted by law.
>> 
>> Αυτό το μήνυμα πιθανόν να περιέχει εμπιστευτικές πληροφορίες και
>> προορίζεται μόνο για το άτομο που κατονομάζεται. Εάν δεν είστε ο
>> κατονομαζόμενος παραλήπτης, δεν πρέπει να διαδώσετε, να διανείμετε, να
>> αλλάξετε ή να αντιγράψετε αυτό το ηλεκτρονικό μήνυμα. Παρακαλώ
>> ειδοποιήστε
>> τον αποστολέα αμέσως με ηλεκτρονικό ταχυδρομείο εάν έχετε λάβει αυτό το
>> ηλεκτρονικό μήνυμα από λάθος και εν συνεχεία διαγράψτε το από το σύστημά
>> σας. Η μετάδοση μέσω ηλεκτρονικού ταχυδρομείου δεν παρέχει εγγυήσεις ως
>> προς την ασφάλεια, την έλλειψη λαθών ή τη μετάδοση ιών. Οποιαδήποτε
>> ευθύνη
>> σχετικά με τα ανωτέρω αποκλείεται κατά το μέγιστο δυνατό μέτρο που
>> επιτρέπει ο νόμος.
>> 
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/-s2--Formatting-input-textfields-tp18593985p18607495.html
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-s2--Formatting-input-textfields-tp18593985p18631148.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: [s2] Formatting input textfields

Posted by Jishnu Viswanath <ji...@tavant.com>.
I don't know about that, I don't know about any input field that can
change based on locale, it just pure text field, it does not know that
it has to takes an internationalized number.

If this thing looks complicated, I don't know, may be you can try
writing your own custom tag. 

Regards,

Jishnu Viswanath

Software Engineer

*(+9180)41190300 - 222(Ext) ll * ( + 91 ) 9731209330ll

Tavant Technologies Inc.,

www.tavant.com

PEOPLE :: PASSION :: EXCELLENCE


-----Original Message-----
From: Milan Milanovic [mailto:milanmilanovich@yahoo.com] 
Sent: Wednesday, July 23, 2008 7:14 PM
To: user@struts.apache.org
Subject: RE: [s2] Formatting input textfields


Thank you Jishnu.

This looks like complicated solution to me, could I just change locale
for
that jsp or textfield ?

--
Thx, Milan


Jishnu Viswanath wrote:
> 
> AJAX validation is done through js, before that we can have our own
> client side validation. 
> Since your's is an easy client side validation we can do something
like
> this.
> 
> If its not something you wanted mail back.
> 
> <s:textarea name="dummy.value" id="someId" onblur="roundOf('someId')"
> cssStyle="width:100%;"/>
> 
> <script type="text/javascript">
>             function roundOf(/*id Of the widget*/someId) {
>                 var inputValue =
document.getElementById(someId).value;
>                 //TODO: I am putting basic validation only the rest is
> upto you
>                 var result = Math.round((inputValue.replace(',', "."))
*
> 100) / 100;
>                 document.getElementById(someId).value=
> (result+"").replace('.', ",");
>                 
> 
>             }
>         </script>
> 
> Regards,
> 
> Jishnu Viswanath
> 
> Software Engineer
> 
> *(+9180)41190300 - 222(Ext) ll * ( + 91 ) 9731209330ll
> 
> Tavant Technologies Inc.,
> 
> www.tavant.com
> 
> PEOPLE :: PASSION :: EXCELLENCE
> 
> 
> -----Original Message-----
> From: Milan Milanovic [mailto:milanmilanovich@yahoo.com] 
> Sent: Wednesday, July 23, 2008 3:34 PM
> To: user@struts.apache.org
> Subject: RE: [s2] Formatting input textfields
> 
> 
> Hi Jishnu,
> 
> well, I'm not sure what to do with ajax validation on jsp page,
because
> my
> BigDecimal field in my action class wouldn't accept it ?
> 
> I need one another thing, that my number be rounded on exactly two
> decimals,
> like: 198,19833 to 198,20 ?
> 
> 
> --
> Thx, Milan
> 
> 
> Jishnu Viswanath wrote:
>> 
>> http://cwiki.apache.org/WW/ajax-validation.html
>> On the validate part, do put Regular expression to make to accept the
>> pattern you want. 
>> 
>> Regards,
>> 
>> Jishnu Viswanath
>> 
>> Software Engineer
>> 
>> *(+9180)41190300 - 222(Ext) ll * ( + 91 ) 9731209330ll
>> 
>> Tavant Technologies Inc.,
>> 
>> www.tavant.com
>> 
>> PEOPLE :: PASSION :: EXCELLENCE
>> 
>> 
>> -----Original Message-----
>> From: Milan Milanovic [mailto:milanmilanovich@yahoo.com] 
>> Sent: Tuesday, July 22, 2008 10:32 PM
>> To: user@struts.apache.org
>> Subject: [s2] Formatting input textfields
>> 
>> 
>> Hi,
>> 
>> I need to format input in textfields that user can enter value like
>> this:
>> 204,05, but now it is like this 204.05.
>> I have defined this formatting for output already. How can I change
> this
>> ?
>> 
>> --
>> Thx, Milan
>> -- 
>> View this message in context:
>>
>
http://www.nabble.com/-s2--Formatting-input-textfields-tp18593985p185939
>> 85.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>> 
>> Any comments or statements made in this email are not necessarily
> those of
>> Tavant Technologies.
>> The information transmitted is intended only for the person or entity
> to
>> which it is addressed and may 
>> contain confidential and/or privileged material. If you have received
> this
>> in error, please contact the 
>> sender and delete the material from any computer. All e-mails sent
> from or
>> to Tavant Technologies 
>> may be subject to our monitoring procedures.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>> 
>> 
>> 
> 
> -- 
> View this message in context:
>
http://www.nabble.com/-s2--Formatting-input-textfields-tp18593985p186074
> 97.html
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> Any comments or statements made in this email are not necessarily
those of
> Tavant Technologies.
> The information transmitted is intended only for the person or entity
to
> which it is addressed and may 
> contain confidential and/or privileged material. If you have received
this
> in error, please contact the 
> sender and delete the material from any computer. All e-mails sent
from or
> to Tavant Technologies 
> may be subject to our monitoring procedures.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context:
http://www.nabble.com/-s2--Formatting-input-textfields-tp18593985p186110
55.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

Any comments or statements made in this email are not necessarily those of Tavant Technologies.
The information transmitted is intended only for the person or entity to which it is addressed and may 
contain confidential and/or privileged material. If you have received this in error, please contact the 
sender and delete the material from any computer. All e-mails sent from or to Tavant Technologies 
may be subject to our monitoring procedures.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: [s2] Formatting input textfields

Posted by Milan Milanovic <mi...@yahoo.com>.
Thank you Jishnu.

This looks like complicated solution to me, could I just change locale for
that jsp or textfield ?

--
Thx, Milan


Jishnu Viswanath wrote:
> 
> AJAX validation is done through js, before that we can have our own
> client side validation. 
> Since your's is an easy client side validation we can do something like
> this.
> 
> If its not something you wanted mail back.
> 
> <s:textarea name="dummy.value" id="someId" onblur="roundOf('someId')"
> cssStyle="width:100%;"/>
> 
> <script type="text/javascript">
>             function roundOf(/*id Of the widget*/someId) {
>                 var inputValue = document.getElementById(someId).value;
>                 //TODO: I am putting basic validation only the rest is
> upto you
>                 var result = Math.round((inputValue.replace(',', ".")) *
> 100) / 100;
>                 document.getElementById(someId).value=
> (result+"").replace('.', ",");
>                 
> 
>             }
>         </script>
> 
> Regards,
> 
> Jishnu Viswanath
> 
> Software Engineer
> 
> *(+9180)41190300 - 222(Ext) ll * ( + 91 ) 9731209330ll
> 
> Tavant Technologies Inc.,
> 
> www.tavant.com
> 
> PEOPLE :: PASSION :: EXCELLENCE
> 
> 
> -----Original Message-----
> From: Milan Milanovic [mailto:milanmilanovich@yahoo.com] 
> Sent: Wednesday, July 23, 2008 3:34 PM
> To: user@struts.apache.org
> Subject: RE: [s2] Formatting input textfields
> 
> 
> Hi Jishnu,
> 
> well, I'm not sure what to do with ajax validation on jsp page, because
> my
> BigDecimal field in my action class wouldn't accept it ?
> 
> I need one another thing, that my number be rounded on exactly two
> decimals,
> like: 198,19833 to 198,20 ?
> 
> 
> --
> Thx, Milan
> 
> 
> Jishnu Viswanath wrote:
>> 
>> http://cwiki.apache.org/WW/ajax-validation.html
>> On the validate part, do put Regular expression to make to accept the
>> pattern you want. 
>> 
>> Regards,
>> 
>> Jishnu Viswanath
>> 
>> Software Engineer
>> 
>> *(+9180)41190300 - 222(Ext) ll * ( + 91 ) 9731209330ll
>> 
>> Tavant Technologies Inc.,
>> 
>> www.tavant.com
>> 
>> PEOPLE :: PASSION :: EXCELLENCE
>> 
>> 
>> -----Original Message-----
>> From: Milan Milanovic [mailto:milanmilanovich@yahoo.com] 
>> Sent: Tuesday, July 22, 2008 10:32 PM
>> To: user@struts.apache.org
>> Subject: [s2] Formatting input textfields
>> 
>> 
>> Hi,
>> 
>> I need to format input in textfields that user can enter value like
>> this:
>> 204,05, but now it is like this 204.05.
>> I have defined this formatting for output already. How can I change
> this
>> ?
>> 
>> --
>> Thx, Milan
>> -- 
>> View this message in context:
>>
> http://www.nabble.com/-s2--Formatting-input-textfields-tp18593985p185939
>> 85.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>> 
>> Any comments or statements made in this email are not necessarily
> those of
>> Tavant Technologies.
>> The information transmitted is intended only for the person or entity
> to
>> which it is addressed and may 
>> contain confidential and/or privileged material. If you have received
> this
>> in error, please contact the 
>> sender and delete the material from any computer. All e-mails sent
> from or
>> to Tavant Technologies 
>> may be subject to our monitoring procedures.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>> 
>> 
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/-s2--Formatting-input-textfields-tp18593985p186074
> 97.html
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> Any comments or statements made in this email are not necessarily those of
> Tavant Technologies.
> The information transmitted is intended only for the person or entity to
> which it is addressed and may 
> contain confidential and/or privileged material. If you have received this
> in error, please contact the 
> sender and delete the material from any computer. All e-mails sent from or
> to Tavant Technologies 
> may be subject to our monitoring procedures.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-s2--Formatting-input-textfields-tp18593985p18611055.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: [s2] Formatting input textfields

Posted by Jishnu Viswanath <ji...@tavant.com>.
AJAX validation is done through js, before that we can have our own
client side validation. 
Since your's is an easy client side validation we can do something like
this.

If its not something you wanted mail back.

<s:textarea name="dummy.value" id="someId" onblur="roundOf('someId')"
cssStyle="width:100%;"/>

<script type="text/javascript">
            function roundOf(/*id Of the widget*/someId) {
                var inputValue = document.getElementById(someId).value;
                //TODO: I am putting basic validation only the rest is
upto you
                var result = Math.round((inputValue.replace(',', ".")) *
100) / 100;
                document.getElementById(someId).value=
(result+"").replace('.', ",");
                

            }
        </script>

Regards,

Jishnu Viswanath

Software Engineer

*(+9180)41190300 - 222(Ext) ll * ( + 91 ) 9731209330ll

Tavant Technologies Inc.,

www.tavant.com

PEOPLE :: PASSION :: EXCELLENCE


-----Original Message-----
From: Milan Milanovic [mailto:milanmilanovich@yahoo.com] 
Sent: Wednesday, July 23, 2008 3:34 PM
To: user@struts.apache.org
Subject: RE: [s2] Formatting input textfields


Hi Jishnu,

well, I'm not sure what to do with ajax validation on jsp page, because
my
BigDecimal field in my action class wouldn't accept it ?

I need one another thing, that my number be rounded on exactly two
decimals,
like: 198,19833 to 198,20 ?


--
Thx, Milan


Jishnu Viswanath wrote:
> 
> http://cwiki.apache.org/WW/ajax-validation.html
> On the validate part, do put Regular expression to make to accept the
> pattern you want. 
> 
> Regards,
> 
> Jishnu Viswanath
> 
> Software Engineer
> 
> *(+9180)41190300 - 222(Ext) ll * ( + 91 ) 9731209330ll
> 
> Tavant Technologies Inc.,
> 
> www.tavant.com
> 
> PEOPLE :: PASSION :: EXCELLENCE
> 
> 
> -----Original Message-----
> From: Milan Milanovic [mailto:milanmilanovich@yahoo.com] 
> Sent: Tuesday, July 22, 2008 10:32 PM
> To: user@struts.apache.org
> Subject: [s2] Formatting input textfields
> 
> 
> Hi,
> 
> I need to format input in textfields that user can enter value like
> this:
> 204,05, but now it is like this 204.05.
> I have defined this formatting for output already. How can I change
this
> ?
> 
> --
> Thx, Milan
> -- 
> View this message in context:
>
http://www.nabble.com/-s2--Formatting-input-textfields-tp18593985p185939
> 85.html
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> Any comments or statements made in this email are not necessarily
those of
> Tavant Technologies.
> The information transmitted is intended only for the person or entity
to
> which it is addressed and may 
> contain confidential and/or privileged material. If you have received
this
> in error, please contact the 
> sender and delete the material from any computer. All e-mails sent
from or
> to Tavant Technologies 
> may be subject to our monitoring procedures.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context:
http://www.nabble.com/-s2--Formatting-input-textfields-tp18593985p186074
97.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

Any comments or statements made in this email are not necessarily those of Tavant Technologies.
The information transmitted is intended only for the person or entity to which it is addressed and may 
contain confidential and/or privileged material. If you have received this in error, please contact the 
sender and delete the material from any computer. All e-mails sent from or to Tavant Technologies 
may be subject to our monitoring procedures.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: [s2] Formatting input textfields

Posted by Milan Milanovic <mi...@yahoo.com>.
Hi Jishnu,

well, I'm not sure what to do with ajax validation on jsp page, because my
BigDecimal field in my action class wouldn't accept it ?

I need one another thing, that my number be rounded on exactly two decimals,
like: 198,19833 to 198,20 ?


--
Thx, Milan


Jishnu Viswanath wrote:
> 
> http://cwiki.apache.org/WW/ajax-validation.html
> On the validate part, do put Regular expression to make to accept the
> pattern you want. 
> 
> Regards,
> 
> Jishnu Viswanath
> 
> Software Engineer
> 
> *(+9180)41190300 - 222(Ext) ll * ( + 91 ) 9731209330ll
> 
> Tavant Technologies Inc.,
> 
> www.tavant.com
> 
> PEOPLE :: PASSION :: EXCELLENCE
> 
> 
> -----Original Message-----
> From: Milan Milanovic [mailto:milanmilanovich@yahoo.com] 
> Sent: Tuesday, July 22, 2008 10:32 PM
> To: user@struts.apache.org
> Subject: [s2] Formatting input textfields
> 
> 
> Hi,
> 
> I need to format input in textfields that user can enter value like
> this:
> 204,05, but now it is like this 204.05.
> I have defined this formatting for output already. How can I change this
> ?
> 
> --
> Thx, Milan
> -- 
> View this message in context:
> http://www.nabble.com/-s2--Formatting-input-textfields-tp18593985p185939
> 85.html
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> Any comments or statements made in this email are not necessarily those of
> Tavant Technologies.
> The information transmitted is intended only for the person or entity to
> which it is addressed and may 
> contain confidential and/or privileged material. If you have received this
> in error, please contact the 
> sender and delete the material from any computer. All e-mails sent from or
> to Tavant Technologies 
> may be subject to our monitoring procedures.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-s2--Formatting-input-textfields-tp18593985p18607497.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: [s2] Formatting input textfields

Posted by Jishnu Viswanath <ji...@tavant.com>.
http://cwiki.apache.org/WW/ajax-validation.html
On the validate part, do put Regular expression to make to accept the
pattern you want. 

Regards,

Jishnu Viswanath

Software Engineer

*(+9180)41190300 - 222(Ext) ll * ( + 91 ) 9731209330ll

Tavant Technologies Inc.,

www.tavant.com

PEOPLE :: PASSION :: EXCELLENCE


-----Original Message-----
From: Milan Milanovic [mailto:milanmilanovich@yahoo.com] 
Sent: Tuesday, July 22, 2008 10:32 PM
To: user@struts.apache.org
Subject: [s2] Formatting input textfields


Hi,

I need to format input in textfields that user can enter value like
this:
204,05, but now it is like this 204.05.
I have defined this formatting for output already. How can I change this
?

--
Thx, Milan
-- 
View this message in context:
http://www.nabble.com/-s2--Formatting-input-textfields-tp18593985p185939
85.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

Any comments or statements made in this email are not necessarily those of Tavant Technologies.
The information transmitted is intended only for the person or entity to which it is addressed and may 
contain confidential and/or privileged material. If you have received this in error, please contact the 
sender and delete the material from any computer. All e-mails sent from or to Tavant Technologies 
may be subject to our monitoring procedures.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org