Re: JavaScriptReference with TextTemplate only returns the first retrieved value

2012-01-26 Thread Adam Gray
I just ran into this today.  Has this been solved yet (in 1.4)?

On Tue, Aug 23, 2011 at 10:23 PM, Doug Leeper  wrote:

> I have encountered this issue as well...and I believe I know the reason for
> this behavior.
>
> The TextTemplateResourceReference eventually is bound to the Application
> shared resources.  It never gets reset.  So the
> TextTemplateResourceReference will always use the first "variables" used
>  to
> substitute in the template.
>
> I believe the correct way to do achieve this behavior is to couple the text
> template substitution with a dynamic web resource.
>
> Am I correct on this?
>
> Has anyone done this before?
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/JavaScriptReference-with-TextTemplate-only-returns-the-first-retrieved-value-tp1877334p3764346.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: JavaScriptReference with TextTemplate only returns the first retrieved value

2011-08-23 Thread Doug Leeper
I have encountered this issue as well...and I believe I know the reason for
this behavior.

The TextTemplateResourceReference eventually is bound to the Application
shared resources.  It never gets reset.  So the
TextTemplateResourceReference will always use the first "variables" used  to
substitute in the template.

I believe the correct way to do achieve this behavior is to couple the text
template substitution with a dynamic web resource.

Am I correct on this?

Has anyone done this before?

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/JavaScriptReference-with-TextTemplate-only-returns-the-first-retrieved-value-tp1877334p3764346.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: Page with no markup - can be done better than with empty TextTemplate?

2011-02-12 Thread Marcin Zajączkowski
On 2011-02-12 23:26, Igor Vaynberg wrote:
> class mypage extends webpage {
>   public mypage() {
>  service.reset();
>  getsession().info(..);
>  throw new restartResponseException(getapplication().gethomepage());
>   }
> }

I knew there is a way :). Thanks Igor.


Marcin


