Split: PrettyFaces + Anchor with JavaScript window.location redirect?

Splash Forums PrettyFaces Users Split: PrettyFaces + Anchor with JavaScript window.location redirect?

This topic contains 6 replies, has 3 voices, and was last updated by  ravindra 2 years, 8 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #25515

    ravindra
    Participant

    Hi sir,

    Am new to pretty faces, i incorporated pretty faces successfully in my project. in my project am using JSF,Prime Faces,Spring and Spring security.

    problem:

    am buliding url using javascript

    ex: window.location.assign(“http://localhost:8080/Project/pages/viewDetails.xhtml”);

    am configure pretty faces like this

    <url-mapping >
    <pattern value=”/view/details” />
    <view-id value=”/pages/viewDetails.xhtml” />
    </url-mapping>

    but am getting in browser like this http://localhost:8080/Project/pages/viewDetails.xhtml

    but actually i need like http://localhost:8080/Project/view/details

    Please help me on this it will great-ful to me .

    Thanks & Regards
    Ravindra.

    #25519

    Hey,

    if you build the raw JSF URL using JavaScript and tell the browser to load this page, the browser will of cause request and show this URL and not the pretty one. There is no way for PrettyFaces to intercept this. If you created the JavaScript, you will adjust your code to create the pretty URL instead of the JSF one.

    Christian

    #25546

    ravindra
    Participant

    Hi ,

    Thanks a lot for giving replay. it was great help to me.

    One more issues

    am buliding url using javascript

    ex: window.location.assign(“http://localhost:8080/Project/pages/viewDetails.xhtml?name=ravindra & company=’xyz’ “) ;

    am configure pretty faces like this

    <url-mapping >
    <pattern value=”/details/#{name}/#{company}” />
    <view-id value=”/pages/viewDetails.xhtml” />
    </url-mapping>

    but am getting in browser like this http://localhost:8080/Project/pages/viewDetails.xhtml?name=ravindra &company=xyz

    but actually i need like http://localhost:8080/Project/details/ravindra/xyz

    Please help me on this it will great-ful to me .

    Regards
    Ravindra

    • This reply was modified 2 years, 8 months ago by  ravindra.
    #25551

    If you are building the URL in JavaScript, then just build it the right way in JavaScript:

    window.location.assign(“http://localhost:8080/Project/details/ravindra/xyz“);

    #25554

    ravindra
    Participant

    Hi Sir,

    Thanks great help from your side

    One More Issue

    I configure rewrite things successfully ,i added one rule in ConfigurationProvider class

    import javax.servlet.ServletContext;
    import org.ocpsoft.rewrite.annotation.RewriteConfiguration;
    import org.ocpsoft.rewrite.config.ConfigurationBuilder;
    import org.ocpsoft.rewrite.servlet.config.HttpConfigurationProvider;
    import org.ocpsoft.rewrite.servlet.config.rule.Join;

    @RewriteConfiguration
    public class PrettyConfigurationProvider extends HttpConfigurationProvider {

    @Override
    public org.ocpsoft.rewrite.config.Configuration getConfiguration(ServletContext t) {
    return ConfigurationBuilder.begin()
    .addRule(Join.path(“/p/viewDetails”).to(“/pages/ViewDetaails.xhtml”).withInboundCorrection());
    }

    @Override
    public int priority() {
    return 10;
    }
    }

    and registered com.ocpsoft.pretty.faces.spi.ConfigurationProvider in META-INF

    when am navigating to viewDetails console returning following error

    javax.servlet.ServletException: Error during Rewrite processing. Please inspect stack trace for root cause.

    How can i resolve this ?

    Thanks & Regards
    Ravindra

    • This reply was modified 2 years, 8 months ago by  ravindra.
    #25558

    You need to look at the stack trace and see what the root cause is. If you paste the full stack trace, we might be able to help. Also, you don’t need to use both @RewriteConfiguration and the META-INF/services registration file – One or the other will do.

    #25571

    ravindra
    Participant

    Hi sir,

    Thanks for your support

    Thanks & Regards
    Ravindra

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

You must be logged in to reply to this topic.

Comments are closed.