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 <e...@novelution.com> 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
> 

Reply via email to