> 2011/2/12 Marcin Zajączkowski :
>> Hi,
>>
>>
>> In the application I need to have an util page which reloads application
>> configuration. No markup is required, page implementation calls reload
>> from service layer, set info message in a session and redirect to a
>> homepage.
>>
>> I did it by creating EmptyMarkup class and returning it from
>> getMarkupResourceStream (IMarkupResourceStreamProvider interface) in my
>> page implementation.
>>
>> public class EmptyMarkup extends TextTemplate {
>>
>>@Override
>>public String getString() {
>>return "";
>>}
>>
>>@Override
>>public TextTemplate interpolate(Map variables) {
>>return this;
>>}
>>
>>
>> It works, but looks quite artificial. I think many applications need
>> that functionality, so I suspect it can be done more native with Wicket,
>> can it?
>>
>>
>> Regards
>> Marcin
>>
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 
> 


-- 
http://solidsoft.wordpress.com/ - Working code is not enough


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



Re: Page with no markup - can be done better than with empty TextTemplate?

2011-02-12 Thread Igor Vaynberg
class mypage extends webpage {
  public mypage() {
 service.reset();
 getsession().info(..);
 throw new restartResponseException(getapplication().gethomepage());
  }
}

-igor

2011/2/12 Marcin Zajączkowski :
> Hi,
>
>
> In the application I need to have an util page which reloads application
> configuration. No markup is required, page implementation calls reload
> from service layer, set info message in a session and redirect to a
> homepage.
>
> I did it by creating EmptyMarkup class and returning it from
> getMarkupResourceStream (IMarkupResourceStreamProvider interface) in my
> page implementation.
>
> public class EmptyMarkup extends TextTemplate {
>
>    @Override
>    public String getString() {
>        return "";
>    }
>
>    @Override
>    public TextTemplate interpolate(Map variables) {
>        return this;
>    }
>
>
> It works, but looks quite artificial. I think many applications need
> that functionality, so I suspect it can be done more native with Wicket,
> can it?
>
>
> Regards
> Marcin
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

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



Page with no markup - can be done better than with empty TextTemplate?

2011-02-12 Thread Marcin Zajączkowski
Hi,


In the application I need to have an util page which reloads application
configuration. No markup is required, page implementation calls reload
from service layer, set info message in a session and redirect to a
homepage.

I did it by creating EmptyMarkup class and returning it from
getMarkupResourceStream (IMarkupResourceStreamProvider interface) in my
page implementation.

public class EmptyMarkup extends TextTemplate {

@Override
public String getString() {
return "";
}

@Override
    public TextTemplate interpolate(Map variables) {
return this;
}


It works, but looks quite artificial. I think many applications need
that functionality, so I suspect it can be done more native with Wicket,
can it?


Regards
Marcin


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



Re: JavaScriptReference with TextTemplate only returns the first retrieved value

2009-01-16 Thread Igor Vaynberg
how about

class varsmodel extends abstractreadonlymodel {
  object getobject() {
user currentUser=session.get().getuser();
HashMap vars = new HashMap();
vars.put("password", currentUser.getPassword());
return vars;
   }
}

   TextTemplateResourceReference ref =
 new TextTemplateResourceReference(
 BasePage.class,
 "sensitive.js",
 "text/javascript",
 new varsmodel()){
 @Override
 public Time lastModifiedTime() { return Time.now(); }
   };


-igor

On Fri, Jan 16, 2009 at 11:09 AM, Trent Larson  wrote:
> Yes, it sounds like caching.  But it's not my browser: even if someone hits
> the page from a totally different computer or another browser, I get the
> same results: whatever was served first from that file is stuck, and nobody
> ever gets any different result.  (If the first browser was not logged in to
> the app, then the value is "${password}" for everyone.)  Yes, I tested my
> cache as you say.
>
> We've now tested with Tomcat as well, so it's not caching in the app
> server.  We've also done Linux vs Windows servers, and with and without
> Apache in the middle, running from Eclipse and from scripted startup.  I'm
> fairly sure I'm taking advantage of something in Wicket inadvertently; I've
> moved this stuff around into the session and a base page and the page
> constructor, and with and without any of the "final" keywords that I had at
> the beginning, all to no avail.
>
> My latest guess is that one of my shortcut methods that call a static method
> (eg. Session.get()) is getting the same one every time (though that's a
> stretch because all other pages show dynamics data correctly.)  It's just
> the .js file that's always gives the same result, no matter who hits it and
> no matter where they're from.
>
> BTW, the URL of the .js resource is this:
> .../resources/com.max.backoffice.page.BasePage/sensitive.js
>
> I must have changed something, because I swear it worked a month ago.  Erg.
>
> I'll try any wild ideas.  Thanks!
>
> Trent
>
> PS: Yes, you're absolutely right about the password security!  It hurts me
> to even show this as my example.
>
>
> On Thu, Jan 15, 2009 at 5:13 PM, Igor Vaynberg wrote:
>
>> sounds like your browser is caching it.
>>
>> try this:
>>
>> hit the page
>> check the value
>> empty browser cache
>> refresh the page
>> see if the value changed...
>>
>>
>> other then that i hope you know that storing a password in cleartext
>> inside a js file might not be the best idea :)
>>
>> -igor
>>
>> On Thu, Jan 15, 2009 at 4:02 PM, Trent Larson 
>> wrote:
>> > Some time ago, I wrote the following code to generate a javascript
>> resource
>> > with values that are unique to each user.  I would have sworn that it
>> > worked, and that it would return a different value depending on which
>> user
>> > was logged in.  However, I've just found that it is now always returning
>> the
>> > same value, whichever value was first retrieved.  Any ideas?
>> >
>> > Here's the javascript file (named "sensitive.js"):
>> >
>> > function getInfoTraxPassword() {
>> >  return "${password}";
>> > }
>> >
>> >
>> >
>> > Here is the Java code:
>> >
>> >HashMap vars = new HashMap();
>> >vars.put("password", currentUser.getPassword());
>> >TextTemplateResourceReference ref =
>> >  new TextTemplateResourceReference(
>> >  BasePage.class,
>> >  "sensitive.js",
>> >  "text/javascript",
>> >  new Model(vars)){
>> >  @Override
>> >  public Time lastModifiedTime() { return Time.now(); }
>> >};
>> >add(new JavaScriptReference("sensitiveJavascript", ref));
>> >
>> >
>> > I'm including it in the HTML HEAD this way:
>> >
>> >
>> >
>> >
>> > I'm currently running the Java code inside the Page class, and with my
>> > debugger I see it getting the right value as it steps through the code.
>>  Ask
>> > me anything else, I dare you!  I swear I've been through every
>> combination
>> > of logic, but once I hit that javascript file the first time, I can never
>> > get any other value for the ${password}.  I'm currently using Jetty for
>> the
>> > app server, with nothing (like Apache) in between.
>> >
>> > Any brainstorms are welcome.  Thanks!
>> > Trent
>> >
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>
>

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



Re: JavaScriptReference with TextTemplate only returns the first retrieved value

2009-01-16 Thread Trent Larson
Yes, it sounds like caching.  But it's not my browser: even if someone hits
the page from a totally different computer or another browser, I get the
same results: whatever was served first from that file is stuck, and nobody
ever gets any different result.  (If the first browser was not logged in to
the app, then the value is "${password}" for everyone.)  Yes, I tested my
cache as you say.

We've now tested with Tomcat as well, so it's not caching in the app
server.  We've also done Linux vs Windows servers, and with and without
Apache in the middle, running from Eclipse and from scripted startup.  I'm
fairly sure I'm taking advantage of something in Wicket inadvertently; I've
moved this stuff around into the session and a base page and the page
constructor, and with and without any of the "final" keywords that I had at
the beginning, all to no avail.

My latest guess is that one of my shortcut methods that call a static method
(eg. Session.get()) is getting the same one every time (though that's a
stretch because all other pages show dynamics data correctly.)  It's just
the .js file that's always gives the same result, no matter who hits it and
no matter where they're from.

BTW, the URL of the .js resource is this:
.../resources/com.max.backoffice.page.BasePage/sensitive.js

I must have changed something, because I swear it worked a month ago.  Erg.

I'll try any wild ideas.  Thanks!

Trent

PS: Yes, you're absolutely right about the password security!  It hurts me
to even show this as my example.


On Thu, Jan 15, 2009 at 5:13 PM, Igor Vaynberg wrote:

> sounds like your browser is caching it.
>
> try this:
>
> hit the page
> check the value
> empty browser cache
> refresh the page
> see if the value changed...
>
>
> other then that i hope you know that storing a password in cleartext
> inside a js file might not be the best idea :)
>
> -igor
>
> On Thu, Jan 15, 2009 at 4:02 PM, Trent Larson 
> wrote:
> > Some time ago, I wrote the following code to generate a javascript
> resource
> > with values that are unique to each user.  I would have sworn that it
> > worked, and that it would return a different value depending on which
> user
> > was logged in.  However, I've just found that it is now always returning
> the
> > same value, whichever value was first retrieved.  Any ideas?
> >
> > Here's the javascript file (named "sensitive.js"):
> >
> > function getInfoTraxPassword() {
> >  return "${password}";
> > }
> >
> >
> >
> > Here is the Java code:
> >
> >HashMap vars = new HashMap();
> >vars.put("password", currentUser.getPassword());
> >TextTemplateResourceReference ref =
> >  new TextTemplateResourceReference(
> >  BasePage.class,
> >  "sensitive.js",
> >  "text/javascript",
> >  new Model(vars)){
> >  @Override
> >  public Time lastModifiedTime() { return Time.now(); }
> >};
> >add(new JavaScriptReference("sensitiveJavascript", ref));
> >
> >
> > I'm including it in the HTML HEAD this way:
> >
> >
> >
> >
> > I'm currently running the Java code inside the Page class, and with my
> > debugger I see it getting the right value as it steps through the code.
>  Ask
> > me anything else, I dare you!  I swear I've been through every
> combination
> > of logic, but once I hit that javascript file the first time, I can never
> > get any other value for the ${password}.  I'm currently using Jetty for
> the
> > app server, with nothing (like Apache) in between.
> >
> > Any brainstorms are welcome.  Thanks!
> > Trent
> >
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: JavaScriptReference with TextTemplate only returns the first retrieved value

2009-01-15 Thread Igor Vaynberg
sounds like your browser is caching it.

try this:

hit the page
check the value
empty browser cache
refresh the page
see if the value changed...


other then that i hope you know that storing a password in cleartext
inside a js file might not be the best idea :)

