Re: Component to String

2013-01-25 Thread Martin Grigorov
There is Mail template example at
http://www.wicket-library.com/wicket-examples-6.0.x/mailtemplate/?0 since
some time.


On Thu, Jan 24, 2013 at 6:25 PM, Steve Lowery slow...@gatessolutions.comwrote:

 I found several threads on the user list about converting a Component into
 a String.  There are at least 2 very valid use cases where doing this makes
 sense:

 1.  You are trying to create an html email to send out to your customers.
  Building that content out with wicket is a great way to do it.  We are
 able to harness Wicket's awesome i18n capabilities to generate the content.
  Otherwise, we resort to ResourceBundles or having to introduce some other
 templating library.

 2.  Many Javascript APIs/JQuery Plugins (i.e. growl notifications,
 popovers, etc) want the html content passed in.  Again, ideally the
 component is written in wicket.

 The threads I've seen have asked for potential ways to do this, but I'm
 wondering if this is a utility that should be included within Wicket
 itself.  What do you think?

 If you think this type of utility does not belong in the framework and
 should be implemented by the users instead, can you provide a wicket 6 way
 of accomplishing this?

 Thanks.

 --


 IMPORTANT: This e-mail (including any attachments) is intended for the use
 of the individual or entity to which it is addressed and may contain
 information that is classified, private, or confidential. If the reader of
 this message is not the intended recipient, or the employee or agent
 responsible for delivering the message to the intended recipient, you are
 hereby notified that any dissemination, distribution, or copying of this
 communication is prohibited. If you have received this communication in
 error, please notify us immediately by replying to this e-mail. Thank you.




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


Component to String

2013-01-24 Thread Steve Lowery
I found several threads on the user list about converting a Component into
a String.  There are at least 2 very valid use cases where doing this makes
sense:

1.  You are trying to create an html email to send out to your customers.
 Building that content out with wicket is a great way to do it.  We are
able to harness Wicket's awesome i18n capabilities to generate the content.
 Otherwise, we resort to ResourceBundles or having to introduce some other
templating library.

2.  Many Javascript APIs/JQuery Plugins (i.e. growl notifications,
popovers, etc) want the html content passed in.  Again, ideally the
component is written in wicket.

The threads I've seen have asked for potential ways to do this, but I'm
wondering if this is a utility that should be included within Wicket
itself.  What do you think?

If you think this type of utility does not belong in the framework and
should be implemented by the users instead, can you provide a wicket 6 way
of accomplishing this?

Thanks.

-- 
 

IMPORTANT: This e-mail (including any attachments) is intended for the use 
of the individual or entity to which it is addressed and may contain 
information that is classified, private, or confidential. If the reader of 
this message is not the intended recipient, or the employee or agent 
responsible for delivering the message to the intended recipient, you are 
hereby notified that any dissemination, distribution, or copying of this 
communication is prohibited. If you have received this communication in 
error, please notify us immediately by replying to this e-mail. Thank you.


Re: Component to String

2013-01-24 Thread Cedric Gatay
Hi,
I recently needed to do this, I come with a simple solution (quickly
deprecated by our main application architecture however). I blogged about
it here
http://www.bloggure.info/work/java-work/use-wicket-templating-system-to-generate-html.html

I hope it will help you, I don't know if it works well with Wicket 6
(written for 1.5).

Regards,


__
Cedric Gatay
http://www.bloggure.info | http://cedric.gatay.fr |
@Cedric_Gatayhttp://twitter.com/Cedric_Gatay


