Thanks, Johan
With that code you are adding an attribute modifier ever time the button renders
And you did get an exception i guess because you call getString() out of the 
blue inside a construtor of a not fully constructed class.
thats why i moved the code to the propably wrong place..
To do that you have to lazy get the string through a model.getObject().
Then also a language change will result that the button will be translated on 
the fly
i have implemented the class I18NAttributeModifier which does what you proposed, by peeking
at the SimpleAttributeModifier code;

       private class I18NAttributeModifier extends AbstractBehavior {

           private String attribute;
           private String value;
public I18NAttributeModifier(String attribute, String value) {
               this.attribute = attribute;
               this.value = value;
           }
/** * @see org.apache.wicket.behavior.AbstractBehavior#onComponentTag(org.apache.wicket.Component,
            *      org.apache.wicket.markup.ComponentTag)
            */
public void onComponentTag(final Component component, final ComponentTag tag)
           {
               if (isEnabled(component))
               {
                   tag.getAttributes().put(attribute, getString(value));
               }
           }
       }

this modifier is added in the constructor and is a private class to the Form i extended from "WebPage"
which is why the getString() method is available.

however i find this a little bit like a quick fix. how should i modify the
class to be reusable from other forms with a button?

if i also try to keep the localizer in the internal class by calling
getLocalizer() in the constructor of the Form class, and replace
the getString() by localizer.getString() in the onComponentTag event
to be able to externalize I18NAttributeModifier for more common usage,
the resource string is not found - probably because the localizer was overwritten after my code getting it in the ctor.

it's a pity that the button needs to be handled in a special way,
is there maybe a way to improve this, or am i doing something wrong?

thanks, regards
nico




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

Reply via email to