-igor

On Thu, Jan 15, 2009 at 4:02 PM, Trent Larson  wrote:
> Some time ago, I wrote the following code to generate a javascript resource
> with values that are unique to each user.  I would have sworn that it
> worked, and that it would return a different value depending on which user
> was logged in.  However, I've just found that it is now always returning the
> same value, whichever value was first retrieved.  Any ideas?
>
> Here's the javascript file (named "sensitive.js"):
>
> function getInfoTraxPassword() {
>  return "${password}";
> }
>
>
>
> Here is the Java code:
>
>HashMap vars = new HashMap();
>vars.put("password", currentUser.getPassword());
>TextTemplateResourceReference ref =
>  new TextTemplateResourceReference(
>  BasePage.class,
>  "sensitive.js",
>  "text/javascript",
>  new Model(vars)){
>  @Override
>  public Time lastModifiedTime() { return Time.now(); }
>};
>add(new JavaScriptReference("sensitiveJavascript", ref));
>
>
> I'm including it in the HTML HEAD this way:
>
>
>
>
> I'm currently running the Java code inside the Page class, and with my
> debugger I see it getting the right value as it steps through the code.  Ask
> me anything else, I dare you!  I swear I've been through every combination
> of logic, but once I hit that javascript file the first time, I can never
> get any other value for the ${password}.  I'm currently using Jetty for the
> app server, with nothing (like Apache) in between.
>
> Any brainstorms are welcome.  Thanks!
> Trent
>

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



