Custom Content

2007-10-13 Thread Jeremy Levy
I'm attempting to load the markup for a page based on values that are
available when the page is constructed.  For example, I want to be able to
pass a parameter into a page and then lookup the name of the content file in
my database based on this parameter and then have the page load and display
the appropriate content.

I've tried looking at the custom resource loading example in the examples
package but that seems to work by loading content based on the class name
and I didn't see a way to extend it.

I've tried overwriting the newMarkupResourceStream method, but it seems to
be called before the constructor is called as well as before the session is
available.

Any suggestions?

j


Re: Custom Content

2007-10-13 Thread Igor Vaynberg
stick a content into a label and call label.setescapemodelstrings(false)

-igor


On 10/13/07, Jeremy Levy [EMAIL PROTECTED] wrote:

 I'm attempting to load the markup for a page based on values that are
 available when the page is constructed.  For example, I want to be able to
 pass a parameter into a page and then lookup the name of the content file
 in
 my database based on this parameter and then have the page load and
 display
 the appropriate content.

 I've tried looking at the custom resource loading example in the examples
 package but that seems to work by loading content based on the class name
 and I didn't see a way to extend it.

 I've tried overwriting the newMarkupResourceStream method, but it seems to
 be called before the constructor is called as well as before the session
 is
 available.

 Any suggestions?

 j



Re: Custom Content

2007-10-13 Thread MattClark


Jeremy Levy-2 wrote:
 
 I want to be able to pass a parameter into a page and then lookup the name
 of the content file in
 my database based on this parameter and then have the page load and
 display
 the appropriate content.

What is the content file you want to display?  Is it just HTML?  If so,
try:

String html = myBusinessMethodToGetContent(someParam);
add( new Label(customContent,html).setEscapeModelStrings(false) );
-- 
View this message in context: 
http://www.nabble.com/Custom-Content-tf4619447.html#a13192982
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: Custom Content

2007-10-13 Thread Jeremy Levy
Will that work if the content includes a form?

I would like to be able to have a page which includes a form but have a
couple of different versions of the HTML and be able to select the one I
want based on the param...

In otherwords the HTML will contain form elements with wicket:id attributes
which I want to be associated with elements I've added in the form class.
The reason is I want to have radically different layouts for a page/form
which I don't want to have to update any java code to enable, only add the
new HTML file and update my database.

Swapping in different style sheets which would seem to make the most sense
isn't going to work in this case..

j

On 10/13/07, Igor Vaynberg [EMAIL PROTECTED] wrote:

 stick a content into a label and call label.setescapemodelstrings(false)

 -igor


 On 10/13/07, Jeremy Levy [EMAIL PROTECTED] wrote:
 
  I'm attempting to load the markup for a page based on values that are
  available when the page is constructed.  For example, I want to be able
 to
  pass a parameter into a page and then lookup the name of the content
 file
  in
  my database based on this parameter and then have the page load and
  display
  the appropriate content.
 
  I've tried looking at the custom resource loading example in the
 examples
  package but that seems to work by loading content based on the class
 name
  and I didn't see a way to extend it.
 
  I've tried overwriting the newMarkupResourceStream method, but it seems
 to
  be called before the constructor is called as well as before the session
  is
  available.
 
  Any suggestions?
 
  j
 



Re: Custom Content

2007-10-13 Thread Igor Vaynberg
see IMarkupResourceStreamProvider and IMarkupCacheKeyProvider. make that
page implement both and suck the markup in from the db.

-igor