On Thu, Jan 24, 2013 at 5:25 PM, Steve Lowery slow...@gatessolutions.comwrote:

 I found several threads on the user list about converting a Component into
 a String.  There are at least 2 very valid use cases where doing this makes
 sense:

 1.  You are trying to create an html email to send out to your customers.
  Building that content out with wicket is a great way to do it.  We are
 able to harness Wicket's awesome i18n capabilities to generate the content.
  Otherwise, we resort to ResourceBundles or having to introduce some other
 templating library.

 2.  Many Javascript APIs/JQuery Plugins (i.e. growl notifications,
 popovers, etc) want the html content passed in.  Again, ideally the
 component is written in wicket.

 The threads I've seen have asked for potential ways to do this, but I'm
 wondering if this is a utility that should be included within Wicket
 itself.  What do you think?

 If you think this type of utility does not belong in the framework and
 should be implemented by the users instead, can you provide a wicket 6 way
 of accomplishing this?

 Thanks.

 --


 IMPORTANT: This e-mail (including any attachments) is intended for the use
 of the individual or entity to which it is addressed and may contain
 information that is classified, private, or confidential. If the reader of
 this message is not the intended recipient, or the employee or agent
 responsible for delivering the message to the intended recipient, you are
 hereby notified that any dissemination, distribution, or copying of this
 communication is prohibited. If you have received this communication in
 error, please notify us immediately by replying to this e-mail. Thank you.



Re: Component to String

2013-01-24 Thread Francois Meillet
Hi Cedric,

Great !
It works on 6.5

François


Le 24 janv. 2013 à 17:39, Cedric Gatay gata...@gmail.com a écrit :

 Hi,
 I recently needed to do this, I come with a simple solution (quickly
 deprecated by our main application architecture however). I blogged about
 it here
 http://www.bloggure.info/work/java-work/use-wicket-templating-system-to-generate-html.html
 
 I hope it will help you, I don't know if it works well with Wicket 6
 (written for 1.5).
 
 Regards,
 
 
 __
 Cedric Gatay
 http://www.bloggure.info | http://cedric.gatay.fr |
 @Cedric_Gatayhttp://twitter.com/Cedric_Gatay
 
 
 On Thu, Jan 24, 2013 at 5:25 PM, Steve Lowery 
 slow...@gatessolutions.comwrote:
 
 I found several threads on the user list about converting a Component into
 a String.  There are at least 2 very valid use cases where doing this makes
 sense:
 
 1.  You are trying to create an html email to send out to your customers.
 Building that content out with wicket is a great way to do it.  We are
 able to harness Wicket's awesome i18n capabilities to generate the content.
 Otherwise, we resort to ResourceBundles or having to introduce some other
 templating library.
 
 2.  Many Javascript APIs/JQuery Plugins (i.e. growl notifications,
 popovers, etc) want the html content passed in.  Again, ideally the
 component is written in wicket.
 
 The threads I've seen have asked for potential ways to do this, but I'm
 wondering if this is a utility that should be included within Wicket
 itself.  What do you think?
 
 If you think this type of utility does not belong in the framework and
 should be implemented by the users instead, can you provide a wicket 6 way
 of accomplishing this?
 
 Thanks.
 
 --
 
 
 IMPORTANT: This e-mail (including any attachments) is intended for the use
 of the individual or entity to which it is addressed and may contain
 information that is classified, private, or confidential. If the reader of
 this message is not the intended recipient, or the employee or agent
 responsible for delivering the message to the intended recipient, you are
 hereby notified that any dissemination, distribution, or copying of this
 communication is prohibited. If you have received this communication in
 error, please notify us immediately by replying to this e-mail. Thank you.
 


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



Re: Component to String

2013-01-24 Thread Nick Pratt
The real issue here is that most Email clients render HTML really badly, or
dont render it at all (or their implementations of such rendering is just
wrong).

Even modern email clients, like the latest Outlook or GMail dont render
significant portions of HTML/CSS correctly, and you will likely have to
resort to table layout to get anything even remotely like what you're
after.

N

