[solved] Problem on actionUrl param from a4j components when using pretty faces

Splash Forums PrettyFaces Users [solved] Problem on actionUrl param from a4j components when using pretty faces

Tagged: , ,

This topic contains 6 replies, has 2 voices, and was last updated by  Ricardo Amaral 11 years, 6 months ago.

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

    Ricardo Amaral

    Hi guys,

    First of all, Lincoln, congratulations for your nice work!

    I’m also having problem with pretty faces + richfaces (a4j). Probably it’s something i’m doing wrong.

    Here is my problem:

    All my app is in AJAX with a4j and jquery, and i’m developing something like an online store.

    Two major problems with an ajax only app is history and access things by URL.

    With pretty faces I think I can fix both. But i’m not getting the right config yet.

    I managed to access products by URL configuring to something like this w/ pretty faces: http://localhost:8080/myappname/search/coke, and everything works great, and the page with products is returned.

    The page returned have a4j components like commandLinks, commandButtons and a form.

    Looking to the rendered html code I could see the commandLink is becoming the following:

    <a href="#" id="generalForm:j_id23:0:j_id28:7:category" name="generalForm:j_id23:0:j_id28:7:category" onclick="A4J.AJAX.Submit('generalForm',event,{'similarityGroupingId':'generalForm:j_id23:0:j_id28:7:category','parameters':{'generalForm:j_id23:0:j_id28:7:category':'generalForm:j_id23:0:j_id28:7:category'} ,'actionUrl':'/myappname/search/coke;jsessionid=A7E70CC70CB271F353B04E5A867F3F07'} );return false;">Link Label</a>

    Pay attention to the param ‘actionUrl’, it is being rendered with the actual URL /myappname/search/coke, and every time I click the link, the same backing bean method is being called, but another method in the same backing bean should be called. This is going on because the pretty faces mapping is working! :)

    Debugging the a4j javascript code, I could see this actionUrl param is used to mount the XmlHttpRequest object destination.

    The question is obvious, how to make it work? :)

    My env: tomcat 6.0.24 + JSF 1.2 (myfaces implementation 1.2.8) + richfaces 3.3.2 + servlet 2.5 + JSP 2.1 + facelets 1.1.15

    Thanks in advance!


    Hi there :) Thank you, I’m glad that you like the project. Hopefully I can help you out.

    I’m not sure exactly what problem you’re experiencing, though, what’s not working?

    * What do you expect to happen?

    * What is happening?




    Ricardo Amaral

    Hi Lincoln,

    After the page with the URL mapped by pretty faces (e.g.: /myapp/search/coke ) is loaded, when I click on a link (a4j:commandLink) I’m expecting the right method of backing bean be called. What is happening is the same method executed by the URL /myapp/search/coke is being called when I click the link, because the “actionURL” param of the html anchor tag rendered for the component a4j:commandLink is inheriting the same URL “/myapp/search/coke”.

    This is happening because when I click a link (a4j:commandLink), the pretty faces filter is receiving the same URL “/myapp/search/coke” and dispatching to direction specified by pretty-faces.xml.

    I don’t know if I was a little more clear now! :)

    Maybe the solution is so simple that I can’t see!



    Could you paste in your mapping configuration please?


    Ricardo Amaral

    Follows my mapping:

    <!– Begin RewriteRules –>

    <rewrite match=”/(buscar|comparar)/(w+)/(w+)” substitute=”/$2/$3″ redirect=”chain” />

    <rewrite match=”/(buscar|comparar)/([w]+.pchxa)” substitute=”/$2″ redirect=”chain” />

    <!– Begin UrlMappings –>

    <url-mapping id=”index”>

    <pattern value=”/” />



    <url-mapping id=”quemsomos”>

    <pattern value=”/quemsomos” />



    <url-mapping id=”clientes”>

    <pattern value=”/clientes” />



    <url-mapping id=”anuncie”>

    <pattern value=”/anuncie” />



    <url-mapping id=”ajuda”>

    <pattern value=”/ajuda” />



    <url-mapping id=”contato”>

    <pattern value=”/contato” />



    <url-mapping id=”cadastrese”>

    <pattern value=”/cadastrese” />



    <url-mapping id=”convite”>

    <pattern value=”/convite” />



    <url-mapping id=”buscaProduto”>

    <pattern value=”/buscar/#{buscaMB.bean.nm_produto}” />




    <url-mapping id=”buscaCategoria”>

    <pattern value=”/buscar/categoria/#{buscaMB.id_categoria}” />




    <url-mapping id=”comparar”>

    <pattern value=”/comparar/#{comparacaoMB.bean.cd_code_bar}” />




    <url-mapping id=”termo”>

    <pattern value=”/termo” />



    <url-mapping id=”politica”>

    <pattern value=”/politica” />




    Ok, on the <action> you don’t wish to execute when the AJAX event occurs, try this:

    <action onPostback="false">...</action>

    But be careful, because this means the action will NOT be called on POST-backs or any form submits, so you need to make sure that any data required is not going to be destroyed on future requests (eg, make sure the bean will retain whatever state it needs to fulfil future requests.)


    Ricardo Amaral

    Ok! I’ll try this tip!


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

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

Comments are closed.