add new mapping during runtime

Splash Forums PrettyFaces Users add new mapping during runtime

This topic contains 4 replies, has 2 voices, and was last updated by  dev123 9 years, 7 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #18469



    i try to add a new url mapping at runtime, but it does not work.

    On server startup i load the pretty config and add the mapping from db (ConfigurationProvider).

    Now i would like to add a new mapping at runtime, but it occurs an exception, since the mapping list is already in use.

    is there any way to add new mappings add runtime?



    I think adding mappings at runtime should actually work fine. Could you post some more details. Which exception do you get?



    Thanks for the quick response :).

    I`m using PrettyFaces in Version 3.3.3 for JSF2. I want to add a new link to the current mapping. In the method I want to create a new UrlMapping like this:

    UrlMapping urlMapping = new UrlMapping();

    and add this mapping to the current configuration like this:


    now this exception occurs:

    Caused by: java.lang.UnsupportedOperationException
    at java.util.Collections$UnmodifiableCollection.add(


    Hmmm, yeah, that’s because getMappings() returns an unmodifiable view for the list of mappings. So adding a mapping to this list won’t work. But you could use setMappings() to work around this. Just retrieve the current list of mappings and construct a new list which also contains the new mapping. Than use setMappings() to set the new mapping list.

    I know that this isn’t a very nice solution, but it should work. Adding mappings dynamically is a very rare usecase nobody thought of while building the API back then. :)




    thank you very much. it works fine :).

Viewing 5 posts - 1 through 5 (of 5 total)

The forum ‘PrettyFaces Users’ is closed to new topics and replies.

Comments are closed.