On Thu, Jan 24, 2013 at 1:04 PM, Francois Meillet 
francois.meil...@gmail.com wrote:

 Hi Cedric,

 Great !
 It works on 6.5

 François


 Le 24 janv. 2013 à 17:39, Cedric Gatay gata...@gmail.com a écrit :

  Hi,
  I recently needed to do this, I come with a simple solution (quickly
  deprecated by our main application architecture however). I blogged about
  it here
 
 http://www.bloggure.info/work/java-work/use-wicket-templating-system-to-generate-html.html
 
  I hope it will help you, I don't know if it works well with Wicket 6
  (written for 1.5).
 
  Regards,
 
 
  __
  Cedric Gatay
  http://www.bloggure.info | http://cedric.gatay.fr |
  @Cedric_Gatayhttp://twitter.com/Cedric_Gatay
 
 
  On Thu, Jan 24, 2013 at 5:25 PM, Steve Lowery 
 slow...@gatessolutions.comwrote:
 
  I found several threads on the user list about converting a Component
 into
  a String.  There are at least 2 very valid use cases where doing this
 makes
  sense:
 
  1.  You are trying to create an html email to send out to your
 customers.
  Building that content out with wicket is a great way to do it.  We are
  able to harness Wicket's awesome i18n capabilities to generate the
 content.
  Otherwise, we resort to ResourceBundles or having to introduce some
 other
  templating library.
 
  2.  Many Javascript APIs/JQuery Plugins (i.e. growl notifications,
  popovers, etc) want the html content passed in.  Again, ideally the
  component is written in wicket.
 
  The threads I've seen have asked for potential ways to do this, but I'm
  wondering if this is a utility that should be included within Wicket
  itself.  What do you think?
 
  If you think this type of utility does not belong in the framework and
  should be implemented by the users instead, can you provide a wicket 6
 way
  of accomplishing this?
 
  Thanks.
 
  --
 
 
  IMPORTANT: This e-mail (including any attachments) is intended for the
 use
  of the individual or entity to which it is addressed and may contain
  information that is classified, private, or confidential. If the reader
 of
  this message is not the intended recipient, or the employee or agent
  responsible for delivering the message to the intended recipient, you
 are
  hereby notified that any dissemination, distribution, or copying of this
  communication is prohibited. If you have received this communication in
  error, please notify us immediately by replying to this e-mail. Thank
 you.
 


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




Re: Component to String

2013-01-24 Thread Cedric Gatay
Yes it is the real issue when displaying HTML in emails. However, using
Wicket's builtin templating engine is great to generate these HTML mails ;)


On Thu, Jan 24, 2013 at 7:24 PM, Nick Pratt nbpr...@gmail.com wrote:

 The real issue here is that most Email clients render HTML really badly, or
 dont render it at all (or their implementations of such rendering is just
 wrong).

 Even modern email clients, like the latest Outlook or GMail dont render
 significant portions of HTML/CSS correctly, and you will likely have to
 resort to table layout to get anything even remotely like what you're
 after.

 N

 On Thu, Jan 24, 2013 at 1:04 PM, Francois Meillet 
 francois.meil...@gmail.com wrote:

  Hi Cedric,
 
  Great !
  It works on 6.5
 
  François
 
 
  Le 24 janv. 2013 à 17:39, Cedric Gatay gata...@gmail.com a écrit :
 
   Hi,
   I recently needed to do this, I come with a simple solution (quickly
   deprecated by our main application architecture however). I blogged
 about
   it here
  
 
 http://www.bloggure.info/work/java-work/use-wicket-templating-system-to-generate-html.html
  
   I hope it will help you, I don't know if it works well with Wicket 6
   (written for 1.5).
  
   Regards,
  
  
   __
   Cedric Gatay
   http://www.bloggure.info | http://cedric.gatay.fr |
   @Cedric_Gatayhttp://twitter.com/Cedric_Gatay
  
  
   On Thu, Jan 24, 2013 at 5:25 PM, Steve Lowery 
  slow...@gatessolutions.comwrote:
  
   I found several threads on the user list about converting a Component
  into
   a String.  There are at least 2 very valid use cases where doing this
  makes
   sense:
  
   1.  You are trying to create an html email to send out to your
  customers.
   Building that content out with wicket is a great way to do it.  We are
   able to harness Wicket's awesome i18n capabilities to generate the
  content.
   Otherwise, we resort to ResourceBundles or having to introduce some
  other
   templating library.
  
   2.  Many Javascript APIs/JQuery Plugins (i.e. growl notifications,
   popovers, etc) want the html content passed in.  Again, ideally the
   component is written in wicket.
  
   The threads I've seen have asked for potential ways to do this, but
 I'm
   wondering if this is a utility that should be included within Wicket
   itself.  What do you think?
  
   If you think this type of utility does not belong in the framework and
   should be implemented by the users instead, can you provide a wicket 6
  way
   of accomplishing this?
  
   Thanks.
  
   --
  
  
   IMPORTANT: This e-mail (including any attachments) is intended for the
  use
   of the individual or entity to which it is addressed and may contain
   information that is classified, private, or confidential. If the
 reader
  of
   this message is not the intended recipient, or the employee or agent
   responsible for delivering the message to the intended recipient, you
  are
   hereby notified that any dissemination, distribution, or copying of
 this
   communication is prohibited. If you have received this communication
 in
   error, please notify us immediately by replying to this e-mail. Thank
  you.
  
 
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 



