beginner question regarding "com.ocpsoft.vP_0"

Splash Forums PrettyFaces Users beginner question regarding "com.ocpsoft.vP_0"

This topic contains 15 replies, has 3 voices, and was last updated by  Christian Kaltepoth 5 years, 3 months ago.

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #18474

    Glister
    Participant

    Hey,

    at first i have to say, awesome great wonderful project !

    i spend only 10 minutes to implement first mappings and i’m fascinated how wonderful and clean it works. okay came across a little problem. So, ….

    following configuration:

    1. Glassfish 3.1.2, Mojarra 2.1.6, PrettyFaces 3.3.3, PrimeFaces 3.3.1, CDI Weld 1.4, CODI 1.0.5, PrimeFaces Extension 0.5.0, Omnifaces 1.0 (only for AjaxExceptionHandler)

    2. web.xml doesn’t contains any prettyfaces stuff

    3. pretty-config.xml is empty (Annotation-based )

    @Named
    @RequestScoped
    @URLMapping(id="viewItem", pattern="/technique/show/#{showItem.tId}", viewId="/tool/technique/show.xhtml")
    public class ShowTechniqueItem implements Serializable{

    4. URL shouldn’t contain “&com.ocpsoft.vP_0=” stuff

    5. URL is : technique/show/28?windowId=542&com.ocpsoft.vP_0=28

    my first question is:

    for what do prettyfaces need the com.ocpsoft.vP_0 parameter ?

    second little bit non-prettyfaces related question:

    I use a CDI Weld RequestScoped Bean, so why does url appends this windowId if i open my bookmarked URL directly ? :/

    Thanks and regards,

    Glister

    #22696

    Hi,

    nice to hear that you like PrettyFaces. :)

    Actually I’m very surprised that this query parameter is added to your URLs. AFAIK this parameter is only used internally and should never show up in an URL like this.

    Could you perhaps create a minimal example project that reproduces this. My guess is that it is somehow related to the combination of libraries you are using.

    Regarding the windowsId parameter. This one is created by MyFaces CODI for supporting the “window scope”. As far as I know you can globally disable this parameter by setting some CODI configuration parameter. But in this case you won’t be able to use this scope.

    Christian

    #22697

    For disabling the windowId I think you have to return false for isUrlParameterSupported in WindowContextConfig:

    https://cwiki.apache.org/confluence/display/EXTCDI/JSF+Config+and+SPI

    #22698

    Glister
    Participant

    Hi Christian,

    thanks for your quick response. Hm, minimal example is difficult, because it’s a more or less big jee-application. I started to migrate some parts to prettyfaces (SEO links ;) etc). So i would need a good amount of time to generate a mini-project.

    To globally disable windowId isn’t a option for me, because 80% of the project is ViewAccessScoped and clientsidehandler is not intended. Only the curious ocpsoft.vP_0 attribute is a little bit annoying.

    But okay, at the moment i can live with that. :)

    I started to remove some third party libraries like omnifaces or primefaces-extensions. No success :(.

    Did disabled all my filters (CharacterEncoding etc). No success!

    Disable JAAS shouldn’t be the problem, or ?

    If i remove the appended attribute it works like a charm.

    Thanks, thanks for your help.

    #22699

    Yes, this attribute should never be rendered in the URL. I’m very surprised to see this happening. A small app to reproduce this would really help us!

    Thanks :)

    ~Lincoln

    #22700

    Glister
    Participant

    Hey guys,

    okay after several tests, i removed CODI at least. And, voilá no , “com.ocpsoft.vP_0” -> pretty url. Before this, i removed the EL-Bean variable from pretty-config.

    Before:

    <pattern value=”/tool/technique/show/#{ bean.id }” />

    To:

    <pattern value=”/tool/technique/show/#{ id }” />

    which results into an URL like: http://server.de/tool/technique/show/27?windowId=32c&id=27

    Finally, removing CODI isn’t a option for me but anywhat from CODI causes to produce this url like above.

    In the copy() method at PathParameter you set the PathParameter Name with this lines:

    PathParameter result = new PathParameter();
    if (isNamed())
    {
    result.setName(getName());
    }
    result.setName(getName());

    @Override
    public String getName()
    {
    if (!isNamed())
    {
    return PATH_PARAM_NAME_PREFIX + getPosition();
    }
    return super.getName();
    }

    didn’t understand this condition. could you explain it to me.

    Are there any known issues with PrettyFaces and CODI ??

    Regards, glister.

    #22701

    Hey all,

    I just tried to reproduce this issue but everything works fine for me. My setup was: Tomcat 7.0.22, MyFaces 2.1.8, Weld 1.1.8.Final and CODI 1.0.5.

    Christian

    #22702

    Glister
    Participant

    damn, did you used ViewAccessScoped beans? Under which condition will prettyfaces add those parameter? The method isNamed() suggest to me that if the path param or request param is not set or named, prettyfaces will add these as an queryparam? Is my conclusion correct ?

    Thanks for testing it.

    Regards, glister

    #22703

    No, I used plain @RequestScoped beans.

    Actually PrettyFaces converts EVERY path parameter into a query parameter. Named path parameters look like this:

    <pattern value="/tool/technique/show/#{ id }" />

    or

    <pattern value="/tool/technique/show/#{ id : bean.id }" />

    In both cases the path parameter will be converted into a query parameter with thane name id.

    If you don’t set a name for the path parameter, PrettyFaces will create an internal dummy name for the query parameter (in your example com.ocpsoft.vP_0). Example for an mapping without a name for the path parameter:

    <pattern value="/tool/technique/show/#{ bean.id }" />

    The really weird thing here is that these query parameter should NEVER show up in outbound URLs (i.e. URLs that are rendered to the page or that you are redirected to).

    It is really a very strange issue because you are the first one reporting such a problem. I’m also not completely sure if it is PrettyFaces that adds the query parameters to the URL. Maybe CODI does something here?

    #22704

    Could you perhaps try to disable isAddWindowIdToActionUrlsEnabled in WindowContextConfig. And if this doesn’t work, try disabling isUrlParameterSupported.

    I think maybe CODI’s way of adding the windows id to the outgoing URL may cause this.

    #22705

    Glister
    Participant

    Hey Christian,

    i set isAddWindowIdToActionUrlsEnabled to false :

    config implementation: org.apache.myfaces.extensions.cdi.core.api.scope.conversation.config.WindowContextConfig
    method: isUrlParameterSupported
    value: true
    method: isUnknownWindowIdsAllowed
    value: false
    method: isAddWindowIdToActionUrlsEnabled
    value: false
    ...

    no success, id gets appended…. :(

    after disabling ParameterSupport, everything works as excepted. :) but without windowId.

    in the meantime i created a small CODI-PrimeFaces-PrettyFaces-OmniFaces project. everything works like a charm. :(((((

    maybe there are some conflicts with faces-config and pretty-config. (but defined prettyfilter at first)

    i can’t debug the project correctly because the sources of prettyfaces didn’t get recognized by Netbeans. i downloaded the src files from maven but if i open a class file, netbeans shows compiled src.

    could it help to implement a phaselistener for debugging ???

    regards, glister

    #22706

    Hmmm. So you say that this bug only occurs if WindowContextConfig.isUrlParameterSupported() == true? If you set it to false everything works like expected?

    In this case it really seems to have something to do with CODI. It would be interesting to know what else CODI does when isUrlParameterSupported is true.

    #22707

    Glister
    Participant

    Hey Christian,

    okay i think CODI is the evil. while debugging CODI i stepped into

    DefaultWindowHandler.java

    there is a code piece:

    if(addRequestParameter)
    {
    url = JsfUtils.addParameters(externalContext, url, true, true, true);
    }
    else
    {
    url = JsfUtils.addParameters(externalContext, url, false, true, true);
    }

    addRequestParameter is true ! before the condition url is without the prettyfaces id.

    after

    JsfUtils.addParameters(externalContext, url, true, true, true);

    i got my prettyfaces-id url.

    okay stepped into the addParameters method

    for(RequestParameter requestParam :
    getParameters(externalContext, true, addRequestParameter, addPageParameter))
    {
    String key = requestParam.getKey();
    ... append append .... to url

    okay and now,

    key = "bId";

    okay the root of evil is here in WindowContextManagerObserver.java

    // add requst-parameters e.g. for f:viewParam handling
    windowHandler.sendRedirect(FacesContext.getCurrentInstance().getExternalContext(), targetURL, true);

    because the third parameter is true, the addParameter variable is true, too so … nasty url gets appended. :(

    #22708

    Glister
    Participant

    // UPDATE///

    Wuuuh, scary scary scary things happens here:

    in my parallel demo test project following happens:

    pretty-config.xml

    <url-mapping id="printName">
    <pattern value="/page1/name/#{ name: pageController.name }" />
    <view-id value="/ugly/uglier/page1.xhtml" />
    <action>#{pageController.loadName}</action>
    </url-mapping>

    <url-mapping id="page1">
    <pattern value="/page1/" />
    <view-id value="/ugly/uglier/page1.xhtml" />
    </url-mapping>

    <url-mapping id="page2">
    <pattern value="/page2/" />
    <view-id value="/really/really/ugly/page2.xhtml" />
    </url-mapping>

    and my RequestScoped Bean:

    private String name;

    public String getName() {
    return name;
    }

    public void setName(String name) {
    this.name = name;
    }

    public void loadName(){
    // do some db select stuff
    if(name != null && !name.isEmpty()){
    name = name.concat(" 123 ");
    }
    }

    so if i open the following url:

    url/page1/name/freddy

    the url gets modified to:

    /prettyfaces-codi-test/page1/name/fred 123 ?windowId=642&name=fred

    and output in xhtml is:

    freddy 123 123

    wtf …..

    regards, glister

    regards, glister

    #22709

    Glister
    Participant

    okay i think i recognized the issue:

    if i start the demo app at:

    server:8080/prettyfacescoditest/

    jsp is shown, no windowId is generated

    okay case 1:

    visit now

    server:8080/prettyfacescoditest/page1/name/freddy

    url gets modified to:

    server:8080/prettyfacescoditest/page1/name/freddy 123 ?windowId=948&name=freddy

    at this point i have a valid windowId so

    case2:

    server:8080/prettyfacescoditest/page1/name/fred?windowId=948

    returns

    server:8080/prettyfaces-codi-test/page1/name/fred?windowId=948

    works as excepted.

Viewing 15 posts - 1 through 15 (of 16 total)

You must be logged in to reply to this topic.

Comments are closed.