Re: Adding UUID Converter

2014-01-14 Thread Martin Grigorov
On Tue, Jan 14, 2014 at 3:21 PM, Oliver B. Fischer wrote:

> Am 14.01.14 14:02, schrieb Martin Grigorov:
>
>  It is quite simple. Anyone can write it if it is needed for her
>> application.
>> But also I don't object to add it.
>>
>>
> Yes, that is true. On the otherhand I expected Wicket to support it since
> the  UUID class is part of java.lang
>

No one asked for it all these years ...


>
> I will prepare a patch and submit it via Jira.
>
> Bye,
>
> Oliver
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: Adding UUID Converter

2014-01-14 Thread Oliver B. Fischer

Am 14.01.14 14:02, schrieb Martin Grigorov:

It is quite simple. Anyone can write it if it is needed for her application.
But also I don't object to add it.



Yes, that is true. On the otherhand I expected Wicket to support it 
since the  UUID class is part of java.lang


I will prepare a patch and submit it via Jira.

Bye,

Oliver

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Adding UUID Converter

2014-01-14 Thread Martin Grigorov
Hi,


On Tue, Jan 14, 2014 at 1:29 PM, Oliver B. Fischer wrote:

> I have to validate a lot of UUIDs and wrote a small converter for UUID. If
> the quite simple implementation is fine for you I would like to contribute
> it to the Wicket code base including some tests
>
> public class UUIDConverter implements IConverter
> {
> public static final String UUID_REGEX = "[0-9a-fA-F]{8}(?:-[0-9a-fA-F]
> {4}){3}-[0-9a-fA-F]{12}";
>

This would be better to be compiled Pattern instead. For better performance.


>
> @Override
> public UUID convertToObject(String value, Locale locale)
> throws ConversionException
> {
> UUID conversionResult = null;
>
> if (value == null || !value.matches(UUID_REGEX)) {
> throw newConversionException(value);
> }
>
> try {
> conversionResult = UUID.fromString(value);
> }
> catch (IllegalArgumentException e)
> {
> throw newConversionException(value);
>

Maybe it is a good idea to pass the cause as well.


> }
>
> return conversionResult;
> }
>
> @Override
> public String convertToString(UUID value, Locale locale)
> {
> String conversionResult = null;
>
> if (value != null) {
> conversionResult = value.toString();
> }
>
> return conversionResult;
> }
>
> protected ConversionException newConversionException(String value)
> {
> return new ConversionException("Failed to convert " + value +
>"to a UUID");
> }
> }
>
>
It is quite simple. Anyone can write it if it is needed for her application.
But also I don't object to add it.


>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Adding UUID Converter

2014-01-14 Thread Oliver B. Fischer
I have to validate a lot of UUIDs and wrote a small converter for UUID. 
If the quite simple implementation is fine for you I would like to 
contribute it to the Wicket code base including some tests


public class UUIDConverter implements IConverter
{
public static final String UUID_REGEX = 
"[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}";


@Override
public UUID convertToObject(String value, Locale locale)
throws ConversionException
{
UUID conversionResult = null;

if (value == null || !value.matches(UUID_REGEX)) {
throw newConversionException(value);
}

try {
conversionResult = UUID.fromString(value);
}
catch (IllegalArgumentException e)
{
throw newConversionException(value);
}

return conversionResult;
}

@Override
public String convertToString(UUID value, Locale locale)
{
String conversionResult = null;

if (value != null) {
conversionResult = value.toString();
}

return conversionResult;
}

protected ConversionException newConversionException(String value)
{
return new ConversionException("Failed to convert " + value +
   "to a UUID");
}
}


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Custom Component Converter not called

2013-09-08 Thread Malte Neumann

Am 07.09.2013 22:19, schrieb Sven Meier:
if you don't specify the type, a TextField will try to resolve the 
type from its model, see AbstractTextComponent#resolveType() and 
IObjectClassAwareModel.

Thanks for this hint.

During further tests after my mail, I found a situtation where the 
convertToString is called, but not the convertToObject. The initial 
situation is the same as described in the first mail. Then the model is 
updated by an ajax-call from null to a value, the output call my 
ToString-Method, but a later form submit doesn't call the 
ToObject-Method. It seems the problem occurs in 
AbstractTextComponent.resolveType. This function tries only once to 
resolve the type. In the first call the function sets type to null.


This is not my problem anymore. I can solve my special problem with the 
IObjectClassAwareModel.


Malte




>Shouldn't there be a pre-examination wheter a component converter is 
available?


Without type there can't be a converter.

Sven

On 09/07/2013 08:42 PM, Malte Neumann wrote:

Hello!

I've got a problem with a TextField and the depending 
CustomConverter. The converter of the component is not been called. 
So the default converter takes the task and fails.


In my case this problem occurs when my IModel.getObject returns null.

The problem arises in the FormComponent.convertInput method. Because 
of the null value, the typeName is null and a generic typcast is made 
and fails. Shouldn't there be a pre-examination wheter a component 
converter is available?


If I explicitly set  a type through TextField.setType my converter is 
called correctly.


Is that behaviour intended this way?

Malte

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Custom Component Converter not called

2013-09-07 Thread Sven Meier

Hi,

if you don't specify the type, a TextField will try to resolve the type 
from its model, see AbstractTextComponent#resolveType() and 
IObjectClassAwareModel.


>Shouldn't there be a pre-examination wheter a component converter is 
available?


Without type there can't be a converter.

Sven

On 09/07/2013 08:42 PM, Malte Neumann wrote:

Hello!

I've got a problem with a TextField and the depending CustomConverter. 
The converter of the component is not been called. So the default 
converter takes the task and fails.


In my case this problem occurs when my IModel.getObject returns null.

The problem arises in the FormComponent.convertInput method. Because 
of the null value, the typeName is null and a generic typcast is made 
and fails. Shouldn't there be a pre-examination wheter a component 
converter is available?


If I explicitly set  a type through TextField.setType my converter is 
called correctly.


Is that behaviour intended this way?

Malte

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Custom Component Converter not called

2013-09-07 Thread Malte Neumann

Hello!

I've got a problem with a TextField and the depending CustomConverter. 
The converter of the component is not been called. So the default 
converter takes the task and fails.


In my case this problem occurs when my IModel.getObject returns null.

The problem arises in the FormComponent.convertInput method. Because of 
the null value, the typeName is null and a generic typcast is made and 
fails. Shouldn't there be a pre-examination wheter a component converter 
is available?


If I explicitly set  a type through TextField.setType my converter is 
called correctly.


Is that behaviour intended this way?

Malte

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Currency Converter

2012-11-07 Thread Martin Grigorov
Hi,

You don't use the generics.
I expect to see : extends AbstractNumberConverter and later
convertTo methods work with Double too.
In your #convertToString() I see no call to super.convertToString() but the
exception says that it fails at AbstractNumberConverter.java:**31 so your
override actually doesn't work.


On Wed, Nov 7, 2012 at 3:54 AM, Jered Myers wrote:

> I am updating my application from Wicket 1.4.18 to Wicket 6.2 and my
> currency converter no longer works once I add the generics into it. I am
> using the converter to allow the user to enter an amount of money.  The
> problem is that when something like "asdfasdf" is entered, I get an
> exception like this:
>
> java.lang.ClassCastException: java.lang.String cannot be cast to
> java.lang.Number
> at org.apache.wicket.util.**convert.converter.**AbstractNumberConverter.**
> convertToString(**AbstractNumberConverter.java:**31)
>
> Is there a currency converter already in Wicket that I haven't seen?  Does
> anybody have a good example of a working converter for currency in Wicket
> 6.x?
>
> Here is my code from 1.4 that was working:
>
> public class CurrencyConverter extends AbstractNumberConverter {
> private static final long serialVersionUID = 1L;
>
> public CurrencyConverter() {
> }
>
> @Override
> public NumberFormat getNumberFormat(Locale locale) {
> return NumberFormat.**getCurrencyInstance(locale);
> }
>
> @Override
> public Class getTargetType() {
> return Double.class;
> }
>
> public Object convertToObject(String value, Locale locale) {
>
> try {
> if(value.startsWith("$")) {
> value = value.replace("$", "");
> }
> value = String.valueOf( Double.valueOf( value ) * 100 );
> value = "$" + value;
>
> return getNumberFormat(locale).parse(**value).doubleValue();
> } catch (ParseException ex) {
> ConversionException conv = new ConversionException("'" + value
> + "' is not a valid dollar amount.");
> conv.setResourceKey("**CurrencyConverter");
> throw conv;
> } catch(NumberFormatException ex){
> ConversionException conv = new ConversionException("'" + value
> + "' is not a valid dollar amount.");
> conv.setResourceKey("**CurrencyConverter");
> throw conv;
> }
> }
>
> @Override
> public String convertToString(Object value, Locale locale) {
> if( value == null )
> return null;
>
> int cents;
>
> if( value instanceof Integer ) {
> cents = (Integer) value;
> return getNumberFormat(locale).**format((double) cents /
> 100.0);
> } else if( value instanceof String ) {
> cents = Integer.parseInt( (String) value );
> return getNumberFormat(locale).**format((double) cents /
> 100.0);
>
> }
>
> return value.toString();
> }
>
> }
>
> --
> Jered Myers
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>


Currency Converter

2012-11-06 Thread Jered Myers
I am updating my application from Wicket 1.4.18 to Wicket 6.2 and my 
currency converter no longer works once I add the generics into it. I am 
using the converter to allow the user to enter an amount of money.  The 
problem is that when something like "asdfasdf" is entered, I get an 
exception like this:


java.lang.ClassCastException: java.lang.String cannot be cast to 
java.lang.Number
at 
org.apache.wicket.util.convert.converter.AbstractNumberConverter.convertToString(AbstractNumberConverter.java:31)


Is there a currency converter already in Wicket that I haven't seen?  
Does anybody have a good example of a working converter for currency in 
Wicket 6.x?


Here is my code from 1.4 that was working:

public class CurrencyConverter extends AbstractNumberConverter {
private static final long serialVersionUID = 1L;

public CurrencyConverter() {
}

@Override
public NumberFormat getNumberFormat(Locale locale) {
return NumberFormat.getCurrencyInstance(locale);
}

@Override
public Class getTargetType() {
return Double.class;
}

public Object convertToObject(String value, Locale locale) {

try {
if(value.startsWith("$")) {
value = value.replace("$", "");
}
value = String.valueOf( Double.valueOf( value ) * 100 );
value = "$" + value;

return getNumberFormat(locale).parse(value).doubleValue();
} catch (ParseException ex) {
ConversionException conv = new ConversionException("'" + 
value + "' is not a valid dollar amount.");

conv.setResourceKey("CurrencyConverter");
throw conv;
} catch(NumberFormatException ex){
ConversionException conv = new ConversionException("'" + 
value + "' is not a valid dollar amount.");

conv.setResourceKey("CurrencyConverter");
throw conv;
}
}

@Override
public String convertToString(Object value, Locale locale) {
if( value == null )
return null;

int cents;

if( value instanceof Integer ) {
cents = (Integer) value;
return getNumberFormat(locale).format((double) cents / 100.0);
} else if( value instanceof String ) {
cents = Integer.parseInt( (String) value );
return getNumberFormat(locale).format((double) cents / 100.0);

}

return value.toString();
}

}

--
Jered Myers



RE: Using AutocompleteTextField with database entries (without a converter)

2012-10-24 Thread Paul Bors
As for your search by multiple columns in the db... do something silly like
using an OR in your SQL and filter by both columns :)

Another idea is to include a drop down to filter by what column you want to
search.

~ Thank you,
  Paul Bors

-Original Message-
From: Gaetan Zoritchak [mailto:g.zoritc...@moncoachfinance.com] 
Sent: Wednesday, October 24, 2012 5:46 PM
To: users@wicket.apache.org
Subject: Re: Using AutocompleteTextField with database entries (without a
converter)

Thanks for the input. I'm going to have a look.

Gaetan
2012/10/24 Paul Bors 

> Take a look at Select2 developed by Ivan Vaynberg one of Wicket's
> contributors:
> http://ivaynberg.github.com/select2/
>
> You should try out the "Loading Remote Data" and "Infinite Scroll with 
> Remote Data" examples.
>
> Thanks Ivan for a great job!
>
> ~ Thank you,
>   Paul Bors
>
> -Original Message-
> From: Gaetan Zoritchak [mailto:g.zoritc...@moncoachfinance.com]
> Sent: Wednesday, October 24, 2012 9:39 AM
> To: users@wicket.apache.org
> Subject: Using AutocompleteTextField with database entries (without a
> converter)
>
> Hello,
> I don't know what is the best way of impleting that in Wicket
>
> That's my use case:
> - the user has to select a customer in a field of a form,
> - he starts to type some characters,
> - the list shows some possibilities based on a database request using 
> the first and last names, the email, ...
> - then he selects one item in the list,
> - the field just shows few informations (Last Name for exemple).
>
> I don't want to use a converter because the data in the field could 
> eventually match more than one entry in the database. I can give more 
> context in the list to make the user be sure of his selection. When 
> the selection is made, I can put a title so that on a mouse over event 
> the user visualize the full information on the customer selection.
>
> The best solution would be to use the database id of the customer as a 
> key during the selection phase.
>
> I don't know what is the best way of implementing this behaviour.
>
> Thanks a lot for any ideas,
>
> Gaetan,
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Using AutocompleteTextField with database entries (without a converter)

2012-10-24 Thread Gaetan Zoritchak
Thanks for the input. I'm going to have a look.

Gaetan
2012/10/24 Paul Bors 

> Take a look at Select2 developed by Ivan Vaynberg one of Wicket's
> contributors:
> http://ivaynberg.github.com/select2/
>
> You should try out the "Loading Remote Data" and "Infinite Scroll with
> Remote Data" examples.
>
> Thanks Ivan for a great job!
>
> ~ Thank you,
>   Paul Bors
>
> -Original Message-
> From: Gaetan Zoritchak [mailto:g.zoritc...@moncoachfinance.com]
> Sent: Wednesday, October 24, 2012 9:39 AM
> To: users@wicket.apache.org
> Subject: Using AutocompleteTextField with database entries (without a
> converter)
>
> Hello,
> I don't know what is the best way of impleting that in Wicket
>
> That's my use case:
> - the user has to select a customer in a field of a form,
> - he starts to type some characters,
> - the list shows some possibilities based on a database request using the
> first and last names, the email, ...
> - then he selects one item in the list,
> - the field just shows few informations (Last Name for exemple).
>
> I don't want to use a converter because the data in the field could
> eventually match more than one entry in the database. I can give more
> context in the list to make the user be sure of his selection. When the
> selection is made, I can put a title so that on a mouse over event the user
> visualize the full information on the customer selection.
>
> The best solution would be to use the database id of the customer as a key
> during the selection phase.
>
> I don't know what is the best way of implementing this behaviour.
>
> Thanks a lot for any ideas,
>
> Gaetan,
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


RE: Using AutocompleteTextField with database entries (without a converter)

2012-10-24 Thread Paul Bors
Take a look at Select2 developed by Ivan Vaynberg one of Wicket's
contributors:
http://ivaynberg.github.com/select2/

You should try out the "Loading Remote Data" and "Infinite Scroll with
Remote Data" examples.

Thanks Ivan for a great job!

~ Thank you,
  Paul Bors

-Original Message-
From: Gaetan Zoritchak [mailto:g.zoritc...@moncoachfinance.com] 
Sent: Wednesday, October 24, 2012 9:39 AM
To: users@wicket.apache.org
Subject: Using AutocompleteTextField with database entries (without a
converter)

Hello,
I don't know what is the best way of impleting that in Wicket

That's my use case:
- the user has to select a customer in a field of a form,
- he starts to type some characters,
- the list shows some possibilities based on a database request using the
first and last names, the email, ...
- then he selects one item in the list,
- the field just shows few informations (Last Name for exemple).

I don't want to use a converter because the data in the field could
eventually match more than one entry in the database. I can give more
context in the list to make the user be sure of his selection. When the
selection is made, I can put a title so that on a mouse over event the user
visualize the full information on the customer selection.

The best solution would be to use the database id of the customer as a key
during the selection phase.

I don't know what is the best way of implementing this behaviour.

Thanks a lot for any ideas,

Gaetan,


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Using AutocompleteTextField with database entries (without a converter)

2012-10-24 Thread Gaetan Zoritchak
Hello,
I don't know what is the best way of impleting that in Wicket

That's my use case:
- the user has to select a customer in a field of a form,
- he starts to type some characters,
- the list shows some possibilities based on a database request using the
first and last names, the email, ...
- then he selects one item in the list,
- the field just shows few informations (Last Name for exemple).

I don't want to use a converter because the data in the field could
eventually match more than one entry in the database. I can give more
context in the list to make the user be sure of his selection. When the
selection is made, I can put a title so that on a mouse over event the user
visualize the full information on the customer selection.

The best solution would be to use the database id of the customer as a key
during the selection phase.

I don't know what is the best way of implementing this behaviour.

Thanks a lot for any ideas,

Gaetan,


Autocomplete when Converter not available/possible

2012-06-18 Thread Douglas Ferguson
Does anybody have a good example of using the AutoCompleteField when a 
Converter is not available?

