Re: 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. Re: Path parameters are null in the managed bean when view id is dynamic.

#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;
}