Inherit/Share query-params

Splash Forums PrettyFaces Users Inherit/Share query-params

This topic contains 15 replies, has 4 voices, and was last updated by  Lincoln Baxter III 6 years, 2 months ago.

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #17983

    jdcoffman
    Participant

    I have several pages all next to each other in a folder that all share a common set of query parameters that I map back to the same bean.

    Is there a way to share or inherit these parameters? There are about 20 of them and I don’t want to have to repeat that list of 20 query parameters over and over for each page.

    #21111

    Hi,

    For now I would suggest creating a ConfigurationPostProcessor that can do the appropriate setup for you.

    http://ocpsoft.com/docs/prettyfaces/3.3.0/en-US/html/Extensions.html#ConfigurationPostProcessor

    I know it’s a bit of a long way around, but it’s the best way to do this right now.

    PrettyFaces 4 should address this issue in a nicer way, but that’s a way out yet.

    ~Lincoln

    #21112

    mbenson
    Participant

    Actually I just used a ConfigurationPostProcessor to implement URLQueryParameter inheritance a couple of days ago. It was very easy using a recursive method + a set of mapping ids already processed.

    While we’re on the subject, however, the inheritance hierarchy didn’t support equals() all the way down (as I recall, one of the components of RequestParameter relied on Object.equals() ), such that I had to implement the check for equality among URLQueryParameters myself. I would request this situation be improved for the future.

    #21113

    @jdcoffman:

    Actually something like this should be possible with mapping inheritance. But unfortunately inheritance of query parameters in not yet implemented in PrettyFaces. See:

    http://ocpsoft.com/docs/prettyfaces/3.3.0/en-US/html/Configuration.html#config.mapping.parents

    This issue request is tracked here:

    http://code.google.com/p/prettyfaces/issues/detail?id=75

    I hope we will be able to implement this for the next version.

    @mbenson:

    Thanks for this feedback! Could you perhaps open a ticket for this? So we can fix this in the next release? Thanks!

    #21114

    @mbenson if you feel so inclined, would you like to share your solution?

    #21115

    mbenson
    Participant

    @chkal: http://code.google.com/p/prettyfaces/issues/detail?id=115

    I would think it possible to implement equals/hashCode on LazyExpression using the beanClass + component. It would be up to you guys whether it is also necessary to test the equality of the embedded LazyBeanNameFinder.

    @lincoln: I don’t really want to C&P code I wrote on my employer’s dime; however, briefly:

    void process(PrettyConfig config) {
    HashSet<String> processed = new HashSet<String>();
    for (UrlMapping mapping : config.getMappings()) {
    process(config, processed);
    }
    }

    void process(UrlMapping mapping, PrettyConfig config, Set<String> processed) {
    if (processed.contains(mapping)) {
    return;
    }
    UrlMapping parent = config.getMappingById(mapping.getParentId());
    if (parent != null) {
    process(parent, config, processed);
    for (QueryParameter parentParam : parent.getQueryParams()) {
    //exercise for the reader, comparing name/expression string
    if (!containsSimilar(mapping.getQueryParams(), parentParam)) {
    mapping.getQueryParams().add(parentParam);
    }
    }
    }
    processed.add(mapping.getId());
    }

    #21116

    Hey all,

    I just implemented inheritance for query parameters and URL actions. In my tests it seems to work very fine. The current snapshots of 3.3.1 already contain my changes. Perhaps someone would like to take the new version for a test drive? You will find all the required details for how to use the snapshots in your project here:

    https://github.com/ocpsoft/prettyfaces/wiki/Snapshots

    Thanks

    Christian

    #21117

    mbenson
    Participant

    So you decided inheritance of these items was a sensible default? Not questioning the decision, but making conversation and seeking understanding ;) . I’ll give the snapshots a try this coming week.

    Matt

    P.S. (off-topic) how the hell do I change my avatar to something cool?

    #21118

    Hey Matt,

    yes, I think query parameters should definitively be inherited per default. I think that users expect this to happen if they use the parentId feature. We are currently discussing how to handle the inheritance of URL actions. In the current snapshots a child mapping will simply inherit all actions from the parents. But this may not be desired in all cases. See my post here for details.

    I hope the new inheritance code will work for you. I think you will be able to drop your custom ConfigurationPostProcessor in the future as PrettyFaces will do everything for you.

    Regarding the avatar: The forum is using gravatar.com for the avatars. Just sign up there with the email address you used for your forum registration and it should work out of the box! :)

    Have a nice weekend. :)

    Christian

    #21119

    Agreed,

    I think that the inheritance feature was probably over-thought when I first created it. Simply inheriting everything is definitely a more logical approach.

    I’m looking forward to trying this out myself :)

    #21120

    @lincoln: So you think we won’t need a inheritable flag for URL actions like I proposed? I would be OK with that! :)

    @mbenson: Much better avatar! :)

    #21121

    mbenson
    Participant

    chkal: thanks! ;)

    #21122

    mbenson
    Participant

    Hi guys,

    Trying to give the snapshot a spin; wanted to simply add http://ocpsoft.com/repository as a proxy snapshot repo in my Nexus install, then add it to my snapshots group. However the artifact names at http://ocpsoft.com/repository/com/ocpsoft/prettyfaces-jsf2/3.3.1-SNAPSHOT/ don’t look like what I’m accustomed to seeing. Is there anything you guys are aware of in that regard of which *I* should also be aware?

    Thanks,

    Matt

    #21123

    Not that I know of. We use the mvn:deploy plugin and the wagon FTP carrier.

    #21124

    mbenson
    Participant

    not sure what the deal was; snapshot is coming through for me now. Sorry for the noise. Just tested this out and working as advertised. Thanks!

Viewing 15 posts - 1 through 15 (of 16 total)

You must be logged in to reply to this topic.

Comments are closed.