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
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
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
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?
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
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:
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
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
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
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??
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
25 matches
Mail list logo