JavaScriptReference with TextTemplate only returns the first retrieved value

2009-01-15 Thread Trent Larson
Some time ago, I wrote the following code to generate a javascript resource
with values that are unique to each user.  I would have sworn that it
worked, and that it would return a different value depending on which user
was logged in.  However, I've just found that it is now always returning the
same value, whichever value was first retrieved.  Any ideas?

Here's the javascript file (named "sensitive.js"):

function getInfoTraxPassword() {
  return "${password}";
}



Here is the Java code:

HashMap vars = new HashMap();
vars.put("password", currentUser.getPassword());
TextTemplateResourceReference ref =
  new TextTemplateResourceReference(
  BasePage.class,
  "sensitive.js",
  "text/javascript",
  new Model(vars)){
  @Override
  public Time lastModifiedTime() { return Time.now(); }
};
add(new JavaScriptReference("sensitiveJavascript", ref));


I'm including it in the HTML HEAD this way:




I'm currently running the Java code inside the Page class, and with my
debugger I see it getting the right value as it steps through the code.  Ask
me anything else, I dare you!  I swear I've been through every combination
of logic, but once I hit that javascript file the first time, I can never
get any other value for the ${password}.  I'm currently using Jetty for the
app server, with nothing (like Apache) in between.

Any brainstorms are welcome.  Thanks!
Trent


Re: TextTemplate

2007-11-20 Thread Lars Hoss
Ah, and one more thing. What is "public abstract TextTemplate
interpolate(Map variables)" good for? Or why is this method abstract?
I would have expected to just overwrite getString() and be able
to use it for TextTemplateHeaderContributor.forJavaScript(TextTemplate,
IModel).
But then again TextTemplateHeaderContributor.forJavaScript(Clazz, String,
IModel) seems to be the better choice anyway?

Yours,
Lars


> Fixed in next release...
> (Jira issues & patches always welcome, of course! :-)
>
> /Gwyn
>
> On 20/11/2007, Lars Hoss <[EMAIL PROTECTED]> wrote:
>> Hi there!
>>
>> What JavaDocs has to say about TextTemplate:
>> Represents a text template that can do variable interpolation
>>
>> Uhm, yeah :-)
>> Maybe you could add VariableInterpolator to the "See also" list?
>>
>> Yours,
>> Lars
>>
>
> --
> Download Wicket 1.3.0-rc1 now! - http://wicketframework.org
>
> -
> 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: TextTemplate

2007-11-20 Thread Lars Hoss
Jira, good idea :-)

BTW, this blog entry was very useful:

http://chillenious.wordpress.com/2006/05/03/wicket-header-contributions-with-behaviors/

Yours,
Lars

> Fixed in next release...
> (Jira issues & patches always welcome, of course! :-)
>
> /Gwyn
>
> On 20/11/2007, Lars Hoss <[EMAIL PROTECTED]> wrote:
>> Hi there!
>>
>> What JavaDocs has to say about TextTemplate:
>> Represents a text template that can do variable interpolation
>>
>> Uhm, yeah :-)
>> Maybe you could add VariableInterpolator to the "See also" list?
>>
>> Yours,
>> Lars
>>
>
> --
> Download Wicket 1.3.0-rc1 now! - http://wicketframework.org
>
> -
> 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: TextTemplate

2007-11-20 Thread Gwyn Evans
Fixed in next release...
(Jira issues & patches always welcome, of course! :-)

/Gwyn

On 20/11/2007, Lars Hoss <[EMAIL PROTECTED]> wrote:
> Hi there!
>
> What JavaDocs has to say about TextTemplate:
> Represents a text template that can do variable interpolation
>
> Uhm, yeah :-)
> Maybe you could add VariableInterpolator to the "See also" list?
>
> Yours,
> Lars
>

-- 
Download Wicket 1.3.0-rc1 now! - http://wicketframework.org

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



TextTemplate

2007-11-20 Thread Lars Hoss
Hi there!

What JavaDocs has to say about TextTemplate:
Represents a text template that can do variable interpolation

Uhm, yeah :-)
Maybe you could add VariableInterpolator to the "See also" list?

Yours,
Lars




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