For example, I have a UserAccount object. I want to display "Joe Blow" with a 
photo on my auto suggest.
But the string "Joe Blow" isn't enough information for a converter to convert 
back to a UserAccount.

To work around this I overwrote getOnSelectJavascriptExpression and in that 
expression I call WicketAjaxGet()
Which points to behavior and passes the id of the UserAccount. In this behavior 
I can look up the UserAccount 
and wire it up.

Is there a better way to do this?

Douglas



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: converter

2012-03-19 Thread Martin Grigorov
Hi,

Take a look at the sources of
https://github.com/wicketstuff/core/tree/master/jdk-1.6-parent/mootools-meiomask-parent/mootools-meiomask
This project integrates input mask implementation (MeioMask) with
Wicket. Use it as inspiration.

On Mon, Mar 19, 2012 at 12:04 AM, neo  wrote:
> Hello I am new in wicket , i have number in textfield  in format -x(five
> digits) but if i input number like 22 , 222 it can by convert with padding
> zero like 00022,00222 how can do it?thank you very much
>
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/converter-tp4483142p4483142.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



converter

2012-03-18 Thread neo
Hello I am new in wicket , i have number in textfield  in format -x(five
digits) but if i input number like 22 , 222 it can by convert with padding
zero like 00022,00222 how can do it?thank you very much

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/converter-tp4483142p4483142.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Adding a converter to a label

2011-11-10 Thread Brian Mulholland
Please ignore.  I got my wires crossed.

Brian Mulholland





On Thu, Nov 10, 2011 at 1:00 PM, Brian Mulholland
 wrote:
> Is it not possible to add a converter to label?  The Label's add()
> takes Behaviors, and Converters evidently aren't behaviors.  I know I
> can modify the model or do the conversion beforehand, but I like
> snapping converters onto controls.
>
> Brian Mulholland
>

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Adding a converter to a label

2011-11-10 Thread Brian Mulholland
Is it not possible to add a converter to label?  The Label's add()
takes Behaviors, and Converters evidently aren't behaviors.  I know I
can modify the model or do the conversion beforehand, but I like
snapping converters onto controls.

Brian Mulholland

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Converter for FileUpload

2011-10-07 Thread Ian Marshall
Fantastic, Martin!

I have changed the model for my FileUploadField from FileUpload to
List and all works fine, without me having to roll my own
converter. (I didn't spot that the constructor for FieldUploadField which
takes a model now takes a model of type IModel<List<FileUpload>>.)

Thanks very much, and have a good weekend,

Ian



Martin Grigorov-4 wrote:
> 
> The difference in FileUploadField from 1.4.x to 1.5.x is that now it
> supports  (HTML5 standards) and it works
> with List instead of just FileUpload.
> You need to update your getConverter() impl to expect List
> 
> On Fri, Oct 7, 2011 at 12:39 PM, Ian Marshall <IanMarshall.UK@>
> wrote:
>> Hello All,
>>
>> I am porting my Wicket 1.4.18 application to 1.5.1.
>>
>> I am now getting the following exception when I use a
>> org.apache.wicket.markup.html.form.upload.FileUploadField to upload a
>> file,
>> when all worked well in 1.4.18:
>>
>>  ... 43 more
>> Caused by: org.apache.wicket.util.convert.ConversionException: Could not
>> convert value:
>> [org.apache.wicket.markup.html.form.upload.FileUpload@1b3d1e5] to type:
>> org.apache.wicket.markup.html.form.upload.FileUpload. Could not find
>> compatible converter.
>>  at
>> org.apache.wicket.ConverterLocator$DefaultConverter.convertToObject(ConverterLocator.java:109)
>>  ... 63 more
>>
>> Does anyone know of an org.apache.wicket.util.convert.IConverter for
>> org.apache.wicket.markup.html.form.upload.FileUpload, or will I have to
>> roll
>> my own?
>>
>> My development environment is:
>>  ∙  Web framework: Apache Wicket 1.5.1 using libraries (I am an Ant
>> user):
>>     ∙  wicket-core-1.5.1.jar
>>     ∙  wicket-request-1.5.1.jar
>>     ∙  wicket-util-1.5.1.jar
>>  ∙  Web server environment: Google App Engine
>>  ∙  Java: 1.6.0_27; Java HotSpot(TM) Client VM 20.2-b06
>>  ∙  System: Windows XP version 5.1 running on x86; Cp1252; en_GB (nb)
>>  ∙  IDE: NetBeans 7.0.1 (Build 201107282000)
>>  ∙  Web browser: Mozilla Firefox 7.0.1
>>
>>
>> Regards,
>>
>> Ian Marshall
>>
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/Converter-for-FileUpload-tp3881522p3881522.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> -
>> To unsubscribe, e-mail: users-unsubscribe@.apache
>> For additional commands, e-mail: users-help@.apache
>>
>>
> 
> 
> 
> -- 
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
> 
> -
> To unsubscribe, e-mail: users-unsubscribe@.apache
> For additional commands, e-mail: users-help@.apache
> 

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Converter-for-FileUpload-tp3881522p3882908.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Converter for FileUpload

2011-10-07 Thread Martin Grigorov
The difference in FileUploadField from 1.4.x to 1.5.x is that now it
supports  (HTML5 standards) and it works
with List instead of just FileUpload.
You need to update your getConverter() impl to expect List

On Fri, Oct 7, 2011 at 12:39 PM, Ian Marshall  wrote:
> Hello All,
>
> I am porting my Wicket 1.4.18 application to 1.5.1.
>
> I am now getting the following exception when I use a
> org.apache.wicket.markup.html.form.upload.FileUploadField to upload a file,
> when all worked well in 1.4.18:
>
>  ... 43 more
> Caused by: org.apache.wicket.util.convert.ConversionException: Could not
> convert value:
> [org.apache.wicket.markup.html.form.upload.FileUpload@1b3d1e5] to type:
> org.apache.wicket.markup.html.form.upload.FileUpload. Could not find
> compatible converter.
>  at
> org.apache.wicket.ConverterLocator$DefaultConverter.convertToObject(ConverterLocator.java:109)
>  ... 63 more
>
> Does anyone know of an org.apache.wicket.util.convert.IConverter for
> org.apache.wicket.markup.html.form.upload.FileUpload, or will I have to roll
> my own?
>
> My development environment is:
>  ∙  Web framework: Apache Wicket 1.5.1 using libraries (I am an Ant user):
>     ∙  wicket-core-1.5.1.jar
>     ∙  wicket-request-1.5.1.jar
>     ∙  wicket-util-1.5.1.jar
>  ∙  Web server environment: Google App Engine
>  ∙  Java: 1.6.0_27; Java HotSpot(TM) Client VM 20.2-b06
>  ∙  System: Windows XP version 5.1 running on x86; Cp1252; en_GB (nb)
>  ∙  IDE: NetBeans 7.0.1 (Build 201107282000)
>  ∙  Web browser: Mozilla Firefox 7.0.1
>
>
> Regards,
>
> Ian Marshall
>
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/Converter-for-FileUpload-tp3881522p3881522.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Converter for FileUpload

2011-10-07 Thread Ian Marshall
Hello All,

I am porting my Wicket 1.4.18 application to 1.5.1.

I am now getting the following exception when I use a
org.apache.wicket.markup.html.form.upload.FileUploadField to upload a file,
when all worked well in 1.4.18:

  ... 43 more
Caused by: org.apache.wicket.util.convert.ConversionException: Could not
convert value:
[org.apache.wicket.markup.html.form.upload.FileUpload@1b3d1e5] to type:
org.apache.wicket.markup.html.form.upload.FileUpload. Could not find
compatible converter.
  at
org.apache.wicket.ConverterLocator$DefaultConverter.convertToObject(ConverterLocator.java:109)
  ... 63 more

Does anyone know of an org.apache.wicket.util.convert.IConverter for
org.apache.wicket.markup.html.form.upload.FileUpload, or will I have to roll
my own?

My development environment is:
  ∙  Web framework: Apache Wicket 1.5.1 using libraries (I am an Ant user):
 ∙  wicket-core-1.5.1.jar
 ∙  wicket-request-1.5.1.jar
 ∙  wicket-util-1.5.1.jar
  ∙  Web server environment: Google App Engine
  ∙  Java: 1.6.0_27; Java HotSpot(TM) Client VM 20.2-b06
  ∙  System: Windows XP version 5.1 running on x86; Cp1252; en_GB (nb)
  ∙  IDE: NetBeans 7.0.1 (Build 201107282000)
  ∙  Web browser: Mozilla Firefox 7.0.1


Regards,

Ian Marshall

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Converter-for-FileUpload-tp3881522p3881522.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: A couple of questions about converter

2011-06-08 Thread Martin Grigorov
Hi Andrea,

On Wed, Jun 8, 2011 at 1:11 PM, Andrea Del Bene  wrote:
> Hi,
>
> I've started to explore the converting mechanism of wicket. I've red javadoc
> and both Wicket in Action and Wicket Cookbook but there still be something
> not completely clear to me.
> Converter are created by converter locator, which creates one instance of
> converter for each java type, right? So the first question is: are
> converters thread safe? If I have two session with two different locale, is
> DateConverter thread safe?
Looking at the code - yes. DateConverter doesn't keep any state.
>
> The second question is: if converters are created and registered at
> Application level, how can I implement a converter at Session level?
> I want to implement a custom date converter based on a date patter which
> depends on the current logged user.
Well, yes, there is no delegation to the Session as there is such for
some other "services" but you can always workaround it by registering
your own locator at app level which checks for existing session and
does something custom or just falls back to the default app locator.
>
> Thank you.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



A couple of questions about converter

2011-06-08 Thread Andrea Del Bene

Hi,

I've started to explore the converting mechanism of wicket. I've red 
javadoc and both Wicket in Action and Wicket Cookbook but there still be 
something not completely clear to me.
Converter are created by converter locator, which creates one instance 
of converter for each java type, right? So the first question is: are 
converters thread safe? If I have two session with two different locale, 
is DateConverter thread safe?


The second question is: if converters are created and registered at 
Application level, how can I implement a converter at Session level?
I want to implement a custom date converter based on a date patter which 
depends on the current logged user.


Thank you.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Converter for interface

2011-02-04 Thread Pedro Santos
You can override the the application converter locator to return your
converter under the instanceof or Class#isAssignableFrom test.
I believe Wicket default converter locator don't do so since it can be
problematic in some cases. If the text field has the Integer type, you can't
use an the NumberConverter because it's contract probably would not specify
that it converts to Integer.

On Fri, Feb 4, 2011 at 11:54 AM, Jan Ferko  wrote:

> Hi,
>
> I wrote custom converter for entity class. convertToObject() works fine,
> but I have problem with convertToString(). Since i have different
> implementations for my entity (immutable and mutable version) I work with
> their common interface in my web layer and wicket seems not to recognize
> that it should convert entity with converter and always uses default
> converter. By the way converter is registered globally for whole
> application. Is there any way how to solve this or i have to set converter
> for each component which uses it? Thanks for help.
>
> example:
>
> interface IEntity {
>getName();
> }
>
> class Entity implements IEntity{
>getName(){};
> }
>
> interface IMutableEntity extends IEntity{
>setName(String name);
> }
>
> class MutableEntity implements IMutableEntity {
>getName(){};
>setName(){};
> }
>
> my converter is registered for IEntity interface.
>
> Jan
>



-- 
Pedro Henrique Oliveira dos Santos


Converter for interface

2011-02-04 Thread Jan Ferko

Hi,

I wrote custom converter for entity class. convertToObject() works fine, 
but I have problem with convertToString(). Since i have different 
implementations for my entity (immutable and mutable version) I work 
with their common interface in my web layer and wicket seems not to 
recognize that it should convert entity with converter and always uses 
default converter. By the way converter is registered globally for whole 
application. Is there any way how to solve this or i have to set 
converter for each component which uses it? Thanks for help.


example:

interface IEntity {
getName();
}

class Entity implements IEntity{
getName(){};
}

interface IMutableEntity extends IEntity{
setName(String name);
}

class MutableEntity implements IMutableEntity {
getName(){};
setName(){};
}

my converter is registered for IEntity interface.

Jan


Re: AutoCompleteTextField: converter seems to be ignored

2010-08-20 Thread Alexandros Karypidis



However, wicket never calls the getConverter() method and simply uses
SomePOJO.toString() to retrieve the text for the choices. What am I
doing wrong?
One possibility is that in all the nested classes in the typical 
Wicket source file you have added the method to the wrong class. Try 
adding @Override to indicate that you intend to override a superclass 
method, and see if the compiler or IDE complains
Good idea but unfortunately that's not it. The method in the correct 
place (within an anonymous class extending AutoCompleteTextField) and 
already has an @Override.


In fact, the converter does get called, but only after I've made a 
selection. By then, the "type" argument is already a java.lang.String.


After looking at Wicket's source code, I've found that AutoTextField 
does not use converters. Instead, you need to declare a renderer as follows:


IAutoCompleteRenderer myRenderer = new 
AbstractAutoCompleteTextRenderer() {

@Override
protected String getTextValue(SomePOJO object) {
return ;
}
};


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: AutoCompleteTextField: converter seems to be ignored

2010-08-20 Thread Alexandros Karypidis

 On 20/8/2010 09:23, Wilhelmsen Tor Iver wrote:

However, wicket never calls the getConverter() method and simply uses
SomePOJO.toString() to retrieve the text for the choices. What am I
doing wrong?

One possibility is that in all the nested classes in the typical Wicket source 
file you have added the method to the wrong class. Try adding @Override to 
indicate that you intend to override a superclass method, and see if the 
compiler or IDE complains
Good idea but unfortunately that's not it. The method in the correct 
place (within an anonymous class extending AutoCompleteTextField) and 
already has an @Override.


In fact, the converter does get called, but only after I've made a 
selection. By then, the "type" argument is already a java.lang.String.



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: AutoCompleteTextField: converter seems to be ignored

2010-08-19 Thread Wilhelmsen Tor Iver
> However, wicket never calls the getConverter() method and simply uses
> SomePOJO.toString() to retrieve the text for the choices. What am I
> doing wrong?

One possibility is that in all the nested classes in the typical Wicket source 
file you have added the method to the wrong class. Try adding @Override to 
indicate that you intend to override a superclass method, and see if the 
compiler or IDE complains.

- Tor Iver

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



AutoCompleteTextField: converter seems to be ignored

2010-08-19 Thread Alexandros Karypidis

 Hi,

I'm using AutoCompleteTextFiled with Wicket 1.4.9.  My model is a POJO 
that is specified as a generic:


searchTextField = new AutoCompleteTextField(...

Therefore I return an Iterator of such POJOs with:

protected Iterator getChoices(String input) {

I'm trying to customize the text displayed (which defaults to 
SomePOJO.toString()) using a converter:


public IConverter getConverter(Class type) {
System.err.println("Looking up converter for: " + 
type.getCanonicalName());

if (SomePOJO.class.isAssignableFrom(type)) {
return new IConverter() { ...

However, wicket never calls the getConverter() method and simply uses 
SomePOJO.toString() to retrieve the text for the choices. What am I 
doing wrong?




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Converter for AjaxEditableMultiLineLabel

2009-12-25 Thread Alec Swan
Thanks, I followed your suggestion and overrode
AjaxEditableMultiLineLabel#newLabel() method.

Now I am trying to unit-test the content of the displayed label using
WicketTester. However, I cannot use WicketTester#assertLabel() because
AjaxEditableMultiLineLabel is a Panel and not a Label.

Does anybody know how to access the display value of
AjaxEditableMultiLineLabel?

Thanks,

Alec

On Fri, Dec 25, 2009 at 2:10 PM, vineet semwal
wrote:

> it doesn't use converter even for the multilinelabel..
> some months ago i needed converter for multilinelabel inside
> ajaxeditablemultilinelabel,
>  i  subclassed ajaxeditablemultilinelabel and provided converter logic for
> multilinelabel there,
> it didn't take much time ;)
>
>
> On Sat, Dec 26, 2009 at 2:02 AM, Sven Meier  wrote:
>
> > AjaxEditableMultiLineLabel doesn't use its converter for the wrapped
> editor
> > as AjaxEditableLabel does - see #newEditor().
> >
> > You should create a RFE in JIRA.
> >
> > Sven
> >
> > Alec Swan wrote:
> >
> >> I am using  to allow the user to enter a Velocity
> >>
> >> template in the editor and then preview the bound template content in
> the
> >> label.
> >>
> >> I created a TemplateConverter class and overrode
> >> AjaxEditableMultiLineLabel#getConverter() method to return an instance
> of
> >> TemplateConverter. However, the
> AjaxEditableMultiLineLabel#getConverter()
> >> is
> >> never called.
> >>
> >> What am I doing wring and what is the recommended way to do this?
> >>
> >> Thanks,
> >>
> >> Alec
> >>
> >>
> >>
> >
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
> >
>
>
> --
> regards,
> Vineet Semwal
>


Re: Converter for AjaxEditableMultiLineLabel

2009-12-25 Thread vineet semwal
it doesn't use converter even for the multilinelabel..
some months ago i needed converter for multilinelabel inside
ajaxeditablemultilinelabel,
  i  subclassed ajaxeditablemultilinelabel and provided converter logic for
multilinelabel there,
it didn't take much time ;)


On Sat, Dec 26, 2009 at 2:02 AM, Sven Meier  wrote:

> AjaxEditableMultiLineLabel doesn't use its converter for the wrapped editor
> as AjaxEditableLabel does - see #newEditor().
>
> You should create a RFE in JIRA.
>
> Sven
>
> Alec Swan wrote:
>
>> I am using  to allow the user to enter a Velocity
>>
>> template in the editor and then preview the bound template content in the
>> label.
>>
>> I created a TemplateConverter class and overrode
>> AjaxEditableMultiLineLabel#getConverter() method to return an instance of
>> TemplateConverter. However, the AjaxEditableMultiLineLabel#getConverter()
>> is
>> never called.
>>
>> What am I doing wring and what is the recommended way to do this?
>>
>> Thanks,
>>
>> Alec
>>
>>
>>
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
regards,
Vineet Semwal


Re: Converter for AjaxEditableMultiLineLabel

2009-12-25 Thread Sven Meier

AjaxEditableMultiLineLabel doesn't use its converter for the wrapped editor as 
AjaxEditableLabel does - see #newEditor().

You should create a RFE in JIRA.

Sven

Alec Swan wrote:

I am using  to allow the user to enter a Velocity
template in the editor and then preview the bound template content in the
label.

I created a TemplateConverter class and overrode
AjaxEditableMultiLineLabel#getConverter() method to return an instance of
TemplateConverter. However, the AjaxEditableMultiLineLabel#getConverter() is
never called.

What am I doing wring and what is the recommended way to do this?

Thanks,

Alec

  



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Converter for AjaxEditableMultiLineLabel

2009-12-25 Thread Alec Swan
I am using AjaxEditableMultiLineLabel to allow the user to enter a Velocity
template in the editor and then preview the bound template content in the
label.

I created a TemplateConverter class and overrode
AjaxEditableMultiLineLabel#getConverter() method to return an instance of
TemplateConverter. However, the AjaxEditableMultiLineLabel#getConverter() is
never called.

What am I doing wring and what is the recommended way to do this?

Thanks,

Alec


Re: Converter Problem

2009-07-08 Thread jpalmer1026

For what it's worth, I added the following Calendar code to the end of the
method, which fixed the problem, but I'm thinking there has to be a better
way to handle this.

public Date convertToObject(String value, Locale locale) {
final Pattern pattern = Pattern.compile(REGEX_PATTERN);
if (StringUtils.isNotBlank(value) &&
!pattern.matcher(value).matches()) {
throw new ConversionException("Invalid date format");
}
Date d = super.convertToObject(value, locale);
Calendar c = Calendar.getInstance();
c.setTime(d);
c.add(Calendar.HOUR, 8);
c.set(Calendar.HOUR, 0);
return c.getTime();
}


jpalmer1026 wrote:
> 
> 
> The DateTime I was referring to is in the
> org.apache.wicket.datetime.DateConverter class, so I have no way of
> modifying it. Any other ideas?
> 
> 
> Stijn Maller wrote:
>> 
>> Looking at your datepattern you should be using LocalDate instead of
>> DateTime, as you don't have a time or a timezone anyway. IMVHO this
>> should
>> solve all your problems.
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/Converter-Problem-tp24378227p24392993.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
> 
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Converter-Problem-tp24378227p24399351.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Converter Problem

2009-07-08 Thread jpalmer1026

The DateTime I was referring to is in the
org.apache.wicket.datetime.DateConverter class, so I have no way of
modifying it. Any other ideas?


Stijn Maller wrote:
> 
> Looking at your datepattern you should be using LocalDate instead of
> DateTime, as you don't have a time or a timezone anyway. IMVHO this should
> solve all your problems.
> 

-- 
View this message in context: 
http://www.nabble.com/Converter-Problem-tp24378227p24392993.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Converter Problem

2009-07-08 Thread jpalmer1026

The DateTime I was referring to is in the
org.apache.wicket.datetime.DateConverter class, so I have no way of
modifying it. Any other ideas?


Stijn Maller wrote:
> 
> Looking at your datepattern you should be using LocalDate instead of
> DateTime, as you don't have a time or a timezone anyway. IMVHO this should
> solve all your problems.
> 

-- 
View this message in context: 
http://www.nabble.com/Converter-Problem-tp24378227p24392990.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Converter Problem

2009-07-08 Thread Stijn Maller

Looking at your datepattern you should be using LocalDate instead of
DateTime, as you don't have a time or a timezone anyway. IMVHO this should
solve all your problems.
-- 
View this message in context: 
http://www.nabble.com/Converter-Problem-tp24378227p24391721.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Using Converter with DropDownChoice

2009-07-07 Thread Marat Radchenko
What model type to you have? Did you call setType on component?
2009/7/7, Christoph Drießen :
> Hi all,
>
>  I'm trying to use a Converter with a DropDownChoice overriding the
> getConverter(Class type) method. Unfortunately this method never gets
> called.
>  Any ideas?
>
>  Christoph
>
>
>
> -
>  To unsubscribe, e-mail:
> users-unsubscr...@wicket.apache.org
>  For additional commands, e-mail: users-h...@wicket.apache.org
>
>

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Converter Problem

2009-07-07 Thread Stefan Malmesjö

The "format.parseDateTime" can do some tricky stuff, it seems:

"Parses a datetime from the given text, returning a new DateTime.

The parse will use the zone and chronology specified on this formatter.

If the text contains a time zone string then that will be taken into 
account in adjusting the time of day as follows. If the 
||withOffsetParsed() 
|| 
has been called, then the resulting DateTime will have a fixed offset 
based on the parsed time zone. Otherwise the resulting DateTime will 
have the zone of this formatter, but the parsed zone may have caused the 
time to be adjusted."


Can you debug step into that and see if anything funky happens there?

/Stefan



On 2009-07-07 22:47, jpalmer1026 wrote:

I did a little bit of digging and it appears that the problem is in the
convertToObject() in the org.apache.wicket.datetime.DateConverter class.
Specifically, the return date.ToDate() line in the following code:

if (applyTimeZoneDifference)
{
TimeZone zone = getClientTimeZone();
...
}
else
{
try
{
DateTime date = format.parseDateTime(value);
return date.toDate();
}
}


jpalmer1026 wrote:
   

I was thinking the same thing but, as you pointed out, I explicitly set it
to false, so I'm not sure why it's behaving this way. I tried setting it
to true just as an experiment but the results were the same. Has anyone
else seen this?


Stefan Malmesjö wrote:
 

Could this have anything to do with applyTimeZoneDifference in
PatterDateConverter? It looks like you set it to false, so it shouldn't,
but still... it fits the description pretty well...
/Stefan

On 2009-07-07 19:44, jpalmer1...@mchsi.com wrote:
   

I am having issues with a custom component that I created. The
component's function is to ensure that the date entered adheres to the
format "^(\\d{2})/(\\d{2})/(\\d{4})$" The problem, though, is when the
form that contains the component is submitted, the date is converted
to the previous day's date. For example, if a date of 07/07/2009 is
entered, the value that gets submitted is 07/06/2009 at 19:00 CDT. My
code (2 classes) is as follows:

public class CustomDateTextField extends TextField {

 public CustomDateTextField(String id, IModel model, Class type) {
 super(id, model, type);
 add(new EzdecDatePicker());
 }

 public CustomDateTextField(String id, IModel model) {
 super(id, model);
 add(new EzdecDatePicker());
 }

 public CustomDateTextField(String id, Class type) {
 super(id, type);
 add(new EzdecDatePicker());
 }

 public CustomDateTextField(String id) {
 super(id);
 add(new EzdecDatePicker());
 }

 @Override
 public IConverter getConverter(Class  type) {
 return new StrictPatternDateConverter();
 }
}

public class StrictPatternDateConverter extends PatternDateConverter {

 public static final String REGEX_PATTERN =
 "^(\\d{2})/(\\d{2})/(\\d{4})$";

 public StrictPatternDateConverter() {
 super("MM/dd/", false);
 }

 @Override
 public Date convertToObject(String value, Locale locale) {
 final Pattern pattern = Pattern.compile(REGEX_PATTERN);
 if (StringUtils.isNotBlank(value)&&
!pattern.matcher(value).matches()) {
 throw new ConversionException("Invalid date format");
 }
 return super.convertToObject(value, locale);
 }
}
 


   
 


   




Re: Converter Problem

2009-07-07 Thread jpalmer1026

I did a little bit of digging and it appears that the problem is in the
convertToObject() in the org.apache.wicket.datetime.DateConverter class.
Specifically, the return date.ToDate() line in the following code:

if (applyTimeZoneDifference)
{
TimeZone zone = getClientTimeZone();
...
}
else
{
try
{
DateTime date = format.parseDateTime(value);
return date.toDate();
}
}


jpalmer1026 wrote:
> 
> I was thinking the same thing but, as you pointed out, I explicitly set it
> to false, so I'm not sure why it's behaving this way. I tried setting it
> to true just as an experiment but the results were the same. Has anyone
> else seen this?
> 
> 
> Stefan Malmesjö wrote:
>> 
>> Could this have anything to do with applyTimeZoneDifference in 
>> PatterDateConverter? It looks like you set it to false, so it shouldn't, 
>> but still... it fits the description pretty well...
>> /Stefan
>> 
>> On 2009-07-07 19:44, jpalmer1...@mchsi.com wrote:
>>> I am having issues with a custom component that I created. The 
>>> component's function is to ensure that the date entered adheres to the 
>>> format "^(\\d{2})/(\\d{2})/(\\d{4})$" The problem, though, is when the 
>>> form that contains the component is submitted, the date is converted 
>>> to the previous day's date. For example, if a date of 07/07/2009 is 
>>> entered, the value that gets submitted is 07/06/2009 at 19:00 CDT. My 
>>> code (2 classes) is as follows:
>>>
>>> public class CustomDateTextField extends TextField {
>>>
>>> public CustomDateTextField(String id, IModel model, Class type) {
>>> super(id, model, type);
>>> add(new EzdecDatePicker());
>>> }
>>>
>>> public CustomDateTextField(String id, IModel model) {
>>> super(id, model);
>>> add(new EzdecDatePicker());
>>> }
>>>
>>> public CustomDateTextField(String id, Class type) {
>>> super(id, type);
>>> add(new EzdecDatePicker());
>>> }
>>>
>>> public CustomDateTextField(String id) {
>>> super(id);
>>> add(new EzdecDatePicker());
>>> }
>>>
>>> @Override
>>> public IConverter getConverter(Class type) {
>>> return new StrictPatternDateConverter();
>>> }
>>> }
>>>
>>> public class StrictPatternDateConverter extends PatternDateConverter {
>>>
>>> public static final String REGEX_PATTERN =
>>> "^(\\d{2})/(\\d{2})/(\\d{4})$";
>>>
>>> public StrictPatternDateConverter() {
>>> super("MM/dd/yyyy", false);
>>> }
>>>
>>> @Override
>>> public Date convertToObject(String value, Locale locale) {
>>> final Pattern pattern = Pattern.compile(REGEX_PATTERN);
>>> if (StringUtils.isNotBlank(value) && 
>>> !pattern.matcher(value).matches()) {
>>> throw new ConversionException("Invalid date format");
>>> }
>>> return super.convertToObject(value, locale);
>>> }
>>> }
>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Converter-Problem-tp24378227p24381041.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Using Converter with DropDownChoice

2009-07-07 Thread Christoph Drießen

Hi all,

I'm trying to use a Converter with a DropDownChoice overriding the  
getConverter(Class type) method. Unfortunately this method never gets  
called.

Any ideas?

Christoph



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Using Converter with DropDownChoice

2009-07-07 Thread Christoph Drießen

James,

I'm not sure if this approach will solve my problem. This is what I  
try to do:


I'd like to display a drop down with the choices "today", "yesterday"  
and "all". Depending on the user's selection the model object's  
property which is of type Date shall be filled with either a Date  
object or null (upon "all" selection). The choice is connected to the  
model object through a PropertyModel.


Cheers,
c



Am 07.07.2009 um 14:01 schrieb James Carman:


Try using an IChoiceRenderer rather than a converter.

On Tue, Jul 7, 2009 at 7:45 AM, Christoph Drießen  wrote:


Hi all,

I'm trying to use a Converter with a DropDownChoice overriding the
getConverter(Class type) method. Unfortunately this method never gets
called.
Any ideas?

Christoph

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org





-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Using Converter with DropDownChoice

2009-07-07 Thread Christoph Drießen

James,

I'm not sure if this approach will solve my problem. This is what I  
try to do:


I'd like to display a drop down with the choices "today", "yesterday"  
and "all". Depending on the user's selection the model object's  
property which is of type Date shall be filled with either a Date  
object or null (upon "all" selection). The choice is connected to the  
model object through a PropertyModel.


Cheers,
c


Am 07.07.2009 um 14:01 schrieb James Carman:


Try using an IChoiceRenderer rather than a converter.

On Tue, Jul 7, 2009 at 7:45 AM, Christoph Drießen  wrote:


Hi all,

I'm trying to use a Converter with a DropDownChoice overriding the
getConverter(Class type) method. Unfortunately this method never gets
called.
Any ideas?

Christoph

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org





-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Converter Problem

2009-07-07 Thread jpalmer1026

I was thinking the same thing but, as you pointed out, I explicitly set it to
false, so I'm not sure why it's behaving this way. I tried setting it to
true just as an experiment but the results were the same. Has anyone else
seen this?


Stefan Malmesjö wrote:
> 
> Could this have anything to do with applyTimeZoneDifference in 
> PatterDateConverter? It looks like you set it to false, so it shouldn't, 
> but still... it fits the description pretty well...
> /Stefan
> 
> On 2009-07-07 19:44, jpalmer1...@mchsi.com wrote:
>> I am having issues with a custom component that I created. The 
>> component's function is to ensure that the date entered adheres to the 
>> format "^(\\d{2})/(\\d{2})/(\\d{4})$" The problem, though, is when the 
>> form that contains the component is submitted, the date is converted 
>> to the previous day's date. For example, if a date of 07/07/2009 is 
>> entered, the value that gets submitted is 07/06/2009 at 19:00 CDT. My 
>> code (2 classes) is as follows:
>>
>> public class CustomDateTextField extends TextField {
>>
>> public CustomDateTextField(String id, IModel model, Class type) {
>> super(id, model, type);
>> add(new EzdecDatePicker());
>> }
>>
>> public CustomDateTextField(String id, IModel model) {
>> super(id, model);
>> add(new EzdecDatePicker());
>> }
>>
>> public CustomDateTextField(String id, Class type) {
>> super(id, type);
>> add(new EzdecDatePicker());
>> }
>>
>> public CustomDateTextField(String id) {
>> super(id);
>> add(new EzdecDatePicker());
>> }
>>
>> @Override
>> public IConverter getConverter(Class type) {
>> return new StrictPatternDateConverter();
>> }
>> }
>>
>> public class StrictPatternDateConverter extends PatternDateConverter {
>>
>> public static final String REGEX_PATTERN =
>> "^(\\d{2})/(\\d{2})/(\\d{4})$";
>>
>> public StrictPatternDateConverter() {
>> super("MM/dd/", false);
>> }
>>
>> @Override
>> public Date convertToObject(String value, Locale locale) {
>> final Pattern pattern = Pattern.compile(REGEX_PATTERN);
>> if (StringUtils.isNotBlank(value) && 
>> !pattern.matcher(value).matches()) {
>> throw new ConversionException("Invalid date format");
>> }
>> return super.convertToObject(value, locale);
>> }
>> }
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Converter-Problem-tp24378227p24378982.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Converter Problem

2009-07-07 Thread Stefan Malmesjö
Could this have anything to do with applyTimeZoneDifference in 
PatterDateConverter? It looks like you set it to false, so it shouldn't, 
but still... it fits the description pretty well...

/Stefan

On 2009-07-07 19:44, jpalmer1...@mchsi.com wrote:
I am having issues with a custom component that I created. The 
component's function is to ensure that the date entered adheres to the 
format "^(\\d{2})/(\\d{2})/(\\d{4})$" The problem, though, is when the 
form that contains the component is submitted, the date is converted 
to the previous day's date. For example, if a date of 07/07/2009 is 
entered, the value that gets submitted is 07/06/2009 at 19:00 CDT. My 
code (2 classes) is as follows:


public class CustomDateTextField extends TextField {

public CustomDateTextField(String id, IModel model, Class type) {
super(id, model, type);
add(new EzdecDatePicker());
}

public CustomDateTextField(String id, IModel model) {
super(id, model);
add(new EzdecDatePicker());
}

public CustomDateTextField(String id, Class type) {
super(id, type);
add(new EzdecDatePicker());
}

public CustomDateTextField(String id) {
super(id);
add(new EzdecDatePicker());
}

@Override
public IConverter getConverter(Class type) {
return new StrictPatternDateConverter();
}
}

public class StrictPatternDateConverter extends PatternDateConverter {

public static final String REGEX_PATTERN =
"^(\\d{2})/(\\d{2})/(\\d{4})$";

public StrictPatternDateConverter() {
super("MM/dd/", false);
}

@Override
public Date convertToObject(String value, Locale locale) {
final Pattern pattern = Pattern.compile(REGEX_PATTERN);
if (StringUtils.isNotBlank(value) && 
!pattern.matcher(value).matches()) {

throw new ConversionException("Invalid date format");
}
return super.convertToObject(value, locale);
}
}




Converter Problem

2009-07-07 Thread jpalmer1026





I am having issues with a custom component that I created. The component's function is to ensure that the date entered adheres to the format "^(\\d{2})/(\\d{2})/(\\d{4})$" The problem, though, is when the form that contains the component is submitted, the date is converted to the previous day's date. For example, if a date of 07/07/2009 is entered, the value that gets submitted is 07/06/2009 at 19:00 CDT. My code (2 classes) is as follows:public class CustomDateTextField extends TextField {    public CustomDateTextField(String id, IModel model, Class type) {    super(id, model, type);    add(new EzdecDatePicker());    }    public CustomDateTextField(String id, IModel model) {    super(id, model);    add(new EzdecDatePicker());    }    public CustomDateTextField(String id, Class type) {    super(id, type);    add(new EzdecDatePicker());    }    public CustomDateTextField(String id) {    super(id);    add(new EzdecDatePicker());    }    @Override    public IConverter getConverter(Class type) {    return new StrictPatternDateConverter();    }}public class StrictPatternDateConverter extends PatternDateConverter {    public static final String REGEX_PATTERN =    "^(\\d{2})/(\\d{2})/(\\d{4})$";    public StrictPatternDateConverter() {    super("MM/dd/", false);    }    @Override    public Date convertToObject(String value, Locale locale) {    final Pattern pattern = Pattern.compile(REGEX_PATTERN);    if (StringUtils.isNotBlank(value) && !pattern.matcher(value).matches()) {    throw new ConversionException("Invalid date format");    }    return super.convertToObject(value, locale);    }}






Re: Using Converter with DropDownChoice

2009-07-07 Thread Christoph Drießen

I wasn't very clear in describing what I'm trying to achieve.

The drop down is part of a form, filling a criteria object to perform  
queries. This criteria object has actually nothing more than a few  
properties, one of them being a "since" property to query the database  
for entities having a timestamp greater than "since". All properties  
are null by default to indicate that the properties is not taken into  
account for the query. The form now offers the user some predefined  
possibilities to set the "since". This is "today", "yesterday" and  
"all". What I see is that I can fill the id of e.g. "today" with the  
timestamp of today and so the used date converter will work. But  
actually this is not what I want. I'd rather like to receive e.g.  
"today" and then convert it to the date I need.


The question for me is why getConverter(..) seems not to be called in  
the Choice classes but e.g. in TextField.



Am 07.07.2009 um 17:08 schrieb James Carman:

Your DropDownChoice should be a DropDownChoice.  Then, the  
"things"
shown by the DropDownChoice are Date objects.  You want to render  
those
dates (one of them is a null) using String values (known as the  
display
value to the renderer).  You might have to set up a localized  
message to get
"all" to display for null, though (rather than "Choose One" or  
whatever).


On Tue, Jul 7, 2009 at 10:55 AM, Christoph Drießen  wrote:

I cannot see how to get the input converted into a Date. The other  
way
round seems clear to me, but how do I get "all" or "today" into a  
Date with
a renderer? Isn't the renderer just for rendering like it's name  
suggests?

Or am I missing something here?


Am 07.07.2009 um 16:32 schrieb James Carman:


So, why wouldn't a renderer work for you?  You could use a map-based

renderer if you wish.

On Tue, Jul 7, 2009 at 9:16 AM, Christoph Drießen   
wrote:


James,


I'm not sure if this approach will solve my problem. This is what  
I try

to
do:

I'd like to display a drop down with the choices "today",  
"yesterday" and
"all". Depending on the user's selection the model object's  
property

which
is of type Date shall be filled with either a Date object or null  
(upon
"all" selection). The choice is connected to the model object  
through a

PropertyModel.

Cheers,
c


Am 07.07.2009 um 14:01 schrieb James Carman:


Try using an IChoiceRenderer rather than a converter.



On Tue, Jul 7, 2009 at 7:45 AM, Christoph Drießen   
wrote:


Hi all,



I'm trying to use a Converter with a DropDownChoice overriding  
the
getConverter(Class type) method. Unfortunately this method  
never gets

called.
Any ideas?

Christoph

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org





-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org





-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org





-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Using Converter with DropDownChoice

2009-07-07 Thread James Carman
Your DropDownChoice should be a DropDownChoice.  Then, the "things"
shown by the DropDownChoice are Date objects.  You want to render those
dates (one of them is a null) using String values (known as the display
value to the renderer).  You might have to set up a localized message to get
"all" to display for null, though (rather than "Choose One" or whatever).

On Tue, Jul 7, 2009 at 10:55 AM, Christoph Drießen  wrote:

> I cannot see how to get the input converted into a Date. The other way
> round seems clear to me, but how do I get "all" or "today" into a Date with
> a renderer? Isn't the renderer just for rendering like it's name suggests?
> Or am I missing something here?
>
>
> Am 07.07.2009 um 16:32 schrieb James Carman:
>
>
>  So, why wouldn't a renderer work for you?  You could use a map-based
>> renderer if you wish.
>>
>> On Tue, Jul 7, 2009 at 9:16 AM, Christoph Drießen  wrote:
>>
>>  James,
>>>
>>> I'm not sure if this approach will solve my problem. This is what I try
>>> to
>>> do:
>>>
>>> I'd like to display a drop down with the choices "today", "yesterday" and
>>> "all". Depending on the user's selection the model object's property
>>> which
>>> is of type Date shall be filled with either a Date object or null (upon
>>> "all" selection). The choice is connected to the model object through a
>>> PropertyModel.
>>>
>>> Cheers,
>>> c
>>>
>>>
>>> Am 07.07.2009 um 14:01 schrieb James Carman:
>>>
>>>
>>> Try using an IChoiceRenderer rather than a converter.
>>>
>>>>
>>>> On Tue, Jul 7, 2009 at 7:45 AM, Christoph Drießen  wrote:
>>>>
>>>> Hi all,
>>>>
>>>>>
>>>>> I'm trying to use a Converter with a DropDownChoice overriding the
>>>>> getConverter(Class type) method. Unfortunately this method never gets
>>>>> called.
>>>>> Any ideas?
>>>>>
>>>>> Christoph
>>>>>
>>>>> -
>>>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>>>>> For additional commands, e-mail: users-h...@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>> -
>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>>> For additional commands, e-mail: users-h...@wicket.apache.org
>>>
>>>
>>>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: Using Converter with DropDownChoice

2009-07-07 Thread Christoph Drießen
I cannot see how to get the input converted into a Date. The other way  
round seems clear to me, but how do I get "all" or "today" into a Date  
with a renderer? Isn't the renderer just for rendering like it's name  
suggests? Or am I missing something here?



Am 07.07.2009 um 16:32 schrieb James Carman:


So, why wouldn't a renderer work for you?  You could use a map-based
renderer if you wish.

On Tue, Jul 7, 2009 at 9:16 AM, Christoph Drießen  wrote:


James,

I'm not sure if this approach will solve my problem. This is what I  
try to

do:

I'd like to display a drop down with the choices "today",  
"yesterday" and
"all". Depending on the user's selection the model object's  
property which
is of type Date shall be filled with either a Date object or null  
(upon
"all" selection). The choice is connected to the model object  
through a

PropertyModel.

Cheers,
c


Am 07.07.2009 um 14:01 schrieb James Carman:


Try using an IChoiceRenderer rather than a converter.


On Tue, Jul 7, 2009 at 7:45 AM, Christoph Drießen   
wrote:


Hi all,


I'm trying to use a Converter with a DropDownChoice overriding the
getConverter(Class type) method. Unfortunately this method never  
gets

called.
Any ideas?

Christoph

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org





-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org





-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Using Converter with DropDownChoice

2009-07-07 Thread James Carman
So, why wouldn't a renderer work for you?  You could use a map-based
renderer if you wish.

On Tue, Jul 7, 2009 at 9:16 AM, Christoph Drießen  wrote:

> James,
>
> I'm not sure if this approach will solve my problem. This is what I try to
> do:
>
> I'd like to display a drop down with the choices "today", "yesterday" and
> "all". Depending on the user's selection the model object's property which
> is of type Date shall be filled with either a Date object or null (upon
> "all" selection). The choice is connected to the model object through a
> PropertyModel.
>
> Cheers,
> c
>
>
> Am 07.07.2009 um 14:01 schrieb James Carman:
>
>
>  Try using an IChoiceRenderer rather than a converter.
>>
>> On Tue, Jul 7, 2009 at 7:45 AM, Christoph Drießen  wrote:
>>
>>  Hi all,
>>>
>>> I'm trying to use a Converter with a DropDownChoice overriding the
>>> getConverter(Class type) method. Unfortunately this method never gets
>>> called.
>>> Any ideas?
>>>
>>> Christoph
>>>
>>> -
>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>>> For additional commands, e-mail: users-h...@wicket.apache.org
>>>
>>>
>>>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: Using Converter with DropDownChoice

2009-07-07 Thread Christoph Drießen

James,

I'm not sure if this approach will solve my problem. This is what I  
try to do:


I'd like to display a drop down with the choices "today", "yesterday"  
and "all". Depending on the user's selection the model object's  
property which is of type Date shall be filled with either a Date  
object or null (upon "all" selection). The choice is connected to the  
model object through a PropertyModel.


Cheers,
c


Am 07.07.2009 um 14:01 schrieb James Carman:


Try using an IChoiceRenderer rather than a converter.

On Tue, Jul 7, 2009 at 7:45 AM, Christoph Drießen  wrote:


Hi all,

I'm trying to use a Converter with a DropDownChoice overriding the
getConverter(Class type) method. Unfortunately this method never gets
called.
Any ideas?

Christoph

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org





-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Using Converter with DropDownChoice

2009-07-07 Thread James Carman
Try using an IChoiceRenderer rather than a converter.

On Tue, Jul 7, 2009 at 7:45 AM, Christoph Drießen  wrote:

> Hi all,
>
> I'm trying to use a Converter with a DropDownChoice overriding the
> getConverter(Class type) method. Unfortunately this method never gets
> called.
> Any ideas?
>
> Christoph
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Using Converter with DropDownChoice

2009-07-07 Thread Christoph Drießen

Hi all,

I'm trying to use a Converter with a DropDownChoice overriding the  
getConverter(Class type) method. Unfortunately this method never gets  
called.

Any ideas?

Christoph

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Datatable columns converter

2009-05-13 Thread alf.redo

Hi Michael, thank you for your suggestion.
what do you think about overriding the AbstractColumn#populateItem() to add
a Label to the cellItem and setting up a proper IConverter to that
component? 

bye

alf


Michael O'Cleirigh wrote:
> 
> 
> This question came up last week aswell, here is an example of how you to 
> subclass PropertyColumn to convert an integer into an arbitrary string:
> 
> 
> http://www.nabble.com/Re%3A-How-to-manipulate-values-in-a-data-table--p23413680.html
> 
> Essentially you wrap the PropertyModel with a custom IModel 
> implementation that does the conversion you want (on each cell).  Then 
> you build the DataTable using your custom column implementation.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Datatable-columns-converter-tp23502460p23519993.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Datatable columns converter

2009-05-12 Thread Michael O'Cleirigh

Hi Alfredo,

This question came up last week aswell, here is an example of how you to 
subclass PropertyColumn to convert an integer into an arbitrary string:


http://www.nabble.com/Re%3A-How-to-manipulate-values-in-a-data-table--p23413680.html

Essentially you wrap the PropertyModel with a custom IModel 
implementation that does the conversion you want (on each cell).  Then 
you build the DataTable using your custom column implementation.


Regards,

Mike


Hi,
I can't figure out the best way to define something like a 
object-to-string converter to add to a DataTable's column 
(PropertyColumn).
I have an Integer in my model and I want to display a proper String to 
the user by a defined mapping.


Thank you

alf


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Datatable columns converter

2009-05-12 Thread Alfredo Aleandri

Hi,
I can't figure out the best way to define something like a 
object-to-string converter to add to a DataTable's column (PropertyColumn).
I have an Integer in my model and I want to display a proper String to 
the user by a defined mapping.


Thank you

alf


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: inmethod grid & converter/formatter?

2009-05-07 Thread Brill Pappin

that would certainly work, but I'd lose the editor column I'm using ;)
All i really need is to be able to add a display formatter so i can  
truncate the content with an ellipsis. Even a method i could override  
when its outputting the label content would work. If there is such a  
method, I'm unsure where it is.


I constantly need to reformat some content into something the user can  
see. but with a inmethod grid, you actually need a display formatter  
and an editor formatter.


- Brill Pappin

On 7-May-09, at 4:21 PM, Ryan McKinley wrote:


what about just implementing AbstractLightWeightColumn#newCell?

this lets you write text directly to the output...


On May 7, 2009, at 4:15 PM, Brill Pappin wrote:

I'm spiking on the inmethod grid components from wicketstuff (1.4- 
SNAPSHOT)


I need to be able to format the data in columns and or modify it  
for view only columns.


the specific case is a description field that sometime needs and  
ellipsis.


I can't see any way to add converters or formatters to the column  
models.. have anyone else tried this or come up with a solution?


So far the only solution i have is to wrap my Pojo's in another  
pojo and provide read-only access to one of the fields.


- Brill Pappin






smime.p7s
Description: S/MIME cryptographic signature


Re: inmethod grid & converter/formatter?

2009-05-07 Thread Ryan McKinley

what about just implementing AbstractLightWeightColumn#newCell?

this lets you write text directly to the output...


On May 7, 2009, at 4:15 PM, Brill Pappin wrote:

I'm spiking on the inmethod grid components from wicketstuff (1.4- 
SNAPSHOT)


I need to be able to format the data in columns and or modify it for  
view only columns.


the specific case is a description field that sometime needs and  
ellipsis.


I can't see any way to add converters or formatters to the column  
models.. have anyone else tried this or come up with a solution?


So far the only solution i have is to wrap my Pojo's in another pojo  
and provide read-only access to one of the fields.


- Brill Pappin




inmethod grid & converter/formatter?

2009-05-07 Thread Brill Pappin
I'm spiking on the inmethod grid components from wicketstuff (1.4- 
SNAPSHOT)


