RE: how to modify internal JavascriptResourceReference packaged with component

2013-02-20 Thread evan
Hi Francois,

Okay, I see what you're saying now.  Yes, that makes sense - I can just 
hardcode those values and not bother overriding other methods.  It loses the 
flexibility on setting the max value in the constructor, but I don't actually 
need that in my situation and I agree that it is a good compromise!  And 
eventually, the resource replacement feature after upgrading to wicket 6 will 
be the ideal solution.  Thanks for your patience and the help!

-Evan

 

From: Francois Meillet [via Apache Wicket] 
[mailto:ml-node+s1842946n4656525...@n4.nabble.com] 
Sent: Monday, February 18, 2013 6:02 PM
To: evan
Subject: Re: how to modify internal JavascriptResourceReference packaged with 
component

 

final ResourceReference YOURJS = new JavaScriptResourceReference( 
Yourclass.class, "YourMultiFileUploadField.js"); 
final int max = 3; 
MultiFileUploadField x = new MultiFileUploadField("yourid"){ 

@Override 
public void renderHead(IHeaderResponse response) { 
response.render(JavaScriptHeaderItem.forReference(YOURJS)); 
response.render(OnDomReadyHeaderItem.forScript("new 
MultiSelector('" + getInputName() +   "', document.getElementById('container'), 
" + max + ",'" +getString("org.apache.wicket.mfu.delete") + 
"').addElement(document.getElementById('upload'));")); 
} 
}; 

I think it's a good compromise 

François Meillet 
Formation Wicket - Développement Wicket 





Le 18 févr. 2013 à 19:26, evan <[hidden email]> a écrit : 


>> 
>> This is improved in Wicket 6. 
>> You can use 
>> org.apache.wicket.protocol.http.WebApplication#addResourceReplacement for 
>> exactly this use case. 
>> See http://wicketinaction.com/2012/07/wicket-6-resource-management/
>> You are recommended to upgrade your application. 
>> 
>> 
> Nice - the addResourceReplacement is great.  Thanks Martin - I will 
> try to upgrade the application soon.  In the meantime, I will override 
> the necessary methods in the class, as per Francois' suggestion. 
> 
> 
> 
> if the question is how to modify internal JavascriptResourceReference 
> packaged with component 
>> I will just override 
>>@Override 
>>public void renderHead(IHeaderResponse response) 
>>{ 
>>// initialize the javascript library 
>>response.render(JavaScriptHeaderItem.forReference(JS)); 
>>response.render(OnDomReadyHeaderItem.forScript("new 
>> MultiSelector('" + getInputName() + 
>>"', document.getElementById('" + 
>> container.getMarkupId() + "'), " + max + ",'" + 
>>getString("org.apache.wicket.mfu.delete") + 
>> "').addElement(document.getElementById('" + 
>>upload.getMarkupId() + "'));")); 
>>} 
>> Max is the max number of files a user can upload. 
>> container.getMarkupId() is container 
>> upload.getMarkupId() is upload 
> 
> 
> 
> Francois, I'm sorry to belabor this question - but I just want to make 
> sure I'm not missing something still.  I think I understand what to do 
> now and it works - I was just pointing out that if I extend the 
> MultiFileUploadField class, it is not enough to only override that one 
> method, because the reference to those 3 variables in my overridden 
> method would be trying to reference private members from the super 
> class and won't be allowed.  So, I just need to also create a new 
> version of the variables in the extended class, and override the 
> constructors in which they are defined, and any other methods in which 
> they are referenced.  Were you saying in your last response that this 
> is not necessary, for some reason that I'm still missing?  In any 
> case, doing it this way works and is fine as a temporary solution 
> until I upgrade and can use the addResourceReplacement approach. 
> Thanks again for all the help! 
> 
> Best, 
> -Evan 
> 
> 
> 
> 
> -- 
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/how-to-modify-internal-JavascriptResourceReference-packaged-with-component-tp4656344p4656516.html
> Sent from the Users forum mailing list archive at Nabble.com. 
> 
> - 
> To unsubscribe, e-mail: [hidden email] 
> For additional commands, e-mail: [hidden email] 
> 

 

François Meillet 
Formation Wicket - Développement Wicket 

 

  _  

If you reply to this email, your me

Re: how to modify internal JavascriptResourceReference packaged with component

2013-02-18 Thread Francois Meillet
final ResourceReference YOURJS = new JavaScriptResourceReference(   
Yourclass.class, "YourMultiFileUploadField.js");
final int max = 3;
MultiFileUploadField x = new MultiFileUploadField("yourid"){

@Override
public void renderHead(IHeaderResponse response) {
response.render(JavaScriptHeaderItem.forReference(YOURJS));
response.render(OnDomReadyHeaderItem.forScript("new 
MultiSelector('" + getInputName() +   "', document.getElementById('container'), 
" + max + ",'" +getString("org.apache.wicket.mfu.delete") + 
"').addElement(document.getElementById('upload'));"));
}
};

I think it's a good compromise

François Meillet
Formation Wicket - Développement Wicket





Le 18 févr. 2013 à 19:26, evan  a écrit :

>> 
>> This is improved in Wicket 6.
>> You can use
>> org.apache.wicket.protocol.http.WebApplication#addResourceReplacement for
>> exactly this use case.
>> See http://wicketinaction.com/2012/07/wicket-6-resource-management/
>> You are recommended to upgrade your application.
>> 
>> 
> Nice - the addResourceReplacement is great.  Thanks Martin - I will
> try to upgrade the application soon.  In the meantime, I will override
> the necessary methods in the class, as per Francois' suggestion.
> 
> 
> 
> if the question is how to modify internal JavascriptResourceReference
> packaged with component
>> I will just override
>>@Override
>>public void renderHead(IHeaderResponse response)
>>{
>>// initialize the javascript library
>>response.render(JavaScriptHeaderItem.forReference(JS));
>>response.render(OnDomReadyHeaderItem.forScript("new 
>> MultiSelector('" + getInputName() +
>>"', document.getElementById('" + 
>> container.getMarkupId() + "'), " + max + ",'" +
>>getString("org.apache.wicket.mfu.delete") + 
>> "').addElement(document.getElementById('" +
>>upload.getMarkupId() + "'));"));
>>}
>> Max is the max number of files a user can upload.
>> container.getMarkupId() is container
>> upload.getMarkupId() is upload
> 
> 
> 
> Francois, I'm sorry to belabor this question - but I just want to make
> sure I'm not missing something still.  I think I understand what to do
> now and it works - I was just pointing out that if I extend the
> MultiFileUploadField class, it is not enough to only override that one
> method, because the reference to those 3 variables in my overridden
> method would be trying to reference private members from the super
> class and won't be allowed.  So, I just need to also create a new
> version of the variables in the extended class, and override the
> constructors in which they are defined, and any other methods in which
> they are referenced.  Were you saying in your last response that this
> is not necessary, for some reason that I'm still missing?  In any
> case, doing it this way works and is fine as a temporary solution
> until I upgrade and can use the addResourceReplacement approach.
> Thanks again for all the help!
> 
> Best,
> -Evan
> 
> 
> 
> 
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/how-to-modify-internal-JavascriptResourceReference-packaged-with-component-tp4656344p4656516.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: how to modify internal JavascriptResourceReference packaged with component

2013-02-18 Thread evan
>
> This is improved in Wicket 6.
> You can use
> org.apache.wicket.protocol.http.WebApplication#addResourceReplacement for
> exactly this use case.
> See http://wicketinaction.com/2012/07/wicket-6-resource-management/
> You are recommended to upgrade your application.
>
>
Nice - the addResourceReplacement is great.  Thanks Martin - I will
try to upgrade the application soon.  In the meantime, I will override
the necessary methods in the class, as per Francois' suggestion.



if the question is how to modify internal JavascriptResourceReference
packaged with component
> I will just override
> @Override
> public void renderHead(IHeaderResponse response)
> {
> // initialize the javascript library
> response.render(JavaScriptHeaderItem.forReference(JS));
> response.render(OnDomReadyHeaderItem.forScript("new 
> MultiSelector('" + getInputName() +
> "', document.getElementById('" + 
> container.getMarkupId() + "'), " + max + ",'" +
> getString("org.apache.wicket.mfu.delete") + 
> "').addElement(document.getElementById('" +
> upload.getMarkupId() + "'));"));
> }
> Max is the max number of files a user can upload.
> container.getMarkupId() is container
> upload.getMarkupId() is upload



Francois, I'm sorry to belabor this question - but I just want to make
sure I'm not missing something still.  I think I understand what to do
now and it works - I was just pointing out that if I extend the
MultiFileUploadField class, it is not enough to only override that one
method, because the reference to those 3 variables in my overridden
method would be trying to reference private members from the super
class and won't be allowed.  So, I just need to also create a new
version of the variables in the extended class, and override the
constructors in which they are defined, and any other methods in which
they are referenced.  Were you saying in your last response that this
is not necessary, for some reason that I'm still missing?  In any
case, doing it this way works and is fine as a temporary solution
until I upgrade and can use the addResourceReplacement approach.
Thanks again for all the help!

Best,
-Evan




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/how-to-modify-internal-JavascriptResourceReference-packaged-with-component-tp4656344p4656516.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: how to modify internal JavascriptResourceReference packaged with component

2013-02-18 Thread Martin Grigorov
Hi,

This is improved in Wicket 6.
You can use
org.apache.wicket.protocol.http.WebApplication#addResourceReplacement for
exactly this use case.
See http://wicketinaction.com/2012/07/wicket-6-resource-management/
You are recommended to upgrade your application.


On Thu, Feb 14, 2013 at 1:39 AM, Evan Sable  wrote:

> Hi,
>
> I'm working on a project that's on wicket 1.4.  It's using
> the MultiFileUploadField class.  I see in the code for that class that in
> renderHead, it calls:
> response.renderJavascriptReference(JS);
> and earlier it defines:
> private static final ResourceReference JS = new
> JavascriptResourceReference(
> MultiFileUploadField.class, "MultiFileUploadField.js");
>
> But, I'd like to make a minor modification to the actual javascript in
> MultiFileUploadField.js.  Specifically, I want to modify that code to
> remove the "c:/fakepath" prefix that appears in the box with the list of
> selected files below the field (in chrome and safari - not a problem in
> firefox and ie).  If I could just over-ride the javascript contents of that
> file, it would be an easy fix.  But, more generally, I'd like to know not
> just for this specific issue, is there a "wicket way" to override the
> packaged javascript resource that comes with a component?  Perhaps is there
> a simple way to extend the MultiFileUploadField class with my own class,
> and somehow keep the rest of the code as is, but specify an alternate
> resource?  It's private in that class, so I don't see how I'd do this, but
> maybe I'm missing something obvious.  Or maybe is there some way to keep
> using the same class but to tell the application that I want to replace the
> corresponding javascript file with my own?  Or is there some other approach
> I should be taking when this type of issue comes up?
>
> Thanks very much for any advice,
> -Evan
>



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


Re: how to modify internal JavascriptResourceReference packaged with component

2013-02-15 Thread Francois Meillet
if the question is how to modify internal JavascriptResourceReference packaged 
with component

I will just override
@Override
public void renderHead(IHeaderResponse response)
{
// initialize the javascript library
response.render(JavaScriptHeaderItem.forReference(JS));
response.render(OnDomReadyHeaderItem.forScript("new 
MultiSelector('" + getInputName() +
"', document.getElementById('" + 
container.getMarkupId() + "'), " + max + ",'" +
getString("org.apache.wicket.mfu.delete") + 
"').addElement(document.getElementById('" +
upload.getMarkupId() + "'));"));
}

Max is the max number of files a user can upload.
container.getMarkupId() is container
upload.getMarkupId() is upload

Hope this helps


François Meillet
Formation Wicket - Développement Wicket





Le 15 févr. 2013 à 20:11, evan  a écrit :

> Okay, so you are saying I need to create my own versions of each of those
> private variables referenced in renderHead, and override any methods that
> use any of them, to reference my own, is that right?  Unfortunately, it
> still has maintenance implications, but I guess that might just be
> inevitable given what I want to do.
> 
> Thanks for the help!
> 
> 
> Francois Meillet wrote
>> Le 15 févr. 2013 à 16:48, evan <
> 
>> evan@
> 
>> > a écrit :
>> 
>>> Hi Francois,
>>> 
>>> Thanks, but actually this still has issues.  At first I thought it was
>>> clearly the simple thing I was missing, but then I remembered there's
>>> still
>>> a problem - the line in renderHead copied from the original
>>> MultiFileUploadField uses private members container, max, and upload, so
>>> the
>>> extending class won't be able to do this.  I realize I could create my
>>> own
>>> versions of each of these (like you suggested with YOURJS), and then
>>> override every method that uses any of them, replacing the reference with
>>> the new versions.  But that might propagate to usage of other fields, and
>>> at
>>> that point
>> 
>>> it might be simpler to just copy the entire contents of the
>>> original class's code into a new version of the class of my own,
>> I would not do that, as you say after, there will be maintenances issues
>> 
>>> with the
>>> only modification being the location of the .js resource.  Neither of
>>> these
>>> two things would be hard to do, and maybe they are simply the only
>>> solutions, but it feels like that's not great, because it loses the
>>> ability
>>> to leverage the fact that future versions of the api class might improve
>>> in
>>> other ways and there'd be maintenance issues keeping my version
>>> up-to-date
>>> with the rest of the api.  Is that just what needs to be done, or is
>>> there
>>> possibly some other way to use the existing class directly and just swap
>>> some alternate resource file in place of the default one? 
>>> 
>> As you say, you 'd like to make a minor modification to the actual
>> javascript in , MultiFileUploadField.js,
>> so in this case I will choose the renderHead override method.
>> 
>> 
>> François Meillet
>> Formation Wicket - Développement Wicket
> 
> 
> 
> 
> 
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/how-to-modify-internal-JavascriptResourceReference-packaged-with-component-tp4656344p4656422.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: how to modify internal JavascriptResourceReference packaged with component

2013-02-15 Thread evan
Okay, so you are saying I need to create my own versions of each of those
private variables referenced in renderHead, and override any methods that
use any of them, to reference my own, is that right?  Unfortunately, it
still has maintenance implications, but I guess that might just be
inevitable given what I want to do.

Thanks for the help!


Francois Meillet wrote
> Le 15 févr. 2013 à 16:48, evan <

> evan@

> > a écrit :
> 
>> Hi Francois,
>> 
>> Thanks, but actually this still has issues.  At first I thought it was
>> clearly the simple thing I was missing, but then I remembered there's
>> still
>> a problem - the line in renderHead copied from the original
>> MultiFileUploadField uses private members container, max, and upload, so
>> the
>> extending class won't be able to do this.  I realize I could create my
>> own
>> versions of each of these (like you suggested with YOURJS), and then
>> override every method that uses any of them, replacing the reference with
>> the new versions.  But that might propagate to usage of other fields, and
>> at
>> that point
> 
>> it might be simpler to just copy the entire contents of the
>> original class's code into a new version of the class of my own,
> I would not do that, as you say after, there will be maintenances issues
> 
>> with the
>> only modification being the location of the .js resource.  Neither of
>> these
>> two things would be hard to do, and maybe they are simply the only
>> solutions, but it feels like that's not great, because it loses the
>> ability
>> to leverage the fact that future versions of the api class might improve
>> in
>> other ways and there'd be maintenance issues keeping my version
>> up-to-date
>> with the rest of the api.  Is that just what needs to be done, or is
>> there
>> possibly some other way to use the existing class directly and just swap
>> some alternate resource file in place of the default one? 
>> 
> As you say, you 'd like to make a minor modification to the actual
> javascript in , MultiFileUploadField.js,
> so in this case I will choose the renderHead override method.
> 
> 
> François Meillet
> Formation Wicket - Développement Wicket





--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/how-to-modify-internal-JavascriptResourceReference-packaged-with-component-tp4656344p4656422.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: how to modify internal JavascriptResourceReference packaged with component

2013-02-15 Thread Francois Meillet

Le 15 févr. 2013 à 16:48, evan  a écrit :

> Hi Francois,
> 
> Thanks, but actually this still has issues.  At first I thought it was
> clearly the simple thing I was missing, but then I remembered there's still
> a problem - the line in renderHead copied from the original
> MultiFileUploadField uses private members container, max, and upload, so the
> extending class won't be able to do this.  I realize I could create my own
> versions of each of these (like you suggested with YOURJS), and then
> override every method that uses any of them, replacing the reference with
> the new versions.  But that might propagate to usage of other fields, and at
> that point

> it might be simpler to just copy the entire contents of the
> original class's code into a new version of the class of my own,
I would not do that, as you say after, there will be maintenances issues

> with the
> only modification being the location of the .js resource.  Neither of these
> two things would be hard to do, and maybe they are simply the only
> solutions, but it feels like that's not great, because it loses the ability
> to leverage the fact that future versions of the api class might improve in
> other ways and there'd be maintenance issues keeping my version up-to-date
> with the rest of the api.  Is that just what needs to be done, or is there
> possibly some other way to use the existing class directly and just swap
> some alternate resource file in place of the default one? 
> 
As you say, you 'd like to make a minor modification to the actual javascript 
in , MultiFileUploadField.js,
so in this case I will choose the renderHead override method.


François Meillet
Formation Wicket - Développement Wicket



> Thanks again,
> -Evan
> 
> 
> Francois Meillet wrote
>> Hi Evan,
>> 
>> try this
>> 
>> private static final ResourceReference YOURJS = new
>> JavaScriptResourceReference( YourClassWhereJavascriptReside.js.class,
>> "YourModifiedJavascript.js");
>> 
>> @Override
>> public void renderHead(IHeaderResponse response)
>> {
>>  response.render(JavaScriptHeaderItem.forReference(YOURJS));
>>  response.render(OnDomReadyHeaderItem.forScript("new MultiSelector('" +
>> getInputName() +
>>  "', document.getElementById('" + 
>> container.getMarkupId() + "'),
>> " + max + ",'" +
>>  getString("org.apache.wicket.mfu.delete") +
>> "').addElement(document.getElementById('" +
>>  upload.getMarkupId() + "'));"));
>> }
> 
> 
> 
> 
> 
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/how-to-modify-internal-JavascriptResourceReference-packaged-with-component-tp4656344p4656416.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
> 


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



Re: how to modify internal JavascriptResourceReference packaged with component

2013-02-15 Thread evan
Hi Francois,

Thanks, but actually this still has issues.  At first I thought it was
clearly the simple thing I was missing, but then I remembered there's still
a problem - the line in renderHead copied from the original
MultiFileUploadField uses private members container, max, and upload, so the
extending class won't be able to do this.  I realize I could create my own
versions of each of these (like you suggested with YOURJS), and then
override every method that uses any of them, replacing the reference with
the new versions.  But that might propagate to usage of other fields, and at
that point it might be simpler to just copy the entire contents of the
original class's code into a new version of the class of my own, with the
only modification being the location of the .js resource.  Neither of these
two things would be hard to do, and maybe they are simply the only
solutions, but it feels like that's not great, because it loses the ability
to leverage the fact that future versions of the api class might improve in
other ways and there'd be maintenance issues keeping my version up-to-date
with the rest of the api.  Is that just what needs to be done, or is there
possibly some other way to use the existing class directly and just swap
some alternate resource file in place of the default one? 

Thanks again,
-Evan


Francois Meillet wrote
> Hi Evan,
> 
> try this
> 
> private static final ResourceReference YOURJS = new
> JavaScriptResourceReference( YourClassWhereJavascriptReside.js.class,
> "YourModifiedJavascript.js");
> 
> @Override
> public void renderHead(IHeaderResponse response)
> {
>   response.render(JavaScriptHeaderItem.forReference(YOURJS));
>   response.render(OnDomReadyHeaderItem.forScript("new MultiSelector('" +
> getInputName() +
>   "', document.getElementById('" + 
> container.getMarkupId() + "'),
> " + max + ",'" +
>   getString("org.apache.wicket.mfu.delete") +
> "').addElement(document.getElementById('" +
>   upload.getMarkupId() + "'));"));
> }





--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/how-to-modify-internal-JavascriptResourceReference-packaged-with-component-tp4656344p4656416.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: how to modify internal JavascriptResourceReference packaged with component

2013-02-14 Thread Francois Meillet
Hi Evan,

try this

private static final ResourceReference YOURJS = new 
JavaScriptResourceReference( YourClassWhereJavascriptReside.js.class, 
"YourModifiedJavascript.js");

@Override
public void renderHead(IHeaderResponse response)
{
response.render(JavaScriptHeaderItem.forReference(YOURJS));
response.render(OnDomReadyHeaderItem.forScript("new MultiSelector('" + 
getInputName() +
"', document.getElementById('" + 
container.getMarkupId() + "'), " + max + ",'" +
getString("org.apache.wicket.mfu.delete") + 
"').addElement(document.getElementById('" +
upload.getMarkupId() + "'));"));
}



François Meillet
Formation Wicket - Développement Wicket





Le 14 févr. 2013 à 00:39, Evan Sable  a écrit :

> Hi,
> 
> I'm working on a project that's on wicket 1.4.  It's using
> the MultiFileUploadField class.  I see in the code for that class that in
> renderHead, it calls:
> response.renderJavascriptReference(JS);
> and earlier it defines:
> private static final ResourceReference JS = new JavascriptResourceReference(
> MultiFileUploadField.class, "MultiFileUploadField.js");
> 
> But, I'd like to make a minor modification to the actual javascript in
> MultiFileUploadField.js.  Specifically, I want to modify that code to
> remove the "c:/fakepath" prefix that appears in the box with the list of
> selected files below the field (in chrome and safari - not a problem in
> firefox and ie).  If I could just over-ride the javascript contents of that
> file, it would be an easy fix.  But, more generally, I'd like to know not
> just for this specific issue, is there a "wicket way" to override the
> packaged javascript resource that comes with a component?  Perhaps is there
> a simple way to extend the MultiFileUploadField class with my own class,
> and somehow keep the rest of the code as is, but specify an alternate
> resource?  It's private in that class, so I don't see how I'd do this, but
> maybe I'm missing something obvious.  Or maybe is there some way to keep
> using the same class but to tell the application that I want to replace the
> corresponding javascript file with my own?  Or is there some other approach
> I should be taking when this type of issue comes up?
> 
> Thanks very much for any advice,
> -Evan