I.e.

package temp;

import org.apache.wicket.util.file.IResourceFinder;
import org.apache.wicket.util.resource.IResourceStream;

import java.util.List;

/**
 * CustomDelegatingResourceFinder
 */
public class CustomDelegatingResourceFinder implements IResourceFinder {

    private final IResourceFinder defaultFinder;

    private final List<IResourceFinder> others;

    public CustomDelegatingResourceFinder(IResourceFinder defaultFinder,
List<IResourceFinder> others) {
        this.defaultFinder = defaultFinder;
        this.others = others;
    }

    @Override
    public IResourceStream find(Class<?> clazz, String pathname) {
        IResourceStream resourceStream = defaultFinder.find(clazz,
pathname);
        if(resourceStream != null) {
            return resourceStream;
        }
        for(IResourceFinder finder : others) {
            IResourceStream stream = finder.find(clazz, pathname);
            if(stream != null) {
                return stream;
            }
        }
        return null;
    }
}

1- val customFinder = new CustomDelegatingResourceFinder(yourCurrentFinder,
app.getFinders())
2- app.setFinders(Collections.singletonList(customFinder)

Disclaimer: I haven't tried code above.




On Thu, Feb 11, 2016 at 12:28 PM, Ernesto Reinaldo Barreiro <
reier...@gmail.com> wrote:

> Hi,
>
> Or simply create a finder that:
>
> 1- Do your default logic
> 2- Contains the finders on getResourceFinders()
> 3- You use setResourceFinders to set this unique resource finder (that
> simply delegates n standard finder if your custom logic fails)
>
> On Thu, Feb 11, 2016 at 12:17 PM, Bas Gooren <b...@iswd.nl> wrote:
>
>> Hi Marieke,
>>
>> I see that ResourceSettings exposes method getResourceFinders() which
>> returns a List.
>> Assuming that’s where you register your custom finder, isn’t the easy
>> solution to simply add it to the top of the list?
>>
>> E.g. add(0, yourFinder) instead of add(yourFinder)?
>>
>>
>> Met vriendelijke groet,
>> Kind regards,
>>
>> Bas
>>
>> Op 11 februari 2016 bij 12:11:46, Marieke Vandamme (
>> marieke.vanda...@tvh.com) schreef:
>>
>> ​Hi,
>>
>> ​We work with an extra ResourceFinder a lot, so that we can modify html
>> when webapplication is already running.
>> Now I want to change the html from a library, but the html is still in the
>> library. I can not remove it from there.. Is there some way I can override
>> this existing html, without removing it from the library? Something like
>> defining a ResourceFinder as the first to look from?
>> Thanks for any help ! Kind Regards, Marieke Vandamme
>>
>> --
>>
>>
>> **** DISCLAIMER ****
>>
>> http://www.tvh.com/glob/en/email-disclaimer
>>
>> "This message is delivered to all addressees subject to the conditions
>> set forth in the attached disclaimer, which is an integral part of this
>> message."
>>
>
>
>
> --
> Regards - Ernesto Reinaldo Barreiro
>



-- 
Regards - Ernesto Reinaldo Barreiro

Reply via email to