Re: Component to String

2013-01-24 Thread Paul Bors
You can also use a VelocityPanel in Wicket to render to HTML or plain text
or XML or whatever your velocity template feels like :)

http://wicket.apache.org/learn/projects/velocity.html

~ Thank you,
Paul Bors

On Thu, Jan 24, 2013 at 1:30 PM, Cedric Gatay gata...@gmail.com wrote:

 Yes it is the real issue when displaying HTML in emails. However, using
 Wicket's builtin templating engine is great to generate these HTML mails ;)


 On Thu, Jan 24, 2013 at 7:24 PM, Nick Pratt nbpr...@gmail.com wrote:

  The real issue here is that most Email clients render HTML really badly,
 or
  dont render it at all (or their implementations of such rendering is just
  wrong).
 
  Even modern email clients, like the latest Outlook or GMail dont render
  significant portions of HTML/CSS correctly, and you will likely have to
  resort to table layout to get anything even remotely like what you're
  after.
 
  N
 
  On Thu, Jan 24, 2013 at 1:04 PM, Francois Meillet 
  francois.meil...@gmail.com wrote:
 
   Hi Cedric,
  
   Great !
   It works on 6.5
  
   François
  
  
   Le 24 janv. 2013 à 17:39, Cedric Gatay gata...@gmail.com a écrit :
  
Hi,
I recently needed to do this, I come with a simple solution (quickly
deprecated by our main application architecture however). I blogged
  about
it here
   
  
 
 http://www.bloggure.info/work/java-work/use-wicket-templating-system-to-generate-html.html
   
I hope it will help you, I don't know if it works well with Wicket 6
(written for 1.5).
   
Regards,
   
   
__
Cedric Gatay
http://www.bloggure.info | http://cedric.gatay.fr |
@Cedric_Gatayhttp://twitter.com/Cedric_Gatay
   
   
On Thu, Jan 24, 2013 at 5:25 PM, Steve Lowery 
   slow...@gatessolutions.comwrote:
   
I found several threads on the user list about converting a
 Component
   into
a String.  There are at least 2 very valid use cases where doing
 this
   makes
sense:
   
1.  You are trying to create an html email to send out to your
   customers.
Building that content out with wicket is a great way to do it.  We
 are
able to harness Wicket's awesome i18n capabilities to generate the
   content.
Otherwise, we resort to ResourceBundles or having to introduce some
   other
templating library.
   
2.  Many Javascript APIs/JQuery Plugins (i.e. growl notifications,
popovers, etc) want the html content passed in.  Again, ideally the
component is written in wicket.
   
The threads I've seen have asked for potential ways to do this, but
  I'm
wondering if this is a utility that should be included within Wicket
itself.  What do you think?
   
If you think this type of utility does not belong in the framework
 and
should be implemented by the users instead, can you provide a
 wicket 6
   way