On 10/13/07, Jeremy Levy [EMAIL PROTECTED] wrote:

 Will that work if the content includes a form?

 I would like to be able to have a page which includes a form but have a
 couple of different versions of the HTML and be able to select the one I
 want based on the param...

 In otherwords the HTML will contain form elements with wicket:id
 attributes
 which I want to be associated with elements I've added in the form class.
 The reason is I want to have radically different layouts for a page/form
 which I don't want to have to update any java code to enable, only add the
 new HTML file and update my database.

 Swapping in different style sheets which would seem to make the most sense
 isn't going to work in this case..

 j

 On 10/13/07, Igor Vaynberg [EMAIL PROTECTED] wrote:
 
  stick a content into a label and call label.setescapemodelstrings(false)
 
  -igor
 
 
  On 10/13/07, Jeremy Levy [EMAIL PROTECTED] wrote:
  
   I'm attempting to load the markup for a page based on values that are
   available when the page is constructed.  For example, I want to be
 able
  to
   pass a parameter into a page and then lookup the name of the content
  file
   in
   my database based on this parameter and then have the page load and
   display
   the appropriate content.
  
   I've tried looking at the custom resource loading example in the
  examples
   package but that seems to work by loading content based on the class
  name
   and I didn't see a way to extend it.
  
   I've tried overwriting the newMarkupResourceStream method, but it
 seems
  to
   be called before the constructor is called as well as before the
 session
   is
   available.
  
   Any suggestions?
  
   j
  
 



Re: Custom Content

2007-10-13 Thread Jeremy Levy
Igor,