I need to be able to format the data in columns and or modify it for  
view only columns.


the specific case is a description field that sometime needs and  
ellipsis.


I can't see any way to add converters or formatters to the column  
models.. have anyone else tried this or come up with a solution?


So far the only solution i have is to wrap my Pojo's in another pojo  
and provide read-only access to one of the fields.


- Brill Pappin

smime.p7s
Description: S/MIME cryptographic signature


Re: radiochoice and propertymodel ignoring converter (wicket 1.3.5)

2009-05-06 Thread Igor Vaynberg
that kind of conversion should go into ichoicerenderer implementation.
the converter is used to convert between browser's "on"/"" values to
true and false.

this is the sig of the constructor from 1.4, hopefully generics will
clear up how this works for you

public RadioChoice(final String id, IModel model, final List choices, IChoiceRenderer renderer)

in your case T is Boolean.

-igor

On Wed, May 6, 2009 at 2:18 PM, james o'brien  wrote:
> I have a custom converter registered for Boolean.class that converts "yes"
> to Boolean(true) and "no" to Boolean(false).  When the RadioChoice loads the
> converter is never called.
>
>
> 
>
> private static final List IRREGULAR_HEARTBEAT =
> Arrays.asList(newString[] {
> "yes", "no" });
>
> RadioChoice irregular = new RadioChoice("irregularHeartbeat",
> newPropertyModel(bloodPressure,
>
> "irregularHeartbeat"), IRREGULAR_HEARTBEAT).setSuffix(" ");
>
>
> BloodPressure Object:
>
>
> public Boolean isIrregularHeartbeat() {
>
> return bloodPressure.isIrregularHeartbeat();
>
> }
>
> public void setIrregularHeartbeat(Boolean value) {
>
> bloodPressure.setIrregularHeartbeat(value);
>
> }
>
> 
>
> Thanks,
> --jim
>

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



radiochoice and propertymodel ignoring converter (wicket 1.3.5)

2009-05-06 Thread james o'brien
I have a custom converter registered for Boolean.class that converts "yes"
to Boolean(true) and "no" to Boolean(false).  When the RadioChoice loads the
converter is never called.




private static final List IRREGULAR_HEARTBEAT =
Arrays.asList(newString[] {
"yes", "no" });

RadioChoice irregular = new RadioChoice("irregularHeartbeat",
newPropertyModel(bloodPressure,

"irregularHeartbeat"), IRREGULAR_HEARTBEAT).setSuffix(" ");


BloodPressure Object:


public Boolean isIrregularHeartbeat() {

return bloodPressure.isIrregularHeartbeat();

}

public void setIrregularHeartbeat(Boolean value) {

bloodPressure.setIrregularHeartbeat(value);

}



Thanks,
--jim


Re: java.sql.Timestamp converter bug in 1.4RC2

2009-04-23 Thread Igor Vaynberg
sounds like a bug, please open a jira issue.

-igor