of accomplishing this?
   
Thanks.
   
--
   
   
IMPORTANT: This e-mail (including any attachments) is intended for
 the
   use
of the individual or entity to which it is addressed and may contain
information that is classified, private, or confidential. If the
  reader
   of
this message is not the intended recipient, or the employee or agent
responsible for delivering the message to the intended recipient,
 you
   are
hereby notified that any dissemination, distribution, or copying of
  this
communication is prohibited. If you have received this communication
  in
error, please notify us immediately by replying to this e-mail.
 Thank
   you.
   
  
  
   -
   To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
   For additional commands, e-mail: users-h...@wicket.apache.org
  
  
 



Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-30 Thread Ned Collyer

Sure I can appreciate that :) However I define my panels to accept certain
objects to chuck into the model, so thats fine.

It means I can provide translations for pojos from non wicket jars using a
method similar to wickets nice 1 class, 1 property file approach.

Eg,

mypanel extends panel {
  mypanel(id, Person person) {
 setModel(new Person())
  }
}


MyNonWicketProject.jar
  Person.class
  Person.properties
entity=Person
name=Name
surname=Surname


Great for generating forms, and combined with generics becomes quite
powerful.

My usecase and requirement of wicket is probably non typical (which is why
wicket rocks because I can customise it) - I have a large team each
developing different modules, and things like translations need to be
available in non wicket environments.  Everything is translatable.

Still - would be nice if the
MarkupInheritanceResolver$TransparentWebMarkupContainer somehow indicated it
was the the page (and returned the pages model).

I can live without it.


igor.vaynberg wrote:
 
 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
 

-- 
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--tp16930303p16979272.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]



Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-30 Thread Igor Vaynberg
On Wed, Apr 30, 2008 at 2:55 AM, Ned Collyer [EMAIL PROTECTED] wrote:

  Still - would be nice if the
  MarkupInheritanceResolver$TransparentWebMarkupContainer somehow indicated it
  was the the page (and returned the pages model).

Component c=...;
boolean page=(c==c.getPage());

-igor




  I can live without it.



  igor.vaynberg wrote:
  
   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
  

  --
  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--tp16930303p16979272.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]



Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-29 Thread Michael Sparer

yepp, then the TransparentWebMarkupContainer gets passed in. And you're
right, it's gonna be a filthy hack if you try to find out if its a Page.
Unfortunately I've got no further suggestions but it'd be interesting to
know why you want to distinguish between pages and other components anyway
...

regards, 
Michael

Ned Collyer wrote:
 
 Thanks for your reply,
 
 Maybe it's because I am using a wicket:message key=foobar/ in the
 markup?!
 
 There isn't really any code to show.  I put the wicket:message into the
 page, then i check the params coming in to the method.
 
 I'll have a bit more of a play I think, but I would be interested in what
 your results are with the wicket:message key=foobar/
 
 Rgds
 
 Ned
 
 
 Michael Sparer wrote:
 
 I just subclassed ComponentStringResourceLoader and tried calling
 getString(foobar); from a page (that extends another page). There
 instanceof Page returns true. Maybe it'd be helpful to see some code (and
 your usecase 'cause maybe there's another way to do it).
 
 regards
 Michael
 
 
 


-
Michael Sparer
http://talk-on-tech.blogspot.com
-- 
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--tp16930303p16955747.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]



Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-29 Thread Ned Collyer

Thanks for your reply,

Maybe it's because I am using a wicket:message key=foobar/ in the
markup?!

There isn't really any code to show.  I put the wicket:message into the
page, then i check the params coming in to the method.

I'll have a bit more of a play I think, but I would be interested in what
your results are with the wicket:message key=foobar/

Rgds

Ned


Michael Sparer wrote:
 
 I just subclassed ComponentStringResourceLoader and tried calling
 getString(foobar); from a page (that extends another page). There
 instanceof Page returns true. Maybe it'd be helpful to see some code (and
 your usecase 'cause maybe there's another way to do it).
 
 regards
 Michael
 