I was afraid you were going to say that, we are still on 1.2.5 and I think
those are 1.3 features :(.  We aren't planning to upgrade until it's
released.

Can you think of any alternatives?  I've divided the entry page and the form
page into two separate pages, the first page figures out which html file to
use, stores it in a static hastable somewhere else, using the sessionid as
the key and forwards to the page that loads the HTML file. ( I know thats
very unwickety, not to mention hacky).  I then load the value out of the
hashtable in newMarkupResourceStream and that works.  Only issue is that
newMarkupResourceStream is only called on the first time the page loads when
it's compiled with the HTML i suppose.  Is there any way to prevent that for
one class / page?

J

On 10/13/07, Igor Vaynberg [EMAIL PROTECTED] wrote:

 see IMarkupResourceStreamProvider and IMarkupCacheKeyProvider. make that
 page implement both and suck the markup in from the db.

 -igor


 On 10/13/07, Jeremy Levy [EMAIL PROTECTED] wrote:
 
  Will that work if the content includes a form?
 
  I would like to be able to have a page which includes a form but have a
  couple of different versions of the HTML and be able to select the one I
  want based on the param...
 
  In otherwords the HTML will contain form elements with wicket:id
  attributes
  which I want to be associated with elements I've added in the form
 class.
  The reason is I want to have radically different layouts for a page/form
  which I don't want to have to update any java code to enable, only add
 the
  new HTML file and update my database.
 
  Swapping in different style sheets which would seem to make the most
 sense
  isn't going to work in this case..
 
  j
 
  On 10/13/07, Igor Vaynberg [EMAIL PROTECTED] wrote:
  
   stick a content into a label and call label.setescapemodelstrings
 (false)
  
   -igor
  
  
   On 10/13/07, Jeremy Levy [EMAIL PROTECTED] wrote:
   
I'm attempting to load the markup for a page based on values that
 are
available when the page is constructed.  For example, I want to be
  able
   to
pass a parameter into a page and then lookup the name of the content
   file
in
my database based on this parameter and then have the page load and
display
the appropriate content.
   
I've tried looking at the custom resource loading example in the
   examples
package but that seems to work by loading content based on the class
   name
and I didn't see a way to extend it.
   
I've tried overwriting the newMarkupResourceStream method, but it
  seems
   to
be called before the constructor is called as well as before the
  session
is
available.
   
Any suggestions?
   
j
   
  
 



Re: Custom Content

2007-10-13 Thread Igor Vaynberg
On 10/13/07, Jeremy Levy [EMAIL PROTECTED] wrote:

 newMarkupResourceStream is only called on the first time the page loads
 when
 it's compiled with the HTML i suppose.  Is there any way to prevent that
 for
 one class / page?


not as far as i know, this is why we added IMarkupCacheKeyProvider

what you can do is use your own markupresourcestreamprovider, but use it in
conjunection with getvariation(). so when you pull out that database id
return it from getvariation() and that way you will get one call to your
markupresourcestreamprovider for every database id instead of just a single
one.

-igor


J

 On 10/13/07, Igor Vaynberg [EMAIL PROTECTED] wrote:
 
  see IMarkupResourceStreamProvider and IMarkupCacheKeyProvider. make that
  page implement both and suck the markup in from the db.
 
  -igor
 
 
  On 10/13/07, Jeremy Levy [EMAIL PROTECTED] wrote:
  
   Will that work if the content includes a form?
  
   I would like to be able to have a page which includes a form but have
 a
   couple of different versions of the HTML and be able to select the one
 I
   want based on the param...
  
   In otherwords the HTML will contain form elements with wicket:id
   attributes
   which I want to be associated with elements I've added in the form
  class.
   The reason is I want to have radically different layouts for a
 page/form
   which I don't want to have to update any java code to enable, only add
  the
   new HTML file and update my database.
  
   Swapping in different style sheets which would seem to make the most
  sense
   isn't going to work in this case..
  
   j
  
   On 10/13/07, Igor Vaynberg [EMAIL PROTECTED] wrote:
   
stick a content into a label and call label.setescapemodelstrings
  (false)
   
-igor
   
   
On 10/13/07, Jeremy Levy [EMAIL PROTECTED] wrote:

 I'm attempting to load the markup for a page based on values that
  are
 available when the page is constructed.  For example, I want to be
   able
to
 pass a parameter into a page and then lookup the name of the
 content
file
 in
 my database based on this parameter and then have the page load
 and
 display
 the appropriate content.

 I've tried looking at the custom resource loading example in the
examples
 package but that seems to work by loading content based on the
 class
name
 and I didn't see a way to extend it.

 I've tried overwriting the newMarkupResourceStream method, but it
   seems
to
 be called before the constructor is called as well as before the
   session
 is
 available.

 Any suggestions?

 j

   
  
 



Re: Custom Content

2007-10-13 Thread Jeremy Levy
Thanks.  I see, so if I were to return a random value with getVariation,
that would effectively defeat reusing the complied version.

Could you give me more details on markupresourcestreamprovider I couldn't
find anything like that in the api, what should I extend / implement and how
do I use it?

j

On 10/13/07, Igor Vaynberg [EMAIL PROTECTED] wrote:

 On 10/13/07, Jeremy Levy [EMAIL PROTECTED] wrote:
 
  newMarkupResourceStream is only called on the first time the page loads
  when
  it's compiled with the HTML i suppose.  Is there any way to prevent that
  for
  one class / page?


 not as far as i know, this is why we added IMarkupCacheKeyProvider

 what you can do is use your own markupresourcestreamprovider, but use it
 in
 conjunection with getvariation(). so when you pull out that database id
 return it from getvariation() and that way you will get one call to your
 markupresourcestreamprovider for every database id instead of just a
 single
 one.

 -igor


 J
 
  On 10/13/07, Igor Vaynberg [EMAIL PROTECTED] wrote:
  
   see IMarkupResourceStreamProvider and IMarkupCacheKeyProvider. make
 that
   page implement both and suck the markup in from the db.
  
   -igor
  
  
   On 10/13/07, Jeremy Levy [EMAIL PROTECTED] wrote:
   
Will that work if the content includes a form?
   
I would like to be able to have a page which includes a form but
 have
  a
couple of different versions of the HTML and be able to select the
 one
  I
want based on the param...
   
In otherwords the HTML will contain form elements with wicket:id
attributes
which I want to be associated with elements I've added in the form
   class.
The reason is I want to have radically different layouts for a
  page/form
which I don't want to have to update any java code to enable, only
 add
   the
new HTML file and update my database.
   
Swapping in different style sheets which would seem to make the most
   sense
isn't going to work in this case..
   
j
   
On 10/13/07, Igor Vaynberg [EMAIL PROTECTED] wrote:

 stick a content into a label and call label.setescapemodelstrings
   (false)

 -igor


 On 10/13/07, Jeremy Levy [EMAIL PROTECTED] wrote:
 
  I'm attempting to load the markup for a page based on values
 that
   are
  available when the page is constructed.  For example, I want to
 be
able
 to
  pass a parameter into a page and then lookup the name of the
  content
 file
  in
  my database based on this parameter and then have the page load
  and
  display
  the appropriate content.
 
  I've tried looking at the custom resource loading example in the
 examples
  package but that seems to work by loading content based on the
  class
 name
  and I didn't see a way to extend it.
 
  I've tried overwriting the newMarkupResourceStream method, but
 it
seems
 to
  be called before the constructor is called as well as before the
session
  is
  available.
 
  Any suggestions?
 
  j
 

   
  
 



Re: Custom Content

2007-10-13 Thread Jeremy Levy
Okay, I think i figured it out. Using AbstractResourceStream which gets
content based on the ids.

Thank you.



On 10/13/07, Jeremy Levy [EMAIL PROTECTED] wrote:

 Thanks.  I see, so if I were to return a random value with getVariation,
 that would effectively defeat reusing the complied version.

 Could you give me more details on markupresourcestreamprovider I couldn't
 find anything like that in the api, what should I extend / implement and how
 do I use it?

 j

 On 10/13/07, Igor Vaynberg [EMAIL PROTECTED] wrote:
 
  On 10/13/07, Jeremy Levy [EMAIL PROTECTED] wrote:
  
   newMarkupResourceStream is only called on the first time the page
  loads
   when
   it's compiled with the HTML i suppose.  Is there any way to prevent
  that
   for
   one class / page?
 
 
  not as far as i know, this is why we added IMarkupCacheKeyProvider
 
  what you can do is use your own markupresourcestreamprovider, but use it
  in
  conjunection with getvariation(). so when you pull out that database id
  return it from getvariation() and that way you will get one call to your
  markupresourcestreamprovider for every database id instead of just a
  single
  one.
 
  -igor
 
 
  J
  
   On 10/13/07, Igor Vaynberg  [EMAIL PROTECTED] wrote:
   
see IMarkupResourceStreamProvider and IMarkupCacheKeyProvider. make
  that
page implement both and suck the markup in from the db.
   
-igor
   
   
On 10/13/07, Jeremy Levy [EMAIL PROTECTED] wrote:

 Will that work if the content includes a form?

 I would like to be able to have a page which includes a form but
  have
   a
 couple of different versions of the HTML and be able to select the
  one
   I
 want based on the param...

 In otherwords the HTML will contain form elements with wicket:id
 attributes
 which I want to be associated with elements I've added in the form
class.
 The reason is I want to have radically different layouts for a
   page/form
 which I don't want to have to update any java code to enable, only
  add
the
 new HTML file and update my database.

 Swapping in different style sheets which would seem to make the
  most
sense
 isn't going to work in this case..

 j

 On 10/13/07, Igor Vaynberg [EMAIL PROTECTED] wrote:
 
  stick a content into a label and call
  label.setescapemodelstrings
(false)
 
  -igor
 
 
  On 10/13/07, Jeremy Levy  [EMAIL PROTECTED] wrote:
  
   I'm attempting to load the markup for a page based on values
  that
are
   available when the page is constructed.  For example, I want
  to be
 able
  to
   pass a parameter into a page and then lookup the name of the
   content
  file
   in
   my database based on this parameter and then have the page
  load
   and
   display
   the appropriate content.
  
   I've tried looking at the custom resource loading example in
  the
  examples
   package but that seems to work by loading content based on the
   class
  name
   and I didn't see a way to extend it.
  
   I've tried overwriting the newMarkupResourceStream method, but
  it
 seems
  to
   be called before the constructor is called as well as before
  the
 session
   is
   available.
  
   Any suggestions?
  
   j