Path parameters are null in the managed bean when view id is dynamic.

Splash Forums PrettyFaces Users Path parameters are null in the managed bean when view id is dynamic.

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

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #18375

    Vijay1028
    Participant

    In a web application I am using Prettyfaces version 3.1.0, Weblogic server 11g and Jsf 2.0

    I have the following code in : pretty-config.xml

    <url-mapping id="property1">
    <pattern value="hotels/#{propertyName1 : searchCriteria.propertyName1}/hotel-overview"/>
    <query-param name="hotel_id">#{searchCriteria.hotelId}</query-param>
    <query-param name="checkin_date" validatorIds="checkInCustomValidation checkInOutCustomValidation" onError="pretty:home">#{searchCriteria.strcheckInDate}</query-param>
    <query-param name="checkout_date" validatorIds="checkOutCustomValidation checkInOutCustomValidation" onError="pretty:home">#{searchCriteria.strcheckOutDate}</query-param>
    <view-id>/xhtml/property/overview/propertyDetails_WY.xhtml</view-id>
    <action onPostback="false">#{propertyBean.propertyDetails}</action>
    </url-mapping>

    In this case the path parameter (i.e propertyName1) are coming as null in the managed bean: The code is as follows:

    FacesContext facesContext = FacesContext.getCurrentInstance();
    if (facesContext != null) {
    reqParamMap = facesContext.getExternalContext().getRequestParameterMap();
    System.out.println("Request Parameter Map : "+reqParamMap);
    propName = reqParamMap.get("propertyName1");
    }

    However the the same parameter is not null and I am getting the value as entered in the url when the view id is not dynamic i.e if the view id is as follows :

    <view-id>/xhtml/property/overview/propertyDetails_WY.xhtml</view-id>

    I do not have any clue about this! I need to get the path parameters for dynamic view id.

    Thanking you in anticipation of your quick response

    #22557

    You are using a very old version of PrettyFaces. There have been some bugfixes reading dynaview in the last versions. Could you please update to 3.3.3 and check if this solves your problem.

    #22558

    Shoab
    Participant

    The Latest version 3.3.3 doesn’t solve the problem. Infact i have tried to capture the path parameters from PrettyContext and that has solved the problem.

    See if it helps.

    /***
    * This method returns the value of path parameter values form pretty context
    * @param prettyContext
    * @param searchTerm
    * @return
    */
    public static String findPathParameterValue(PrettyContext prettyContext, String pathParam){

    Map<String, String> parameterMap = new HashMap<String, String>();
    String paramValue = "";
    String keyUrl = prettyContext.getCurrentMapping().getPattern();
    String valueUrl = prettyContext.getRequestURL().toString();
    String [] keyArray = keyUrl.split("/");
    String [] valueArray = valueUrl.split("/");

    for(int index = 0; index < keyArray.length; index++){
    parameterMap.put(keyArray[index], valueArray[index]);
    }

    for (Map.Entry<String, String> entry : parameterMap.entrySet()){
    if(entry.getKey().contains(pathParam)){
    paramValue = entry.getValue();
    break;
    }
    }

    return paramValue;
    }

    #22559

    Hmmm. I think the problem in your case is that the forwarded request (which is determined using dynaview) is treated as a completely new request which isn’t related to the original one any more. Therefore path parameters only work in the forwarded URL.

    I think you will really need some custom code here. :(

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

You must be logged in to reply to this topic.

Comments are closed.