On Thu, Apr 23, 2009 at 12:47 AM, Steve Flasby  wrote:
> Chaps,
>
>  Ive just noticed that SqlTimestampConverter appears to be broken.
>  I expected it to produce a Date/Time as output, but it only produces
>  a time. SqlTimeConverter prints a simple time as I expected.
>
> Looking in the code SqlTimestampConverter::convertToString uses:
>
> DateFormat format = DateFormat.getTimeInstance(dateFormat, locale);
>
> when I think it should say:
>
> DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT,
> DateFormat.SHORT, locale);
>
> instead.
>
> convertToObject would need a corresponding change to:
> DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT,
> DateFormat.SHORT, locale);
>
>
>
> Am I right or is this behavior by design?
>
>
> Cheers - Steve
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



java.sql.Timestamp converter bug in 1.4RC2

2009-04-23 Thread Steve Flasby

Chaps,

  Ive just noticed that SqlTimestampConverter appears to be broken.
  I expected it to produce a Date/Time as output, but it only produces
  a time. SqlTimeConverter prints a simple time as I expected.

Looking in the code SqlTimestampConverter::convertToString uses:

DateFormat format = DateFormat.getTimeInstance(dateFormat, locale);

when I think it should say:

DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, 
DateFormat.SHORT, locale);


instead.

convertToObject would need a corresponding change to:
DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, 
DateFormat.SHORT, locale);




Am I right or is this behavior by design?


Cheers - Steve


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Form values lost on converter error when inside table

2008-09-12 Thread Serkan Camurcuoglu
I think you can make a quick test by implementing a simple reuse 
strategy which directly returns the existingItems iterator..



Lorenzo Bolzani wrote:

2008/9/12 Serkan Camurcuoglu <[EMAIL PROTECTED]>:
  

if you were using a listview, you should have called setReuseItems(true) on
it.. Maybe there exists something similar for DataView.. ListView javadoc
says:

"If you nest a ListView in a Form, ALLWAYS set this property to true, as
otherwise validation will not work properly. "




Hi Serkan,
think you very much for the reply, we looked for something similar but
we completely missed that.
I think could be useful to report the same warning in the DataView and
DataTable javadoc (or maybe just Form).

Anyway in our example we are using a DataView and that method is not present.
We found a setReuseStrategy both on DataView and on DataTable but none
of the provided strategies (default and reuseIfEquals) worked.

What is the ReuseStrategy providing a behavior equivalent to
setReuseItems(true)?

I suspect is ReuseIfModelsEqualStrategy and we have to define a custom
model with the correct equals but I'm not sure and I'm looking for a
confirm.


Thanks again.

Bye

Lorenzo

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Form values lost on converter error when inside table

2008-09-12 Thread Lorenzo Bolzani
2008/9/12 Serkan Camurcuoglu <[EMAIL PROTECTED]>:
> if you were using a listview, you should have called setReuseItems(true) on
> it.. Maybe there exists something similar for DataView.. ListView javadoc
> says:
>
> "If you nest a ListView in a Form, ALLWAYS set this property to true, as
> otherwise validation will not work properly. "
>

Hi Serkan,
think you very much for the reply, we looked for something similar but
we completely missed that.
I think could be useful to report the same warning in the DataView and
DataTable javadoc (or maybe just Form).

Anyway in our example we are using a DataView and that method is not present.
We found a setReuseStrategy both on DataView and on DataTable but none
of the provided strategies (default and reuseIfEquals) worked.

What is the ReuseStrategy providing a behavior equivalent to
setReuseItems(true)?

I suspect is ReuseIfModelsEqualStrategy and we have to define a custom
model with the correct equals but I'm not sure and I'm looking for a
confirm.


Thanks again.

Bye

Lorenzo

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Form values lost on converter error when inside table

2008-09-12 Thread Serkan Camurcuoglu
if you were using a listview, you should have called setReuseItems(true) 
on it.. Maybe there exists something similar for DataView.. ListView 
javadoc says:


"If you nest a ListView in a Form, ALLWAYS set this property to true, as 
otherwise validation will not work properly. "




Lorenzo Bolzani wrote:

Hi,
I'need to display some editable values inside an HTML table.
The form contains both string and numeric values. If I submit an
invalid numeric value an error is reporter but all other values are
lost.

Using a simple form this does not happens, it happens only when we had
the "table part". I think we have done something wrong with the
dataview and the dataProvider but we cannot see what's wrong.

Following this article (we skipped the detachable part)

http://liminescence.blogspot.com/2007/12/wicket-html-table-implementation.html

I defined a very simple DataProvider

protected List readAll() {
  return Arrays.asList(new Bean("a", 1), new Bean("b", 2));
}

a simple dataView

@Override
protected void populateItem(Item item) {
   Bean bean = (Bean) item.getModelObject();
   item.setModel(new CompoundPropertyModel(bean));
   item.add(new TextField("rock"));
   item.add(new TextField("number"));
}

and added this to a form

 final DataView personDataView = new PersonDataView("beanList",
dataProvider);
 form.add(personDataView);

This is the markup

 
   Rock
  Number
   
  
   
  
  
   
  
   
 

When I type an invalid value for the "number" field the "rock" field
is reset to the default value and the input from the user is lost.

What are we doing wrong?


Thanks, bye

Lorenzo

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Form values lost on converter error when inside table

2008-09-12 Thread Lorenzo Bolzani
Hi,
I'need to display some editable values inside an HTML table.
The form contains both string and numeric values. If I submit an
invalid numeric value an error is reporter but all other values are
lost.

Using a simple form this does not happens, it happens only when we had
the "table part". I think we have done something wrong with the
dataview and the dataProvider but we cannot see what's wrong.

Following this article (we skipped the detachable part)

http://liminescence.blogspot.com/2007/12/wicket-html-table-implementation.html

I defined a very simple DataProvider

protected List readAll() {
  return Arrays.asList(new Bean("a", 1), new Bean("b", 2));
}

a simple dataView

@Override
protected void populateItem(Item item) {
   Bean bean = (Bean) item.getModelObject();
   item.setModel(new CompoundPropertyModel(bean));
   item.add(new TextField("rock"));
   item.add(new TextField("number"));
}

and added this to a form

 final DataView personDataView = new PersonDataView("beanList",
dataProvider);
 form.add(personDataView);

This is the markup

 
   Rock
  Number
   
  
   
  
  
   
  
   
 

When I type an invalid value for the "number" field the "rock" field
is reset to the default value and the input from the user is lost.

What are we doing wrong?


Thanks, bye

Lorenzo

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: converter can not convert org.myproject.Something to a string

2008-05-05 Thread Eelco Hillenius
On Mon, May 5, 2008 at 5:56 AM, Johan Compagner <[EMAIL PROTECTED]> wrote:
> that is a wrong check yes
>  its removed.

JIRA?

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: converter can not convert org.myproject.Something to a string

2008-05-05 Thread Johan Compagner
that is a wrong check yes
its removed.

On Mon, May 5, 2008 at 2:07 PM, Leszek Gawron <[EMAIL PROTECTED]> wrote:

> I started getting these as soon as I have used latest wicket trunk in my
> project:
>
>  Caused by: java.lang.IllegalArgumentException: converter can not convert
> > com.mobilebox.pfs.ranking.model.Sex to a string
> >at
> > org.apache.wicket.markup.html.form.AbstractChoice.appendOptionHtml(AbstractChoice.java:392)
> >at
> > org.apache.wicket.markup.html.form.AbstractChoice.onComponentTagBody(AbstractChoice.java:361)
> >at
> > org.apache.wicket.Component.renderComponent(Component.java:2531)
> >
>
>
> This leads to:
>
> protected void appendOptionHtml(AppendingStringBuffer buffer, E
> > choice, int index,
> >String selected)
> >{
> >T objectValue = (T)renderer.getDisplayValue(choice);
> >Class objectClass = (Class)(objectValue == null ?
> > null : objectValue.getClass());
> >
> >String displayValue = "";
> >    if (objectClass != null && objectClass != String.class)
> >{
> >final IConverter converter =
> > this.getConverter(objectClass);
> >
> >if
> > (!converter.getClass().isAssignableFrom(objectClass))
> >throw new
> > IllegalArgumentException("converter can not convert " +
> >objectClass.getName() + " to a
> > string");
> >
> >displayValue =
> > converter.convertToString(objectValue, getLocale());
> >}
> >
>
> The check does not seem correct. How can converter class be ever
> assignable to an model object class? Or am I missing something?
>
> --
> Leszek Gawron http://www.mobilebox.pl/krs.html
> CTO at MobileBox Ltd.
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


converter can not convert org.myproject.Something to a string

2008-05-05 Thread Leszek Gawron
I started getting these as soon as I have used latest wicket trunk in my 
project:



Caused by: java.lang.IllegalArgumentException: converter can not convert 
com.mobilebox.pfs.ranking.model.Sex to a string
at 
org.apache.wicket.markup.html.form.AbstractChoice.appendOptionHtml(AbstractChoice.java:392)
at 
org.apache.wicket.markup.html.form.AbstractChoice.onComponentTagBody(AbstractChoice.java:361)
at org.apache.wicket.Component.renderComponent(Component.java:2531)



This leads to:


protected void appendOptionHtml(AppendingStringBuffer buffer, E choice, 
int index,
String selected)
{
T objectValue = (T)renderer.getDisplayValue(choice);
Class objectClass = (Class)(objectValue == null ? null : 
objectValue.getClass());

String displayValue = "";
if (objectClass != null && objectClass != String.class)
{
    final IConverter converter = 
this.getConverter(objectClass);

if (!converter.getClass().isAssignableFrom(objectClass))
throw new IllegalArgumentException("converter can 
not convert " +
objectClass.getName() + " to a string");

displayValue = converter.convertToString(objectValue, 
getLocale());
}


The check does not seem correct. How can converter class be ever 
assignable to an model object class? Or am I missing something?


--
Leszek Gawron http://www.mobilebox.pl/krs.html
CTO at MobileBox Ltd.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: No built-in converter for Locale.class?

2008-04-18 Thread David Leangen

> no

Ok, thanks.

> what should such a converted do?
> And what should people type in as a text string?
> Most of the times locales are none editable select boxes or list choices

Not for personal consumption. :-)

I'm just testing out an annotation-based means of controlling page
parameters and control flow. I'm providing default values as Strings,
which means that some fields need converters.

This seems to clean up the pages quite a bit and simplify a lot the
processing of parameters. Maybe a useful feature for a later release of
Wicket?


Cheers,
David




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: No built-in converter for Locale.class?

2008-04-18 Thread Johan Compagner
no
what should such a converted do?
And what should people type in as a text string?
Most of the times locales are none editable select boxes or list choices

johan


On Fri, Apr 18, 2008 at 9:40 AM, David Leangen <[EMAIL PROTECTED]> wrote:

>
> Before I go and write my own, I just wanted to make sure that there is
> no built-in Converter for Locale.
>
> Looking through the code tells me that it's not supported by default. Is
> this so?
>
>
> Thanks,
> David
>
>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


No built-in converter for Locale.class?

2008-04-18 Thread David Leangen

Before I go and write my own, I just wanted to make sure that there is
no built-in Converter for Locale.

Looking through the code tells me that it's not supported by default. Is
this so?


Thanks,
David




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Converter gets called before Validator?

2008-03-13 Thread Igor Vaynberg
yes. validators work on types not strings, if they didnt then every
converter would have to attempt to type convert the string and deal
with conversion errors. so first we typeconvert, then run validators
on the result

-igor


On Thu, Mar 13, 2008 at 12:23 PM, Michael Mehrle <[EMAIL PROTECTED]> wrote:
> I read the update docs and at this time assume that my component's
>  Validator gets called AFTER the Converter. Is that correct for 1.3?
>
>  Michael
>
>
>  -
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Converter gets called before Validator?

2008-03-13 Thread Michael Mehrle
I read the update docs and at this time assume that my component's
Validator gets called AFTER the Converter. Is that correct for 1.3?

Michael


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: append a converter or coversion function

2008-03-10 Thread Johan Compagner
But we dont really know if a converter is provided
and how it is provided
you still can have that converter registered globally

If we would fix that we should somehow always call getConverter(Class)
and then the default 1 (if class is null?) should call back something of the
formcomponent
that does then what we do now.

something like

FormComponent.getConverter(Class clz)
{
 if (clz == null)
  {
return new IConverrter()
{
 convertToObject()
 {
// call what now convertInput does
   return convertValue(getInputAsArray());
 }
}
  }
  return super.getConverter(Class clz)
}

this way convertInput only have to call getConverter(type).convertToObject()

then getConverter() is always called.
But i dont know if that is really for the better
and what pittfalls we have because of that

johan

On Mon, Mar 10, 2008 at 11:55 PM, <[EMAIL PROTECTED]> wrote:

> I missed this one. That explains what I just posted.
> I'd say the logic could be
> if a converter is provided, the its stringtoobject is
> called. otherwise, check the set type and use the types'registered
> converter.
>
> >yes i think i explained that before
> >the first call you see is the getConverter call that calls
> objectToString()
> >on it
> >but if type is not set on a field getConverter is not called for
> >StringToObject
> >
> >johan
> >
> >
> >
> >On Mon, Mar 10, 2008 at 11:44 PM, <[EMAIL PROTECTED]> wrote:
> >
> >> Yes, but the issue I encountered that wicket first
> >>  call getConverter method, yet not using
> >> what was returned as supposed to be. Class based
> >> converter is a way to write one default converter
> >> for one class, but if a special converter is provided
> >> for a subset of that class, then the special convert should be used
> >>
> >> >yes, since the converter interface now has
> >> >
> >> >convertToObject(String value);
> >> >convertToString(Object value);
> >> >
> >> >not just a single convertTo(Object object, Class type)
> >> >
> >> >it makes it rather explicit that the converter is meant to convert
> >> >something to a string and back...no?
> >> >
> >> >-igor
> >> >
> >> >
> >> >On Mon, Mar 10, 2008 at 11:35 AM, Eelco Hillenius
> >> ><[EMAIL PROTECTED]> wrote:
> >> >> On Sun, Mar 9, 2008 at 9:45 AM, Igor Vaynberg <
> [EMAIL PROTECTED]>
> >> >wrote:
> >> >>
> >> >> > i thought we agreed converters were type converters...
> >> >>
> >> >>  Did we? :-)
> >> >>
> >> >>  Eelco
>  >> >>
> >> >>
> >> >>
> >> >>
>  -
> >> >>  To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> >>  For additional commands, e-mail: [EMAIL PROTECTED]
> >> >>
> >> >>
> >> >
> >> >-
> >> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> >For additional commands, e-mail: [EMAIL PROTECTED]
> >> >
> >>
> >> -
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: append a converter or coversion function

2008-03-10 Thread dvd
I missed this one. That explains what I just posted.
I'd say the logic could be 
if a converter is provided, the its stringtoobject is
called. otherwise, check the set type and use the types'registered
converter. 

>yes i think i explained that before
>the first call you see is the getConverter call that calls objectToString()
>on it
>but if type is not set on a field getConverter is not called for
>StringToObject
>
>johan
>
>
>
>On Mon, Mar 10, 2008 at 11:44 PM, <[EMAIL PROTECTED]> wrote:
>
>> Yes, but the issue I encountered that wicket first
>>  call getConverter method, yet not using
>> what was returned as supposed to be. Class based
>> converter is a way to write one default converter
>> for one class, but if a special converter is provided
>> for a subset of that class, then the special convert should be used
>>
>> >yes, since the converter interface now has
>> >
>> >convertToObject(String value);
>> >convertToString(Object value);
>> >
>> >not just a single convertTo(Object object, Class type)
>> >
>> >it makes it rather explicit that the converter is meant to convert
>> >something to a string and back...no?
>> >
>> >-igor
>> >
>> >
>> >On Mon, Mar 10, 2008 at 11:35 AM, Eelco Hillenius
>> ><[EMAIL PROTECTED]> wrote:
>> >> On Sun, Mar 9, 2008 at 9:45 AM, Igor Vaynberg <[EMAIL PROTECTED]>
>> >wrote:
>> >>
>> >> > i thought we agreed converters were type converters...
>> >>
>> >>  Did we? :-)
>> >>
>> >>  Eelco
>> >>
>> >>
>> >>
>> >>  -
>> >>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >>  For additional commands, e-mail: [EMAIL PROTECTED]
>> >>
>> >>
>> >
>> >-
>> >To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >For additional commands, e-mail: [EMAIL PROTECTED]
>> >
>>
>> -
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: append a converter or coversion function

2008-03-10 Thread Johan Compagner
yes i think i explained that before
the first call you see is the getConverter call that calls objectToString()
on it
but if type is not set on a field getConverter is not called for
StringToObject

johan



On Mon, Mar 10, 2008 at 11:44 PM, <[EMAIL PROTECTED]> wrote:

> Yes, but the issue I encountered that wicket first
>  call getConverter method, yet not using
> what was returned as supposed to be. Class based
> converter is a way to write one default converter
> for one class, but if a special converter is provided
> for a subset of that class, then the special convert should be used
>
> >yes, since the converter interface now has
> >
> >convertToObject(String value);
> >convertToString(Object value);
> >
> >not just a single convertTo(Object object, Class type)
> >
> >it makes it rather explicit that the converter is meant to convert
> >something to a string and back...no?
> >
> >-igor
> >
> >
> >On Mon, Mar 10, 2008 at 11:35 AM, Eelco Hillenius
> ><[EMAIL PROTECTED]> wrote:
> >> On Sun, Mar 9, 2008 at 9:45 AM, Igor Vaynberg <[EMAIL PROTECTED]>
> >wrote:
> >>
> >> > i thought we agreed converters were type converters...
> >>
> >>  Did we? :-)
> >>
> >>  Eelco
> >>
> >>
> >>
> >>  -
> >>  To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>  For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >
> >-
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: append a converter or coversion function

