8 Replies Latest reply on Aug 8, 2008 3:25 AM by deanhiller2000

    validation erases url params???

    deanhiller2000

      Once the user chooses a company, the company alias needs to follow him around in the url(as I am rewriting the url so state in session is not an option).  Therefore, I need
      http://x.com/xxx/page.xhtml?alias=xsoftware
      for many pages.  I added the
      <param name="alias" required="true"/>
      to many pages and all was working pretty nicely UNTIL I wrote a page that required validation.  When I click the add user button to add the user and VALIDATION fails, the url is rewritten WITHOUT the parameter!!!!


      Everything else is great.  right now, I never add params in my links and everything works fine jumping between pages except this part when validation fails. 


      WORKAROUND???  is there a way to prevent validation and do validation myself so I can redirect to the same page BUT with the alias.  That would be a good work around for the time being...


      I gotta have this alias or my url rewriter breaks and I can't get the urls the way our requirements are set out.
      thanks for any help on this!!!

        • 1. Re: validation erases url params???
          deanhiller2000

          hmmm, go figure, right after that post, I almost stumble on to the answer(or at least I know part of it).  I was using h:commandButton, only the seam components propagate params so you have to use an s:button but once I do that, validation stops occuring for some reason.  Anyone know why validation does not happen for s:button.  I will go see if I can find this in the docs.

          • 2. Re: validation erases url params???
            deanhiller2000

            AHHHHHH...s:link and s:button both say they do NOT submit the form in the documentation...now what do I do...h:commandButton does not propogate params and s:link and s:button don't submit forms.


            I need
            1. to submit the form(ie. h:commandButton)
            2. to propogate the params(ie. s:button)


            How do I get the best of both???
            thanks,
            Dean

            • 3. Re: validation erases url params???

              You need to use an ajax form, so that form submission is performed with ajax, and therefore it doesn't affect your url.

              • 4. Re: validation erases url params???

                Take a look at the RichFaces Developer Guide, specifically to the Ajax Form and Ajax Command Button, the Output panel will be helpful to wrap the messages and show any faces message triggered by validation error

                • 5. Re: validation erases url params???

                  On the other hand, while your submission will not affect you URL, you URL will not affect your validation, if you need the chosen company to do the validation you will have to find a way to have it available during submission (for that, you might need to store it in a conversation, in page, or in session scope)

                  • 6. Re: validation erases url params???
                    deanhiller2000

                    I had to think on this for a while.  AJAX is not what I want as it is more like a wizard type thing and that would just be too complex.  I would rather find a way to do this.


                    I did not get your last comment.  basically as someone hops around though the url always needs the alias=<company> parameter in the url on nearly every page once they are in.  it works except for the post.  I did finally fine this bug but it says it is fixed.


                    My Link


                    I wish I could find an example where they params and a POST with commandLink or commandButton..anyone know of one?

                    • 7. Re: validation erases url params???
                      pmuir

                      h:commandLink propagates parameters, h:commandButton doesn't. No easy way around this.

                      • 8. Re: validation erases url params???
                        deanhiller2000

                        sweeeet, BUT commandLink almost seems to propogate the url param...it seems it propogates it around the code though. 


                        1. The key propogates to the next page now, BUT it doesn't seem to set the @RequestParameter value at all when I click the register commandLink.  The @RequestParameter is set when it first loads the register page AND after I click the register link, the next page has the key in the url.  The key just seems to dissappear between clicking register and the next page(ie. when #{register.register} is invoked, the key is null)....when #{register.loadPage} is invoked, the same key is there and set in the register bean.  Is this a bug or something I am stuck with????  Is there an example in the seam examples with this....I did a search on param and did not find a good example of propogating through a commandLink.


                        2. there is a new problem where the magical enter button doesn't work anymore.  Hitting enter does not click register :(.  Anyway to work around that new issue.