-- 
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--tp16930303p16955733.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]



Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-29 Thread Ned Collyer
I basically want the components Model.

It's legitimate for it to be null.  So, if I can see which component is a
page, then i can easily call the getPage().getModel()

Of course if it's TransparentWebMarkupContainer then getModel returns null
even if the page has a model set.

It appears to work with panels, just not page.

Are there other conditions that will cause the component to come through as
TransparentWebMarkupContainer?  How can I determine it's a page :).  Ugly
hacks are not something i enjoy/advocate using.

On Tue, Apr 29, 2008 at 6:56 PM, Michael Sparer [EMAIL PROTECTED]
wrote:


 yepp, then the TransparentWebMarkupContainer gets passed in. And you're
 right, it's gonna be a filthy hack if you try to find out if its a Page.
 Unfortunately I've got no further suggestions but it'd be interesting to
 know why you want to distinguish between pages and other components anyway
 ...

 regards,
 Michael




Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-29 Thread Michael Sparer

well one (as said ugly ;-)) way that comes to my mind is to ask if
component.getParent().getParent() instanceof Page (that should also work if
you use nested subpages).

regards, 
Michael



you could check if it's a transparentwebmarkupcontainer with instanceof. 

Ned Collyer wrote:
 
 I basically want the components Model.
 
 It's legitimate for it to be null.  So, if I can see which component is a
 page, then i can easily call the getPage().getModel()
 
 Of course if it's TransparentWebMarkupContainer then getModel returns null
 even if the page has a model set.
 
 It appears to work with panels, just not page.
 
 Are there other conditions that will cause the component to come through
 as
 TransparentWebMarkupContainer?  How can I determine it's a page :).  Ugly
 hacks are not something i enjoy/advocate using.
 
 On Tue, Apr 29, 2008 at 6:56 PM, Michael Sparer [EMAIL PROTECTED]
 wrote:
 

 yepp, then the TransparentWebMarkupContainer gets passed in. And you're
 right, it's gonna be a filthy hack if you try to find out if its a Page.
 Unfortunately I've got no further suggestions but it'd be interesting to
 know why you want to distinguish between pages and other components
 anyway
 ...

 regards,
 Michael


 
 


-
Michael Sparer
http://talk-on-tech.blogspot.com
-- 
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--tp16930303p16957722.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]



Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-29 Thread Ned Collyer

I did an elegantish... workaround.  - the page instantiates a panel - the
panel has the model.

Basically my pages defer almost everything to panels - and I guess it also
aids in their reuse/embeddability.

I'm quite familiar with instanceof thanks ;)


Michael Sparer wrote:
 
 well one (as said ugly ;-)) way that comes to my mind is to ask if
 component.getParent().getParent() instanceof Page (that should also work
 if you use nested subpages).
 
 regards, 
 Michael
 

-- 
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--tp16930303p16957861.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]



Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-29 Thread Igor Vaynberg
Page page=component.getPage() ?

-igor


On Tue, Apr 29, 2008 at 3:53 AM, Michael Sparer [EMAIL PROTECTED] wrote:

  well one (as said ugly ;-)) way that comes to my mind is to ask if
  component.getParent().getParent() instanceof Page (that should also work if
  you use nested subpages).

  regards,
  Michael



  you could check if it's a transparentwebmarkupcontainer with instanceof.



  Ned Collyer wrote:
  
   I basically want the components Model.
  
   It's legitimate for it to be null.  So, if I can see which component is a
   page, then i can easily call the getPage().getModel()
  
   Of course if it's TransparentWebMarkupContainer then getModel returns null
   even if the page has a model set.
  
   It appears to work with panels, just not page.
  
   Are there other conditions that will cause the component to come through
   as
   TransparentWebMarkupContainer?  How can I determine it's a page :).  Ugly
   hacks are not something i enjoy/advocate using.
  
   On Tue, Apr 29, 2008 at 6:56 PM, Michael Sparer [EMAIL PROTECTED]
   wrote:
  
  
   yepp, then the TransparentWebMarkupContainer gets passed in. And you're
   right, it's gonna be a filthy hack if you try to find out if its a Page.
   Unfortunately I've got no further suggestions but it'd be interesting to
   know why you want to distinguish between pages and other components
   anyway
   ...
  
   regards,
   Michael
  
  
  
  



 -
  Michael Sparer
  http://talk-on-tech.blogspot.com
  --
  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--tp16930303p16957722.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]



Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-29 Thread Ned Collyer