2008-03-10 Thread dvd
Another level of indirection?
for compoundpropertymode Could I could do
add(new textfield("foo").setModel(new uppercasingmodel(this))) ?

if this is the webpage with the "foo" field.

Compared to
add(new UpperCaseTextfield("foo"));

the latter would be more efficient and clean.



>class uppercasingmodel implements imodel {
>  private final imodel delegate;
>
>  public void setobject(object) {
>  delegate.setobject(uppercase((string)object));
>  }
>  ...
>}
>
>add(new textfield("foo", new uppercasingmodel(model)));
>
>-igor
>
>
>On Mon, Mar 10, 2008 at 3:31 AM,  <[EMAIL PROTECTED]> wrote:
>> I'd consider it a "generic" business component that applies
>>  to so many apps/business pojos that would justify it to become a web 
>component,
>>  much like RequiredTextField or even PasswordTextField.
>>
>>  Could you illustrate how to do it better with model decorator
>>  to use it like using RequiredTextField?
>>
>>
>>
>>
>>  >no, "upper case string" is not a special type, not unless you do not
>>  >use String to represent it...like i said, my suggestion is to do this
>>  >via a model decorator. further, something like this doesnt even sound
>>  >like it belongs in the web layer - sounds like a business requirement
>>  >which should be enforced by the setter of the bussiness pojo.
>>  >
>>  >-igor
>>
>>
>> >
>>  >
>>  >On Sun, Mar 9, 2008 at 7:57 PM,  <[EMAIL PROTECTED]> wrote:
>>  >> I used the trick it worked great. Thanks very much.
>>  >>  Should it be considered a bug?
>>  >>  What is interesting before using setType is that getConverter is 
>actually
>>  >>   called (from my simple tracing), but after that its methods were
>>  >>  not called (I guess somewhere it learned the modelobject was a String 
>so
>>  >>  it simply call the built-in converter.
>>  >>  I'd think if the getConverter is overriden, its methods should be 
>called
>>  >>  regardless of what type was it.  Besides, UppercaseString is
>>  >>  a special "Type" so it does not conflict with the rules.
>>  >>  (Any custom converter could be considered to target a special type
>>  >>  even though it could be just uppercasing or prepend a * to the string)
>>  >>  Built-in converter might follow the default rules but
>>  >>  if custom converter is provided, wicket should totally depend
>>  >>  on the custom converter to do whatever it does.
>>  >>
>>  >>  Anyway, thanks again.
>>  >>
>>  >>
>>  >>
>>  >>  >if you set the type yourself by hand then getConverter() will be 
>called
>>  >and
>>  >>  >you can do what ever you want
>>  >>  >We dont do that automatic yes (resolveType doesn't set it to the
>>  >>  >String.class)
>>  >>  >
>>  >>  >johan
>>  >>  >
>>  >>  >
>>  >>  >
>>  >>  >On Sun, Mar 9, 2008 at 5:45 PM, Igor Vaynberg 
><[EMAIL PROTECTED]>
>>  >>  >wrote:
>>  >>  >
>>  >>  >> i thought we agreed converters were type converters...so they 
>shouldnt
>>  >>  >> be invoked if you are doing string->string :|
>>  >>  >>
>>  >>  >> -igor
>>  >>  >>
>>  >>  >>
>>  >>  >> On Sun, Mar 9, 2008 at 5:47 AM, Johan Compagner 
><[EMAIL PROTECTED]>
>>  >>  >> wrote:
>>  >>  >> > call setTYpe(String.class) on the textfield
>>  >>  >> >  or use that constructor with the type param
>>  >>  >> >
>>  >>  >> >  does that help?
>>  >>  >> >
>>  >>  >> >
>>  >>  >> >
>>  >>  >> >  On Sun, Mar 9, 2008 at 1:35 PM, <[EMAIL PROTECTED]> wrote:
>>  >>  >> >
>>  >>  >> >  > Below is a custom component with overrding the getConverter
>>  >>  >> >  > for testing purpose. As you could see, it is plain simple one
>>  >>  >> >  > with simple output debugging. But it is not working.
>>  >>  >> >  > the getConverter is called (output "here")
>>  >>  >> >  > but the convertToObje

Re: append a converter or coversion function

2008-03-10 Thread dvd
Yes, but the issue I encountered that wicket first
 call getConverter method, yet not using
what was returned as supposed to be. Class based
converter is a way to write one default converter
for one class, but if a special converter is provided
for a subset of that class, then the special convert should be used

>yes, since the converter interface now has
>
>convertToObject(String value);
>convertToString(Object value);
>
>not just a single convertTo(Object object, Class type)
>
>it makes it rather explicit that the converter is meant to convert
>something to a string and back...no?
>
>-igor
>
>
>On Mon, Mar 10, 2008 at 11:35 AM, Eelco Hillenius
><[EMAIL PROTECTED]> wrote:
>> On Sun, Mar 9, 2008 at 9:45 AM, Igor Vaynberg <[EMAIL PROTECTED]> 
>wrote:
>>
>> > i thought we agreed converters were type converters...
>>
>>  Did we? :-)
>>
>>  Eelco
>>
>>
>>
>>  -
>>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>>  For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>-
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: append a converter or coversion function

2008-03-10 Thread Igor Vaynberg
sure, it works. but it seems rather silly that a String type converter
is invoked to convert what already is a String to a String - seems
like a noop to me

-igor


On Mon, Mar 10, 2008 at 1:39 PM, Johan Compagner <[EMAIL PROTECTED]> wrote:
> But why cant converToObject(String) not return a string??
>  Thats up to the developer.
>
>  So
>
>  textfield = new TextField()
>  {
>   getConverter(Class clz)
>   {
>   }
>  }
>  textfield.setType(String.class)
>
>  that should work fine (and it does if i am not mistaken)
>
>  johan
>
>
>
>  On Mon, Mar 10, 2008 at 7:37 PM, Igor Vaynberg <[EMAIL PROTECTED]>
>
>
> wrote:
>
>  > yes, since the converter interface now has
>  >
>  > convertToObject(String value);
>  > convertToString(Object value);
>  >
>  > not just a single convertTo(Object object, Class type)
>  >
>  > it makes it rather explicit that the converter is meant to convert
>  > something to a string and back...no?
>  >
>  > -igor
>  >
>  >
>  > On Mon, Mar 10, 2008 at 11:35 AM, Eelco Hillenius
>  > <[EMAIL PROTECTED]> wrote:
>  > > On Sun, Mar 9, 2008 at 9:45 AM, Igor Vaynberg <[EMAIL PROTECTED]>
>  > wrote:
>  > >
>  > > > i thought we agreed converters were type converters...
>  > >
>  > >  Did we? :-)
>  > >
>  > >  Eelco
>  > >
>  > >
>  > >
>  > >  -
>  > >  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  > >  For additional commands, e-mail: [EMAIL PROTECTED]
>  > >
>  > >
>  >
>  > -
>  > To unsubscribe, e-mail: [EMAIL PROTECTED]
>  > For additional commands, e-mail: [EMAIL PROTECTED]
>  >
>  >
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: append a converter or coversion function

2008-03-10 Thread Johan Compagner
But why cant converToObject(String) not return a string??
Thats up to the developer.

So

textfield = new TextField()
{
  getConverter(Class clz)
  {
  }
}
textfield.setType(String.class)

that should work fine (and it does if i am not mistaken)

johan



On Mon, Mar 10, 2008 at 7:37 PM, Igor Vaynberg <[EMAIL PROTECTED]>
wrote:

> yes, since the converter interface now has
>
> convertToObject(String value);
> convertToString(Object value);
>
> not just a single convertTo(Object object, Class type)
>
> it makes it rather explicit that the converter is meant to convert
> something to a string and back...no?
>
> -igor
>
>
> On Mon, Mar 10, 2008 at 11:35 AM, Eelco Hillenius
> <[EMAIL PROTECTED]> wrote:
> > On Sun, Mar 9, 2008 at 9:45 AM, Igor Vaynberg <[EMAIL PROTECTED]>
> wrote:
> >
> > > i thought we agreed converters were type converters...
> >
> >  Did we? :-)
> >
> >  Eelco
> >
> >
> >
> >  -
> >  To unsubscribe, e-mail: [EMAIL PROTECTED]
> >  For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: append a converter or coversion function

2008-03-10 Thread Eelco Hillenius
On Mon, Mar 10, 2008 at 11:37 AM, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
> yes, since the converter interface now has
>
>  convertToObject(String value);
>  convertToString(Object value);
>
>  not just a single convertTo(Object object, Class type)
>
>  it makes it rather explicit that the converter is meant to convert
>  something to a string and back...no?

It does.

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: append a converter or coversion function

2008-03-10 Thread Igor Vaynberg
yes, since the converter interface now has

convertToObject(String value);
convertToString(Object value);

not just a single convertTo(Object object, Class type)

it makes it rather explicit that the converter is meant to convert
something to a string and back...no?

-igor


On Mon, Mar 10, 2008 at 11:35 AM, Eelco Hillenius
<[EMAIL PROTECTED]> wrote:
> On Sun, Mar 9, 2008 at 9:45 AM, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
>
> > i thought we agreed converters were type converters...
>
>  Did we? :-)
>
>  Eelco
>
>
>
>  -
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: append a converter or coversion function

2008-03-10 Thread Eelco Hillenius
On Sun, Mar 9, 2008 at 9:45 AM, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
> i thought we agreed converters were type converters...

Did we? :-)

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: append a converter or coversion function

2008-03-10 Thread Igor Vaynberg
class uppercasingmodel implements imodel {
  private final imodel delegate;

  public void setobject(object) {
  delegate.setobject(uppercase((string)object));
  }
  ...
}

add(new textfield("foo", new uppercasingmodel(model)));

-igor


