Re: Programmatic creation of messages with nested components

2019-07-25 Thread Thomas Heigl
Hi Martin,

Sure. Currently I'm using  like described in the JavaDoc of
WicketMessageResolver:

Template:

>   
> [amount].
> 
> 
> 
>


Java:

> add(new Label("amount", new Model("$5.00")));
> add(new BookmarkablePageLink("link", DetailsPage.class));


i18n:

> myKey=Your balance is ${amount}. Click ${link} to view the details.
> linkText=here


This works, but the key "myKey" cannot be changed during runtime. I'd like
to use the private MessageContainer the same way I can use an
EnclosureContainer:

Template:

>   
> [amount].
> 
> 
> 
>


Java:

> final String key = "myKey";

final MessageContainer msg = new MessageContainer("msg", key, true);

msg.add(new Label("amount", new Model("$5.00")));
> msg.add(new BookmarkablePageLink("link", DetailsPage.class));

add(msg);


I hope that explains my requirement a bit better.

Best,

 Thomas


On Thu, Jul 25, 2019 at 6:48 AM Martin Terra <
martin.te...@koodaripalvelut.com> wrote:

> Hi!
>
> Can you show an example of solution now vs. solution after change, what are
> the benefits of such visibility change to your case? Maybe there is another
> way to accomplish your goal?
>
> **
> Martin
>
> ke 24. heinäk. 2019 klo 22.25 Thomas Heigl (tho...@umschalt.com)
> kirjoitti:
>
> > Hi all,
> >
> > I'd like to create Wicket messages with child components programatically.
> > Currently, this is only possible by using the  tag and
> > nesting components inside of it.
> >
> > For most use cases this is sufficient, but I sometimes come across cases
> > where I'd like to programatically define the message key instead of
> > hard-coding it in the template.
> >
> > The class that does all the interpolation is currently
> > private:
> > org.apache.wicket.markup.resolver.WicketMessageResolver.MessageContainer
> >
> > Would it be possible to make this a public (top-level) class in Wicket 9?
> > If I understand correctly, this would solve my requirement without any
> > other code changes.
> >
> > Best regards,
> >
> > Thomas
> >
>


Re: Programmatic creation of messages with nested components

2019-07-25 Thread Zbynek Vavros
How about using org.apache.wicket.markup.IMarkupResourceStreamProvider ?

Zbynek

On Thu, Jul 25, 2019 at 6:48 AM Martin Terra <
martin.te...@koodaripalvelut.com> wrote:

> Hi!
>
> Can you show an example of solution now vs. solution after change, what are
> the benefits of such visibility change to your case? Maybe there is another
> way to accomplish your goal?
>
> **
> Martin
>
> ke 24. heinäk. 2019 klo 22.25 Thomas Heigl (tho...@umschalt.com)
> kirjoitti:
>
> > Hi all,
> >
> > I'd like to create Wicket messages with child components programatically.
> > Currently, this is only possible by using the  tag and
> > nesting components inside of it.
> >
> > For most use cases this is sufficient, but I sometimes come across cases
> > where I'd like to programatically define the message key instead of
> > hard-coding it in the template.
> >
> > The class that does all the interpolation is currently
> > private:
> > org.apache.wicket.markup.resolver.WicketMessageResolver.MessageContainer
> >
> > Would it be possible to make this a public (top-level) class in Wicket 9?
> > If I understand correctly, this would solve my requirement without any
> > other code changes.
> >
> > Best regards,
> >
> > Thomas
> >
>