Do you know an elegant solution Igor?

Detecting when the component IS a page - when something like wicket:message
key=foobar/ is used in a page's markup, the component sent to the
StringResourceLoader is
MarkupInheritanceResolver$TransparentWebMarkupContainer and not Page.

If the strings are resolved in java (ie, getString(foobar)) (according to
michael) 
  component instanceof Page == true

if the strings are resolved in markup (ie, wicket:message key=foobar/)
  component instanceof Page == false

Rgds

Ned

igor.vaynberg wrote:
 
 Page page=component.getPage() ?
 
 -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--tp16930303p16973039.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]



Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-29 Thread Igor Vaynberg
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

On Tue, Apr 29, 2008 at 4:55 PM, Ned Collyer [EMAIL PROTECTED] wrote:

  Do you know an elegant solution Igor?

  Detecting when the component IS a page - when something like wicket:message
  key=foobar/ is used in a page's markup, the component sent to the
  StringResourceLoader is
  MarkupInheritanceResolver$TransparentWebMarkupContainer and not Page.

  If the strings are resolved in java (ie, getString(foobar)) (according to
  michael)
   component instanceof Page == true

  if the strings are resolved in markup (ie, wicket:message key=foobar/)
   component instanceof Page == false

  Rgds

  Ned


  igor.vaynberg wrote:
  
   Page page=component.getPage() ?
  
   -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--tp16930303p16973039.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]



Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-29 Thread Ned Collyer

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]



Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-29 Thread Igor Vaynberg
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]



Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-28 Thread Michael Sparer

comp instanceof Page ?

or am I misunderstanding somethin?


Ned Collyer wrote:
 
 Hi,
 
 I've written my own class that extends ComponentStringResourceLoader (i
 might change it to extend some other class)
 
 At any rate, when loadStringResource(Component component, String key) is
 called, and the component is a panel I can call getModel and retrieve
 the model.
 
 When the component is a Page, it comes in as
 MarkupInheritanceResolver$TransparentWebMarkupContainer - and getModel
 returns null (even if the page has had the model set).
 
 So... how do I determine is the component is a page? - what is the
 condition I should check?
 


-
Michael Sparer
http://talk-on-tech.blogspot.com
-- 
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--tp16930303p16938536.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]



Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-28 Thread Ned Collyer


Michael Sparer wrote:
 
 comp instanceof Page ?
 
 or am I misunderstanding somethin?
 
comp instanceof Page == false

comp is instance of MarkupInheritanceResolver$TransparentWebMarkupContainer

I need to get the model out of the page - if its a page.  Unfortunatly
getModel returns null

I'm not sure if there are other circumstances where
MarkupInheritanceResolver$TransparentWebMarkupContainer could match the
component.

I can call comp.getPage() or comp.getParent() a few times - but I need to
determine that it IS a page - because if it is not, then I handle it
differently.
-- 
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--tp16930303p16945995.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]



loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-27 Thread Ned Collyer

Hi,

I've written my own class that extends ComponentStringResourceLoader (i
might change it to extend some other class)

At any rate, when loadStringResource(Component component, String key) is
called, and the component is a panel I can call getModel and retrieve the
model.

When the component is a Page, it comes in as
MarkupInheritanceResolver$TransparentWebMarkupContainer - and getModel
returns null (even if the page has had the model set).

So... how do I determine is the component is a page? - what is the condition
I should check?
-- 
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--tp16930303p16930303.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]