On Mon, Mar 10, 2008 at 3:31 AM,  <[EMAIL PROTECTED]> wrote:
> I'd consider it a "generic" business component that applies
>  to so many apps/business pojos that would justify it to become a web 
> component,
>  much like RequiredTextField or even PasswordTextField.
>
>  Could you illustrate how to do it better with model decorator
>  to use it like using RequiredTextField?
>
>
>
>
>  >no, "upper case string" is not a special type, not unless you do not
>  >use String to represent it...like i said, my suggestion is to do this
>  >via a model decorator. further, something like this doesnt even sound
>  >like it belongs in the web layer - sounds like a business requirement
>  >which should be enforced by the setter of the bussiness pojo.
>  >
>  >-igor
>
>
> >
>  >
>  >On Sun, Mar 9, 2008 at 7:57 PM,  <[EMAIL PROTECTED]> wrote:
>  >> I used the trick it worked great. Thanks very much.
>  >>  Should it be considered a bug?
>  >>  What is interesting before using setType is that getConverter is actually
>  >>   called (from my simple tracing), but after that its methods were
>  >>  not called (I guess somewhere it learned the modelobject was a String so
>  >>  it simply call the built-in converter.
>  >>  I'd think if the getConverter is overriden, its methods should be called
>  >>  regardless of what type was it.  Besides, UppercaseString is
>  >>  a special "Type" so it does not conflict with the rules.
>  >>  (Any custom converter could be considered to target a special type
>  >>  even though it could be just uppercasing or prepend a * to the string)
>  >>  Built-in converter might follow the default rules but
>  >>  if custom converter is provided, wicket should totally depend
>  >>  on the custom converter to do whatever it does.
>  >>
>  >>  Anyway, thanks again.
>  >>
>  >>
>  >>
>  >>  >if you set the type yourself by hand then getConverter() will be called
>  >and
>  >>  >you can do what ever you want
>  >>  >We dont do that automatic yes (resolveType doesn't set it to the
>  >>  >String.class)
>  >>  >
>  >>  >johan
>  >>  >
>  >>  >
>  >>  >
>  >>  >On Sun, Mar 9, 2008 at 5:45 PM, Igor Vaynberg <[EMAIL PROTECTED]>
>  >>  >wrote:
>  >>  >
>  >>  >> i thought we agreed converters were type converters...so they shouldnt
>  >>  >> be invoked if you are doing string->string :|
>  >>  >>
>  >>  >> -igor
>  >>  >>
>  >>  >>
>  >>  >> On Sun, Mar 9, 2008 at 5:47 AM, Johan Compagner <[EMAIL PROTECTED]>
>  >>  >> wrote:
>  >>  >> > call setTYpe(String.class) on the textfield
>  >>  >> >  or use that constructor with the type param
>  >>  >> >
>  >>  >> >  does that help?
>  >>  >> >
>  >>  >> >
>  >>  >> >
>  >>  >> >  On Sun, Mar 9, 2008 at 1:35 PM, <[EMAIL PROTECTED]> wrote:
>  >>  >> >
>  >>  >> >  > Below is a custom component with overrding the getConverter
>  >>  >> >  > for testing purpose. As you could see, it is plain simple one
>  >>  >> >  > with simple output debugging. But it is not working.
>  >>  >> >  > the getConverter is called (output "here")
>  >>  >> >  > but the convertToObject never called (no "there")
>  >>  >> >  > I basically cut and paste the WicketinAction example.
>  >>  >> >  > What I am doing wrong here?
>  >>  >> >  >
>  >>  >> >  >
>  >>  >> >  > public class RequiredUppperCaseTextField extends TextField {
>  >>  >> >  >
>  >>  >> >  >public RequiredUppperCaseTextField(String id) {
>  >>  >> >  >super(id);
>  >>  >> >  >setRequired(true);
>  >>  >> >  >
>  >>  >> >  >}
>  >>  >> >  >@Override
>  >>  >> >  >public final IC

Re: append a converter or coversion function

2008-03-10 Thread Johan Compagner
We do call it
you only have to specify the type
And if the type can be resolved and is NOT String.class your converter is
called

The only issue is if we cant resolve the type or the type is String then we
do by default something else

You have to set the type yourself then then your converter is called



On Mon, Mar 10, 2008 at 11:25 AM, <[EMAIL PROTECTED]> wrote:

> You could resolve the type because a converted is already registered
> for that type.  I could make a special class called UpperCaseString
> and register a converter and new TextField( . UpperCaseString.class).
> From this perspective, if I override getConverter to provide my own,
> wicket should use it directly instead of infer the type and what to do
> since I have give a definite converter. As I had observed,
> the custom getConverter was actually called, so all that takes
> is to call its methods instead of using builtin rules. The provider
> of the custom converter would be responsible for the outcome.
>
> >A converter is only called when type is set for converting from string
> >to object. Maybe we should document this a bit better.
> >
> >The type is tried to be resolved for you, but if it is a string  then
> >it is ignored so that normal convert() processing happens. This is a
> >bit weird but dont know how we can make this easier
> >
> >On 3/10/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >> I used the trick it worked great. Thanks very much.
> >> Should it be considered a bug?
> >> What is interesting before using setType is that getConverter is
> actually
> >>  called (from my simple tracing), but after that its methods were
> >> not called (I guess somewhere it learned the modelobject was a String
> so
> >> it simply call the built-in converter.
> >> I'd think if the getConverter is overriden, its methods should be
> called
> >> regardless of what type was it.  Besides, UppercaseString is
> >> a special "Type" so it does not conflict with the rules.
> >> (Any custom converter could be considered to target a special type
> >> even though it could be just uppercasing or prepend a * to the string)
> >> Built-in converter might follow the default rules but
> >> if custom converter is provided, wicket should totally depend
> >> on the custom converter to do whatever it does.
> >>
> >> Anyway, thanks again.
> >>
> >> >if you set the type yourself by hand then getConverter() will be
> called
> >and
> >> >you can do what ever you want
> >> >We dont do that automatic yes (resolveType doesn't set it to the
> >> >String.class)
> >> >
> >> >johan
> >> >
> >> >
> >> >
> >> >On Sun, Mar 9, 2008 at 5:45 PM, Igor Vaynberg <[EMAIL PROTECTED]
> >
> >> >wrote:
> >> >
> >> >> i thought we agreed converters were type converters...so they
> shouldnt
> >> >> be invoked if you are doing string->string :|
> >> >>
> >> >> -igor
> >> >>
> >> >>
> >> >> On Sun, Mar 9, 2008 at 5:47 AM, Johan Compagner <
> [EMAIL PROTECTED]>
> >> >> wrote:
> >> >> > call setTYpe(String.class) on the textfield
> >> >> >  or use that constructor with the type param
> >> >> >
> >> >> >  does that help?
> >> >> >
> >> >> >
> >> >> >
> >> >> >  On Sun, Mar 9, 2008 at 1:35 PM, <[EMAIL PROTECTED]> wrote:
> >> >> >
> >> >> >  > Below is a custom component with overrding the getConverter
> >> >> >  > for testing purpose. As you could see, it is plain simple one
> >> >> >  > with simple output debugging. But it is not working.
> >> >> >  > the getConverter is called (output "here")
> >> >> >  > but the convertToObject never called (no "there")
> >> >> >  > I basically cut and paste the WicketinAction example.
> >> >> >  > What I am doing wrong here?
> >> >> >  >
> >> >> >  >
> >> >> >  > public class RequiredUppperCaseTextField extends TextField {
> >> >> >  >
> >> >> >  >public RequiredUppperCaseTextField(String id) {
> >> >> >  >super(id);
> >> >> >  >setRequired(true);
> >> >> >  >
> >> >>

Re: append a converter or coversion function

2008-03-10 Thread dvd
I'd consider it a "generic" business component that applies
to so many apps/business pojos that would justify it to become a web component,
much like RequiredTextField or even PasswordTextField.

Could you illustrate how to do it better with model decorator
to use it like using RequiredTextField?



>no, "upper case string" is not a special type, not unless you do not
>use String to represent it...like i said, my suggestion is to do this
>via a model decorator. further, something like this doesnt even sound
>like it belongs in the web layer - sounds like a business requirement
>which should be enforced by the setter of the bussiness pojo.
>
>-igor
>
>
>On Sun, Mar 9, 2008 at 7:57 PM,  <[EMAIL PROTECTED]> wrote:
>> I used the trick it worked great. Thanks very much.
>>  Should it be considered a bug?
>>  What is interesting before using setType is that getConverter is actually
>>   called (from my simple tracing), but after that its methods were
>>  not called (I guess somewhere it learned the modelobject was a String so
>>  it simply call the built-in converter.
>>  I'd think if the getConverter is overriden, its methods should be called
>>  regardless of what type was it.  Besides, UppercaseString is
>>  a special "Type" so it does not conflict with the rules.
>>  (Any custom converter could be considered to target a special type
>>  even though it could be just uppercasing or prepend a * to the string)
>>  Built-in converter might follow the default rules but
>>  if custom converter is provided, wicket should totally depend
>>  on the custom converter to do whatever it does.
>>
>>  Anyway, thanks again.
>>
>>
>>
>>  >if you set the type yourself by hand then getConverter() will be called 
>and
>>  >you can do what ever you want
>>  >We dont do that automatic yes (resolveType doesn't set it to the
>>  >String.class)
>>  >
>>  >johan
>>  >
>>  >
>>  >
>>  >On Sun, Mar 9, 2008 at 5:45 PM, Igor Vaynberg <[EMAIL PROTECTED]>
>>  >wrote:
>>  >
>>  >> i thought we agreed converters were type converters...so they shouldnt
>>  >> be invoked if you are doing string->string :|
>>  >>
>>  >> -igor
>>  >>
>>  >>
>>  >> On Sun, Mar 9, 2008 at 5:47 AM, Johan Compagner <[EMAIL PROTECTED]>
>>  >> wrote:
>>  >> > call setTYpe(String.class) on the textfield
>>  >> >  or use that constructor with the type param
>>  >> >
>>  >> >  does that help?
>>  >> >
>>  >> >
>>  >> >
>>  >> >  On Sun, Mar 9, 2008 at 1:35 PM, <[EMAIL PROTECTED]> wrote:
>>  >> >
>>  >> >  > Below is a custom component with overrding the getConverter
>>  >> >  > for testing purpose. As you could see, it is plain simple one
>>  >> >  > with simple output debugging. But it is not working.
>>  >> >  > the getConverter is called (output "here")
>>  >> >  > but the convertToObject never called (no "there")
>>  >> >  > I basically cut and paste the WicketinAction example.
>>  >> >  > What I am doing wrong here?
>>  >> >  >
>>  >> >  >
>>  >> >  > public class RequiredUppperCaseTextField extends TextField {
>>  >> >  >
>>  >> >  >public RequiredUppperCaseTextField(String id) {
>>  >> >  >super(id);
>>  >> >  >setRequired(true);
>>  >> >  >
>>  >> >  >}
>>  >> >  >@Override
>>  >> >  >public final IConverter getConverter(Class arg000){
>>  >> >  >System.out.println("here"+ arg0);
>>  >> >  >   IConverter icAppend = new IConverter(){
>>  >> >  >
>>  >> >  >public Object convertToObject(String arg0, Locale arg1) 
>{
>>  >> >  >    System.out.println("there"+ arg0);
>>  >> >  >String s = "sss";
>>  >> >  >return s;
>>  >> >  >}
>>  >> >  >
>>  >> >  >public String convertToString(Object arg0, Locale arg1) 
>{
>>  >> >  >return (String)arg0;
>>  >> >  >}
>>  >> >  >

Re: append a converter or coversion function

2008-03-10 Thread dvd
You could resolve the type because a converted is already registered
for that type.  I could make a special class called UpperCaseString
and register a converter and new TextField( . UpperCaseString.class).
>From this perspective, if I override getConverter to provide my own,
wicket should use it directly instead of infer the type and what to do
since I have give a definite converter. As I had observed,
the custom getConverter was actually called, so all that takes
is to call its methods instead of using builtin rules. The provider
of the custom converter would be responsible for the outcome.

>A converter is only called when type is set for converting from string
>to object. Maybe we should document this a bit better.
>
>The type is tried to be resolved for you, but if it is a string  then
>it is ignored so that normal convert() processing happens. This is a
>bit weird but dont know how we can make this easier
>
>On 3/10/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>> I used the trick it worked great. Thanks very much.
>> Should it be considered a bug?
>> What is interesting before using setType is that getConverter is actually
>>  called (from my simple tracing), but after that its methods were
>> not called (I guess somewhere it learned the modelobject was a String so
>> it simply call the built-in converter.
>> I'd think if the getConverter is overriden, its methods should be called
>> regardless of what type was it.  Besides, UppercaseString is
>> a special "Type" so it does not conflict with the rules.
>> (Any custom converter could be considered to target a special type
>> even though it could be just uppercasing or prepend a * to the string)
>> Built-in converter might follow the default rules but
>> if custom converter is provided, wicket should totally depend
>> on the custom converter to do whatever it does.
>>
>> Anyway, thanks again.
>>
>> >if you set the type yourself by hand then getConverter() will be called 
>and
>> >you can do what ever you want
>> >We dont do that automatic yes (resolveType doesn't set it to the
>> >String.class)
>> >
>> >johan
>> >
>> >
>> >
>> >On Sun, Mar 9, 2008 at 5:45 PM, Igor Vaynberg <[EMAIL PROTECTED]>
>> >wrote:
>> >
>> >> i thought we agreed converters were type converters...so they shouldnt
>> >> be invoked if you are doing string->string :|
>> >>
>> >> -igor
>> >>
>> >>
>> >> On Sun, Mar 9, 2008 at 5:47 AM, Johan Compagner <[EMAIL PROTECTED]>
>> >> wrote:
>> >> > call setTYpe(String.class) on the textfield
>> >> >  or use that constructor with the type param
>> >> >
>> >> >  does that help?
>> >> >
>> >> >
>> >> >
>> >> >  On Sun, Mar 9, 2008 at 1:35 PM, <[EMAIL PROTECTED]> wrote:
>> >> >
>> >> >  > Below is a custom component with overrding the getConverter
>> >> >  > for testing purpose. As you could see, it is plain simple one
>> >> >  > with simple output debugging. But it is not working.
>> >> >  > the getConverter is called (output "here")
>> >> >  > but the convertToObject never called (no "there")
>> >> >  > I basically cut and paste the WicketinAction example.
>> >> >  > What I am doing wrong here?
>> >> >  >
>> >> >  >
>> >> >  > public class RequiredUppperCaseTextField extends TextField {
>> >> >  >
>> >> >  >public RequiredUppperCaseTextField(String id) {
>> >> >  >super(id);
>> >> >  >setRequired(true);
>> >> >  >
>> >> >  >}
>> >> >  >@Override
>> >> >  >public final IConverter getConverter(Class arg000){
>> >> >  >System.out.println("here"+ arg0);
>> >> >  >   IConverter icAppend = new IConverter(){
>> >> >  >
>> >> >  >public Object convertToObject(String arg0, Locale arg1) 
>{
>> >> >  >    System.out.println("there"+ arg0);
>> >> >  >String s = "sss";
>> >> >  >return s;
>> >> >  >}
>> >> >  >
>> >> >  >public String convertToString(Object arg0, Lo

Re: append a converter or coversion function

2008-03-10 Thread Johan Compagner
A converter is only called when type is set for converting from string
to object. Maybe we should document this a bit better.

The type is tried to be resolved for you, but if it is a string  then
it is ignored so that normal convert() processing happens. This is a
bit weird but dont know how we can make this easier

On 3/10/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I used the trick it worked great. Thanks very much.
> Should it be considered a bug?
> What is interesting before using setType is that getConverter is actually
>  called (from my simple tracing), but after that its methods were
> not called (I guess somewhere it learned the modelobject was a String so
> it simply call the built-in converter.
> I'd think if the getConverter is overriden, its methods should be called
> regardless of what type was it.  Besides, UppercaseString is
> a special "Type" so it does not conflict with the rules.
> (Any custom converter could be considered to target a special type
> even though it could be just uppercasing or prepend a * to the string)
> Built-in converter might follow the default rules but
> if custom converter is provided, wicket should totally depend
> on the custom converter to do whatever it does.
>
> Anyway, thanks again.
>
> >if you set the type yourself by hand then getConverter() will be called and
> >you can do what ever you want
> >We dont do that automatic yes (resolveType doesn't set it to the
> >String.class)
> >
> >johan
> >
> >
> >
> >On Sun, Mar 9, 2008 at 5:45 PM, Igor Vaynberg <[EMAIL PROTECTED]>
> >wrote:
> >
> >> i thought we agreed converters were type converters...so they shouldnt
> >> be invoked if you are doing string->string :|
> >>
> >> -igor
> >>
> >>
> >> On Sun, Mar 9, 2008 at 5:47 AM, Johan Compagner <[EMAIL PROTECTED]>
> >> wrote:
> >> > call setTYpe(String.class) on the textfield
> >> >  or use that constructor with the type param
> >> >
> >> >  does that help?
> >> >
> >> >
> >> >
> >> >  On Sun, Mar 9, 2008 at 1:35 PM, <[EMAIL PROTECTED]> wrote:
> >> >
> >> >  > Below is a custom component with overrding the getConverter
> >> >  > for testing purpose. As you could see, it is plain simple one
> >> >  > with simple output debugging. But it is not working.
> >> >  > the getConverter is called (output "here")
> >> >  > but the convertToObject never called (no "there")
> >> >  > I basically cut and paste the WicketinAction example.
> >> >  > What I am doing wrong here?
> >> >  >
> >> >  >
> >> >  > public class RequiredUppperCaseTextField extends TextField {
> >> >  >
> >> >  >public RequiredUppperCaseTextField(String id) {
> >> >  >super(id);
> >> >  >setRequired(true);
> >> >  >
> >> >  >}
> >> >  >@Override
> >> >  >public final IConverter getConverter(Class arg000){
> >> >  >System.out.println("here"+ arg0);
> >> >  >   IConverter icAppend = new IConverter(){
> >> >  >
> >> >  >public Object convertToObject(String arg0, Locale arg1) {
> >> >  >System.out.println("there"+ arg0);
> >> >  >String s = "sss";
> >> >  >return s;
> >> >  >}
> >> >  >
> >> >  >public String convertToString(Object arg0, Locale arg1) {
> >> >  >return (String)arg0;
> >> >  >}
> >> >  >
> >> >  >};
> >> >  >return icAppend;
> >> >  > }
> >> >  >
> >> >  > }
> >> >  >
> >> >  >
> >> >  > >Override the getConverter() method. First call super and with that
> >> >  > >result call the special one (camel casing?)
> >> >  > >
> >> >  > >On 3/9/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >> >  > >> Hello:
> >> >  > >> I wonder how to "append" a converter or java method to a
> component
> >> so
> >> >  > that
> >> >  > >I
> >> >  > >> would affect what is already defined. For

Re: append a converter or coversion function

2008-03-09 Thread Igor Vaynberg
no, "upper case string" is not a special type, not unless you do not
use String to represent it...like i said, my suggestion is to do this
via a model decorator. further, something like this doesnt even sound
like it belongs in the web layer - sounds like a business requirement
which should be enforced by the setter of the bussiness pojo.

-igor


On Sun, Mar 9, 2008 at 7:57 PM,  <[EMAIL PROTECTED]> wrote:
> I used the trick it worked great. Thanks very much.
>  Should it be considered a bug?
>  What is interesting before using setType is that getConverter is actually
>   called (from my simple tracing), but after that its methods were
>  not called (I guess somewhere it learned the modelobject was a String so
>  it simply call the built-in converter.
>  I'd think if the getConverter is overriden, its methods should be called
>  regardless of what type was it.  Besides, UppercaseString is
>  a special "Type" so it does not conflict with the rules.
>  (Any custom converter could be considered to target a special type
>  even though it could be just uppercasing or prepend a * to the string)
>  Built-in converter might follow the default rules but
>  if custom converter is provided, wicket should totally depend
>  on the custom converter to do whatever it does.
>
>  Anyway, thanks again.
>
>
>
>  >if you set the type yourself by hand then getConverter() will be called and
>  >you can do what ever you want
>  >We dont do that automatic yes (resolveType doesn't set it to the
>  >String.class)
>  >
>  >johan
>  >
>  >
>  >
>  >On Sun, Mar 9, 2008 at 5:45 PM, Igor Vaynberg <[EMAIL PROTECTED]>
>  >wrote:
>  >
>  >> i thought we agreed converters were type converters...so they shouldnt
>  >> be invoked if you are doing string->string :|
>  >>
>  >> -igor
>  >>
>  >>
>  >> On Sun, Mar 9, 2008 at 5:47 AM, Johan Compagner <[EMAIL PROTECTED]>
>  >> wrote:
>  >> > call setTYpe(String.class) on the textfield
>  >> >  or use that constructor with the type param
>  >> >
>  >> >  does that help?
>  >> >
>  >> >
>  >> >
>  >> >  On Sun, Mar 9, 2008 at 1:35 PM, <[EMAIL PROTECTED]> wrote:
>  >> >
>  >> >  > Below is a custom component with overrding the getConverter
>  >> >  > for testing purpose. As you could see, it is plain simple one
>  >> >  > with simple output debugging. But it is not working.
>  >> >  > the getConverter is called (output "here")
>  >> >  > but the convertToObject never called (no "there")
>  >> >  > I basically cut and paste the WicketinAction example.
>  >> >  > What I am doing wrong here?
>  >> >  >
>  >> >  >
>  >> >  > public class RequiredUppperCaseTextField extends TextField {
>  >> >  >
>  >> >  >public RequiredUppperCaseTextField(String id) {
>  >> >  >super(id);
>  >> >  >setRequired(true);
>  >> >  >
>  >> >  >}
>  >> >  >@Override
>  >> >  >public final IConverter getConverter(Class arg000){
>  >> >  >System.out.println("here"+ arg0);
>  >> >  >   IConverter icAppend = new IConverter(){
>  >> >  >
>  >> >  >public Object convertToObject(String arg0, Locale arg1) {
>  >> >  >System.out.println("there"+ arg0);
>  >> >  >String s = "sss";
>  >> >  >return s;
>  >> >  >}
>  >> >  >
>  >> >  >public String convertToString(Object arg0, Locale arg1) {
>  >> >  >return (String)arg0;
>  >> >  >}
>  >> >  >
>  >> >  >};
>  >> >  >return icAppend;
>  >> >  > }
>  >> >  >
>  >> >  > }
>  >> >  >
>  >> >  >
>  >> >  > >Override the getConverter() method. First call super and with that
>  >> >  > >result call the special one (camel casing?)
>  >> >  > >
>  >> >  > >On 3/9/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>  >> >  > >> Hello:
>  >> >  > >> I wonder how to "append" a converter or java method to a component
>  >> so

Re: append a converter or coversion function

2008-03-09 Thread dvd
I used the trick it worked great. Thanks very much.
Should it be considered a bug?
What is interesting before using setType is that getConverter is actually
 called (from my simple tracing), but after that its methods were
not called (I guess somewhere it learned the modelobject was a String so 
it simply call the built-in converter.
I'd think if the getConverter is overriden, its methods should be called
regardless of what type was it.  Besides, UppercaseString is
a special "Type" so it does not conflict with the rules.
(Any custom converter could be considered to target a special type
even though it could be just uppercasing or prepend a * to the string)
Built-in converter might follow the default rules but 
if custom converter is provided, wicket should totally depend
on the custom converter to do whatever it does.

Anyway, thanks again.

>if you set the type yourself by hand then getConverter() will be called and
>you can do what ever you want
>We dont do that automatic yes (resolveType doesn't set it to the
>String.class)
>
>johan
>
>
>
>On Sun, Mar 9, 2008 at 5:45 PM, Igor Vaynberg <[EMAIL PROTECTED]>
>wrote:
>
>> i thought we agreed converters were type converters...so they shouldnt
>> be invoked if you are doing string->string :|
>>
>> -igor
>>
>>
>> On Sun, Mar 9, 2008 at 5:47 AM, Johan Compagner <[EMAIL PROTECTED]>
>> wrote:
>> > call setTYpe(String.class) on the textfield
>> >  or use that constructor with the type param
>> >
>> >  does that help?
>> >
>> >
>> >
>> >  On Sun, Mar 9, 2008 at 1:35 PM, <[EMAIL PROTECTED]> wrote:
>> >
>> >  > Below is a custom component with overrding the getConverter
>> >  > for testing purpose. As you could see, it is plain simple one
>> >  > with simple output debugging. But it is not working.
>> >  > the getConverter is called (output "here")
>> >  > but the convertToObject never called (no "there")
>> >  > I basically cut and paste the WicketinAction example.
>> >  > What I am doing wrong here?
>> >  >
>> >  >
>> >  > public class RequiredUppperCaseTextField extends TextField {
>> >  >
>> >  >public RequiredUppperCaseTextField(String id) {
>> >  >super(id);
>> >  >setRequired(true);
>> >  >
>> >  >}
>> >  >@Override
>> >  >public final IConverter getConverter(Class arg000){
>> >  >System.out.println("here"+ arg0);
>> >  >   IConverter icAppend = new IConverter(){
>> >  >
>> >  >public Object convertToObject(String arg0, Locale arg1) {
>> >  >System.out.println("there"+ arg0);
>> >  >String s = "sss";
>> >  >    return s;
>> >  >}
>> >  >
>> >  >public String convertToString(Object arg0, Locale arg1) {
>> >  >return (String)arg0;
>> >  >}
>> >  >
>> >  >};
>> >  >return icAppend;
>> >  > }
>> >  >
>> >  > }
>> >  >
>> >  >
>> >  > >Override the getConverter() method. First call super and with that
>> >  > >result call the special one (camel casing?)
>> >  > >
>> >  > >On 3/9/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>> >  > >> Hello:
>> >  > >> I wonder how to "append" a converter or java method to a component
>> so
>> >  > that
>> >  > >I
>> >  > >> would affect what is already defined. For example, I want
>> "camelize" a
>> >  > >> TextField(or some customized subclass) so that after the converter
>> >  > already
>> >  > >> defined completes the conversion (regardless what has been done in
>> the
>> >  > >> chain) , I could use the added converted/method to make the final
>> >  > >conversion
>> >  > >> to my need. The example I am seeing appears to "overide" and only
>> one
>> >  > can
>> >  > >be
>> >  > >> defined for a component, unlike validators, that I could add a
>> chain of
>> >  > >> them. Let me know if I am wrong about this.
>> >  > >> Thanks
>> >  > >
>> >  >
>> >-
>> >  > >To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >  > >For additional commands, e-mail: [EMAIL PROTECTED]
>> >  > >
>> >  >
>> >  > -
>> >  > To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >  > For additional commands, e-mail: [EMAIL PROTECTED]
>> >  >
>> >  >
>> >
>>
>> -
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: append a converter or coversion function

2008-03-09 Thread Johan Compagner
if you set the type yourself by hand then getConverter() will be called and
you can do what ever you want
We dont do that automatic yes (resolveType doesn't set it to the
String.class)

johan



On Sun, Mar 9, 2008 at 5:45 PM, Igor Vaynberg <[EMAIL PROTECTED]>
wrote:

> i thought we agreed converters were type converters...so they shouldnt
> be invoked if you are doing string->string :|
>
> -igor
>
>
> On Sun, Mar 9, 2008 at 5:47 AM, Johan Compagner <[EMAIL PROTECTED]>
> wrote:
> > call setTYpe(String.class) on the textfield
> >  or use that constructor with the type param
> >
> >  does that help?
> >
> >
> >
> >  On Sun, Mar 9, 2008 at 1:35 PM, <[EMAIL PROTECTED]> wrote:
> >
> >  > Below is a custom component with overrding the getConverter
> >  > for testing purpose. As you could see, it is plain simple one
> >  > with simple output debugging. But it is not working.
> >  > the getConverter is called (output "here")
> >  > but the convertToObject never called (no "there")
> >  > I basically cut and paste the WicketinAction example.
> >  > What I am doing wrong here?
> >  >
> >  >
> >  > public class RequiredUppperCaseTextField extends TextField {
> >  >
> >  >public RequiredUppperCaseTextField(String id) {
> >  >super(id);
> >  >setRequired(true);
> >  >
> >  >}
> >  >@Override
> >  >public final IConverter getConverter(Class arg000){
> >  >System.out.println("here"+ arg0);
> >  >   IConverter icAppend = new IConverter(){
> >  >
> >  >public Object convertToObject(String arg0, Locale arg1) {
> >  >System.out.println("there"+ arg0);
> >  >String s = "sss";
> >  >return s;
> >  >}
> >  >
> >  >public String convertToString(Object arg0, Locale arg1) {
> >  >    return (String)arg0;
> >  >}
> >  >
> >  >};
> >  >return icAppend;
> >  > }
> >  >
> >  > }
> >  >
> >  >
> >  > >Override the getConverter() method. First call super and with that
> >  > >result call the special one (camel casing?)
> >  > >
> >  > >On 3/9/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >  > >> Hello:
> >  > >> I wonder how to "append" a converter or java method to a component
> so
> >  > that
> >  > >I
> >  > >> would affect what is already defined. For example, I want
> "camelize" a
> >  > >> TextField(or some customized subclass) so that after the converter
> >  > already
> >  > >> defined completes the conversion (regardless what has been done in
> the
> >  > >> chain) , I could use the added converted/method to make the final
> >  > >conversion
> >  > >> to my need. The example I am seeing appears to "overide" and only
> one
> >  > can
> >  > >be
> >  > >> defined for a component, unlike validators, that I could add a
> chain of
> >  > >> them. Let me know if I am wrong about this.
> >  > >> Thanks
> >  > >
> >  >
> >-
> >  > >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >  > >For additional commands, e-mail: [EMAIL PROTECTED]
> >  > >
> >  >
> >  > -
> >  > To unsubscribe, e-mail: [EMAIL PROTECTED]
> >  > For additional commands, e-mail: [EMAIL PROTECTED]
> >  >
> >  >
> >
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: append a converter or coversion function

2008-03-09 Thread Igor Vaynberg
i thought we agreed converters were type converters...so they shouldnt
be invoked if you are doing string->string :|

-igor


On Sun, Mar 9, 2008 at 5:47 AM, Johan Compagner <[EMAIL PROTECTED]> wrote:
> call setTYpe(String.class) on the textfield
>  or use that constructor with the type param
>
>  does that help?
>
>
>
>  On Sun, Mar 9, 2008 at 1:35 PM, <[EMAIL PROTECTED]> wrote:
>
>  > Below is a custom component with overrding the getConverter
>  > for testing purpose. As you could see, it is plain simple one
>  > with simple output debugging. But it is not working.
>  > the getConverter is called (output "here")
>  > but the convertToObject never called (no "there")
>  > I basically cut and paste the WicketinAction example.
>  > What I am doing wrong here?
>  >
>  >
>  > public class RequiredUppperCaseTextField extends TextField {
>  >
>  >public RequiredUppperCaseTextField(String id) {
>  >super(id);
>  >setRequired(true);
>  >
>  >}
>  >@Override
>  >public final IConverter getConverter(Class arg000){
>  >System.out.println("here"+ arg0);
>  >   IConverter icAppend = new IConverter(){
>  >
>  >public Object convertToObject(String arg0, Locale arg1) {
>  >System.out.println("there"+ arg0);
>  >String s = "sss";
>  >return s;
>  >}
>  >
>  >public String convertToString(Object arg0, Locale arg1) {
>  >return (String)arg0;
>  >}
>  >
>  >};
>  >return icAppend;
>  > }
>  >
>  > }
>  >
>  >
>  > >Override the getConverter() method. First call super and with that
>  > >result call the special one (camel casing?)
>  > >
>  > >On 3/9/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>  > >> Hello:
>  > >> I wonder how to "append" a converter or java method to a component so
>  > that
>  > >I
>  > >> would affect what is already defined. For example, I want "camelize" a
>  > >> TextField(or some customized subclass) so that after the converter
>  > already
>  > >> defined completes the conversion (regardless what has been done in the
>  > >> chain) , I could use the added converted/method to make the final
>  > >conversion
>  > >> to my need. The example I am seeing appears to "overide" and only one
>  > can
>  > >be
>  > >> defined for a component, unlike validators, that I could add a chain of
>  > >> them. Let me know if I am wrong about this.
>  > >> Thanks
>  > >
>  > >-
>  > >To unsubscribe, e-mail: [EMAIL PROTECTED]
>  > >For additional commands, e-mail: [EMAIL PROTECTED]
>  > >
>  >
>  > -
>  > To unsubscribe, e-mail: [EMAIL PROTECTED]
>  > For additional commands, e-mail: [EMAIL PROTECTED]
>  >
>  >
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: append a converter or coversion function

2008-03-09 Thread Johan Compagner
call setTYpe(String.class) on the textfield
or use that constructor with the type param

does that help?

On Sun, Mar 9, 2008 at 1:35 PM, <[EMAIL PROTECTED]> wrote:

> Below is a custom component with overrding the getConverter
> for testing purpose. As you could see, it is plain simple one
> with simple output debugging. But it is not working.
> the getConverter is called (output "here")
> but the convertToObject never called (no "there")
> I basically cut and paste the WicketinAction example.
> What I am doing wrong here?
>
>
> public class RequiredUppperCaseTextField extends TextField {
>
>public RequiredUppperCaseTextField(String id) {
>super(id);
>setRequired(true);
>
>}
>@Override
>public final IConverter getConverter(Class arg000){
>System.out.println("here"+ arg0);
>   IConverter icAppend = new IConverter(){
>
>public Object convertToObject(String arg0, Locale arg1) {
>System.out.println("there"+ arg0);
>String s = "sss";
>return s;
>}
>
>public String convertToString(Object arg0, Locale arg1) {
>return (String)arg0;
>}
>
>};
>return icAppend;
> }
>
> }
>
>
> >Override the getConverter() method. First call super and with that
> >result call the special one (camel casing?)
> >
> >On 3/9/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >> Hello:
> >> I wonder how to "append" a converter or java method to a component so
> that
> >I
> >> would affect what is already defined. For example, I want "camelize" a
> >> TextField(or some customized subclass) so that after the converter
> already
> >> defined completes the conversion (regardless what has been done in the
> >> chain) , I could use the added converted/method to make the final
> >conversion
> >> to my need. The example I am seeing appears to "overide" and only one
> can
> >be
> >> defined for a component, unlike validators, that I could add a chain of
> >> them. Let me know if I am wrong about this.
> >> Thanks
> >
> >-
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: append a converter or coversion function

2008-03-09 Thread dvd
Below is a custom component with overrding the getConverter
for testing purpose. As you could see, it is plain simple one
with simple output debugging. But it is not working.
the getConverter is called (output "here")
but the convertToObject never called (no "there")
I basically cut and paste the WicketinAction example.
What I am doing wrong here?


public class RequiredUppperCaseTextField extends TextField {

public RequiredUppperCaseTextField(String id) {
super(id);
setRequired(true);

}
@Override
public final IConverter getConverter(Class arg000){
System.out.println("here"+ arg0);   
   IConverter icAppend = new IConverter(){

public Object convertToObject(String arg0, Locale arg1) {
System.out.println("there"+ arg0);
String s = "sss";
return s;
}

public String convertToString(Object arg0, Locale arg1) {
return (String)arg0;
}

};
return icAppend;
}
   
}


>Override the getConverter() method. First call super and with that
>result call the special one (camel casing?)
>
>On 3/9/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>> Hello:
>> I wonder how to "append" a converter or java method to a component so that 
>I
>> would affect what is already defined. For example, I want "camelize" a
>> TextField(or some customized subclass) so that after the converter already
>> defined completes the conversion (regardless what has been done in the
>> chain) , I could use the added converted/method to make the final 
>conversion
>> to my need. The example I am seeing appears to "overide" and only one can 
>be
>> defined for a component, unlike validators, that I could add a chain of
>> them. Let me know if I am wrong about this.
>> Thanks
>
>-
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: append a converter or coversion function

2008-03-09 Thread Johan Compagner
Such a method would waste memory space. The current way is fine to
chain converters you could do this globally if you want

SetModel is only called by you when you construct it. Not when the dat
is set from the browser the setModelObject is called or
getModel().setObject()

On 3/9/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Thanks. I will give a try, although I wish there would be something like
> component.add(IPostConverteToObject or IPostConverttoString) that would
> not require subclass and also allow easy reuse of what is available.
>
> A related question, after conversion is done, Can I do something like below
>
> class MyTextField extend TextField{
>@Override
>setModel(model){
>  MySpeicalProcessing(model) // after this model object is changed to
> what I want
>  super.setModel(model)
>}
> }
>
> The javadoc said it
> WARNING: DO NOT OVERRIDE THIS METHOD UNLESS YOU HAVE A VERY GOOD REASON FOR
> IT. OVERRIDING THIS MIGHT OPEN UP SECURITY LEAKS AND BREAK BACK-BUTTON
> SUPPORT.
>
> Also, would wicket gurantee that after the conversion, it would only call
> setModel(model)  instead of being able to use other means to update the
> model value
> such as setModelObject. If allowed, then the above method could fail
> mysteriously.
>
> Thanks
>
>
>
>
> >Override the getConverter() method. First call super and with that
> >result call the special one (camel casing?)
> >
> >On 3/9/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >> Hello:
> >> I wonder how to "append" a converter or java method to a component so
> that
> >I
> >> would affect what is already defined. For example, I want "camelize" a
> >> TextField(or some customized subclass) so that after the converter
> already
> >> defined completes the conversion (regardless what has been done in the
> >> chain) , I could use the added converted/method to make the final
> >conversion
> >> to my need. The example I am seeing appears to "overide" and only one can
> >be
> >> defined for a component, unlike validators, that I could add a chain of
> >> them. Let me know if I am wrong about this.
> >> Thanks
> >
> >-
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: append a converter or coversion function

2008-03-09 Thread dvd
Thanks. I will give a try, although I wish there would be something like
component.add(IPostConverteToObject or IPostConverttoString) that would
not require subclass and also allow easy reuse of what is available.

A related question, after conversion is done, Can I do something like below

class MyTextField extend TextField{
   @Override
   setModel(model){
 MySpeicalProcessing(model) // after this model object is changed to what I 
want
 super.setModel(model)
   }
}

The javadoc said it
WARNING: DO NOT OVERRIDE THIS METHOD UNLESS YOU HAVE A VERY GOOD REASON FOR IT. 
OVERRIDING THIS MIGHT OPEN UP SECURITY LEAKS AND BREAK BACK-BUTTON SUPPORT.

Also, would wicket gurantee that after the conversion, it would only call 
setModel(model)  instead of being able to use other means to update the model 
value
such as setModelObject. If allowed, then the above method could fail 
mysteriously.

Thanks




>Override the getConverter() method. First call super and with that
>result call the special one (camel casing?)
>
>On 3/9/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>> Hello:
>> I wonder how to "append" a converter or java method to a component so that 
>I
>> would affect what is already defined. For example, I want "camelize" a
>> TextField(or some customized subclass) so that after the converter already
>> defined completes the conversion (regardless what has been done in the
>> chain) , I could use the added converted/method to make the final 
>conversion
>> to my need. The example I am seeing appears to "overide" and only one can 
>be
>> defined for a component, unlike validators, that I could add a chain of
>> them. Let me know if I am wrong about this.
>> Thanks
>
>-
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: append a converter or coversion function

2008-03-09 Thread Johan Compagner
Override the getConverter() method. First call super and with that
result call the special one (camel casing?)

On 3/9/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hello:
> I wonder how to "append" a converter or java method to a component so that I
> would affect what is already defined. For example, I want "camelize" a
> TextField(or some customized subclass) so that after the converter already
> defined completes the conversion (regardless what has been done in the
> chain) , I could use the added converted/method to make the final conversion
> to my need. The example I am seeing appears to "overide" and only one can be
> defined for a component, unlike validators, that I could add a chain of
> them. Let me know if I am wrong about this.
> Thanks

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: append a converter or coversion function

2008-03-08 Thread Igor Vaynberg
a model decorator would not result in any repeated code

-igor


On Sat, Mar 8, 2008 at 4:30 PM,  <[EMAIL PROTECTED]> wrote:
> I could use both model or onSubmit to do what I mentioned.
>  But this resulted in repeating coding. If I put
>  the special conversion code in converter, it would be handily reusable
>  by me or others without worring about the convertion logic for each model or 
> form.  Validator chaining is the example of what I meant
>
>
>
>  >i think a model decorator is more appropriate here
>  >
>  >-igor
>  >
>  >
>  >On Sat, Mar 8, 2008 at 3:10 PM,  <[EMAIL PROTECTED]> wrote:
>  >> Hello:
>  >>  I wonder how to "append" a converter or java method to a component so 
> that
>  >I would affect what is already defined. For example, I want "camelize" a
>  >TextField(or some customized subclass) so that after the converter already
>  >defined completes the conversion (regardless what has been done in the 
> chain)
>  >, I could use the added converted/method to make the final conversion to my
>  >need. The example I am seeing appears to "overide" and only one can be 
> defined
>  >for a component, unlike validators, that I could add a chain of them. Let me
>  >know if I am wrong about this.
>  >>  Thanks
>  >
>  >-
>  >To unsubscribe, e-mail: [EMAIL PROTECTED]
>  >For additional commands, e-mail: [EMAIL PROTECTED]
>  >
>
>  -
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



  1   2   >