wrong post url

Splash Forums Rewrite Users wrong post url

This topic contains 13 replies, has 3 voices, and was last updated by  lyahim 8 years, 3 months ago.

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
  • #25013


    Hi All!

    Unfortunatelly I don’t have more idea, must write the problem what I found.
    I use now prettyfaces but I checked the Rewrite too.
    I have a simple web project and I want to make a contact form with url what contains parameter. When I try to submit the form, it try to process with the view-id and redirect to there too.
    For example: http://wiki:8080/hu/contact->http://wiki:8080/res/pages/contact.xhtml
    At the background I got a null source exception:

    (http-localhost- null source: javax.servlet.ServletException: null source
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:606) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

    My pattern is: /#{lang}/contact
    And view-id is: /res/pages/contact.xhtml
    I used the annotation way, the full annotation is:
    @URLMapping(id = “contact”, pattern = “/#{lang}/contact”, viewId = “/res/pages/contact.xhtml”)
    @Join(path = “/{lang}/contact”, to = “/res/pages/contact.xhtml”)

    I use JBoss AS 7.1

    When don’t use parameter in url(/contact), it works right.

    I tried to read about it on many forums, but i found nothing.

    Thanks for helping.



    So you say that the FaceServlet throws this exception only if you have a path parameter in your pattern, right?

    Could you please post the full stacktrace?

    Also, could you try to use 2.0.5.Final instead of 2.0.7.Final. There was a report regarding problems with parameters in another forums post after updating from 2.0.5.Final to 2.0.7.Final.



    Dear Christian!

    Sorry fot late reply. I try to check what is the exactly failure and I found it.
    The null source exception is forgottable, because it caused by a null object in my ViewHandler and the stacktrace was wrong.
    My other problem is the post url.
    I use the 2.0.5.Final library. And make a small project for present the situation.
    I attach the project, what you can access in “baseURL/en/test” url for example.
    But after click any submit button, will be send to “baseURL/res/pages/test.xhtml”.

    Thank you,



    thanks. A small project that reproduces an error is always handy. I’ll have a look at it as soon as possible.

    I just had a quick look at the RAR file and found something that you could try. Could you also add the rewrite-integration-faces module to your project and try again. There have been reports that adding this module leads to weird ClassNotFoundExceptions. If this happens, you could (for a temporary test) add the module directly to the Glassfish lib directory and check if this works.




    Hello Christian!

    I copy the rewrite-integration-faces module into the project, but has no effect. I solved the nullpointer exception, but the form action url even bad. Could you check the attachment?



    Hi. We recently fixed a few bugs in 2.0.8.Final that may cause this issue. Could you try upgrading and let us know if that solves your issue? Thanks!



    Hello Lincoln!

    I try the latest release, but the wrong behavior stay. And after I created a ConfigurationProvider and there defined a similar rule
    but the behaviour didn’t changed.


    • This reply was modified 8 years, 3 months ago by  lyahim.

    Could you perhaps upload a sample application that reproduces this? I think we need to look at the code to see what is wrong here.




    Hello Lincoln!

    I attach a simple project, what contains the required codes for test the situation.
    I read more and more your documents and don’t understand why not work for my this function because that is well documented. Therefore maybe more important I use Jboss AS 7.1 server.

    When you get the ‘base_url/’ or ‘base_url/correct’ link you can start the test.



    I just had a look at your project. There are two issues.

    First, if you have a join with a parameter, you have to specify the value of that parameter if you want to use h:link to navigate to this page.

    <h:link value="click me" outcome="/res/pages/invalid.xhtml">
      <f:param name="param" value="foobar"/>

    Second, you have to add rewrite-integration-faces-2.0.8.jar to your WEB-INF/lib. After doing this, the form postback URLs will be rewritten and you won’t be sent to the plain JSF URL any more when clicking one of the buttons.

    I hope this helps. 🙂



    Hello All!

    Thank you for kind help! Christian the last post was very helpful. I try many cases because the simple app worked, but the original project didn’t. Therefore I dig a bit in my code and i found the bug.
    When I use a ViewHandler the form action use viewId instead of pattern.

    I attach the updated project.



    I wasn’t able to run your sample app due to missing dependencies, but I think I can tell you what is going wrong.

    Actually your custom view handler is incorrect. It looks like you are trying to extends the existing default view handler of Mojarra by creating a subclass. If you do it this way, the RewriteViewHander will be completely ignored which is why you are getting problems.

    As there may be multiple view handlers in a single application, you have to use some kind of wrapper pattern instead. Something like this:

    public class ReverseProxyViewHandler extends ViewHandler {
    	private ViewHandler parent;
    	public ReverseProxyViewHandler(ViewHandler parent) {
    	    this.parent = parent;
    	public Locale calculateLocale(FacesContext context) {
    	    return parent.calculateLocale(context);
    	public String calculateRenderKitId(FacesContext context) {
    	    return parent.calculateRenderKitId(context);
            /* more */

    This way you will get a “chain” of view handlers. So if you want to do some custom stuff, you will typically add some code to one of the methods, but keep calling the parent view handler to do the real stuff.

    Here is another example of how to create a custom view handler that delegates calls to the parent (default) view handler.



    Or simply extend this class which does most of the delegation work for you:




    Thank you very much Christian, I have no more question 🙂

    Best Regards,

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

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

Comments are closed.