hm. dont know if doing localization based on type of model object is a
great idea. there are many usecases where model type is quiet
aribitrary, and as you have found out yourself you dont know what
component you get passed in, so you just need to handle it in a way
that makes sense to you.

-igor


On Tue, Apr 29, 2008 at 7:11 PM, Ned Collyer <[EMAIL PROTECTED]> wrote:
>
>  I'm writing my own
>
>  It does this
>
>     @Override
>     public String loadStringResource(Component component, String key) {
>         if (component == null) {
>             return null;
>         }
>         String result = null;
>         Locale locale = component.getLocale();
>         String style = component.getStyle();
>
>         IModel model = component.getInnermostModel();
>
>         if (model != null) {
>             Object object = model.getObject();
>
>             if (object != null) {
>                 result = loadStringResource(object.getClass(), key, locale,
>  style);
>             }
>         }
>         return result;
>     }
>
>  Basically if does the translation lookup based on whatever object is set to
>  the model of the component.
>
>  It works fantastically except when the keys are in <wicket:message
>  key="foodbar"/> - because component becomes an instance of
>
> MarkupInheritanceResolver$TransparentWebMarkupContainer and getModel returns
>  null.
>
>  Are there other circumstances where the component can be
>  MarkupInheritanceResolver$TransparentWebMarkupContainer and it not be a
>  page?
>
>
>
>  igor.vaynberg wrote:
>  >
>  > sorry, but i dont really get what the problem is or why it matters
>  > what component stringresourceloader gets. it simply traverses up the
>  > hieararchy looking for .properties files
>  >
>  > -igor
>  >
>
>  --
>  View this message in context: 
> http://www.nabble.com/loadStringResource%28Component-component%2C-String-key%29---correct-method-to-check-if-the-component-IS-a-Page--tp16930303p16974123.html
>
>
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  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]

Reply via email to