[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 7 years, 2 months ago.

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

    Ricardo Amaral
    Participant

    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!

    #20030

    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?

    Thanks!

    –Lincoln

    #20031

    Ricardo Amaral
    Participant

    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!

    Thanks!

    #20032

    Could you paste in your mapping configuration please?

    #20033

    Ricardo Amaral
    Participant

    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=”/” />

    <view-id>/index.pchxa</view-id>

    </url-mapping>

    <url-mapping id=”quemsomos”>

    <pattern value=”/quemsomos” />

    <view-id>/quemsomos_wrapper.pchxa</view-id>

    </url-mapping>

    <url-mapping id=”clientes”>

    <pattern value=”/clientes” />

    <view-id>/clientes_wrapper.pchxa</view-id>

    </url-mapping>

    <url-mapping id=”anuncie”>

    <pattern value=”/anuncie” />

    <view-id>/anuncie_wrapper.pchxa</view-id>

    </url-mapping>

    <url-mapping id=”ajuda”>

    <pattern value=”/ajuda” />

    <view-id>/ajuda_wrapper.pchxa</view-id>

    </url-mapping>

    <url-mapping id=”contato”>

    <pattern value=”/contato” />

    <view-id>/contato_wrapper.pchxa</view-id>

    </url-mapping>

    <url-mapping id=”cadastrese”>

    <pattern value=”/cadastrese” />

    <view-id>/cadastrese_wrapper.pchxa</view-id>

    </url-mapping>

    <url-mapping id=”convite”>

    <pattern value=”/convite” />

    <view-id>/convite_wrapper.pchxa</view-id>

    </url-mapping>

    <url-mapping id=”buscaProduto”>

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

    <view-id>/busca_wrapper.pchxa?directaccess=true</view-id>

    <action>#{buscaMB.buscarProdutos}</action>

    </url-mapping>

    <url-mapping id=”buscaCategoria”>

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

    <view-id>/busca_wrapper.pchxa?directaccess=true</view-id>

    <action>#{buscaMB.buscarProdutosPorCategoria}</action>

    </url-mapping>

    <url-mapping id=”comparar”>

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

    <view-id>/comparacao_wrapper.pchxa?directaccess=true</view-id>

    <action>#{comparacaoMB.compararProduto}</action>

    </url-mapping>

    <url-mapping id=”termo”>

    <pattern value=”/termo” />

    <view-id>/termo_wrapper.pchxa</view-id>

    </url-mapping>

    <url-mapping id=”politica”>

    <pattern value=”/politica” />

    <view-id>/politica_wrapper.pchxa</view-id>

    </url-mapping>

    #20034

    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.)

    #20035

    Ricardo Amaral
    Participant

    Ok! I’ll try this tip!

    Thanks

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

You must be logged in to reply to this topic.

Comments are closed.