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 message will be added to the discussion below: http://apache-wicket.1842946.n4.nabble.com/how-to-modify-internal-JavascriptResourceReference-packaged-with-component-tp4656344p4656525.html To unsubscribe from how to modify internal JavascriptResourceReference packaged with component, click here <http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4656344&code=ZXZhbkBub3ZlbHV0aW9uLmNvbXw0NjU2MzQ0fDM5NTQ3MjY5OA==> . <http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> NAML -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/how-to-modify-internal-JavascriptResourceReference-packaged-with-component-tp4656344p4656622.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