Re: How to dynamically inject parameters without having to inject target backingbean

Splash Forums PrettyFaces Users How to dynamically inject parameters without having to inject target backingbean Re: How to dynamically inject parameters without having to inject target backingbean

#22806

nena_99
Participant

Actually – Lincoln, I have come to the conclusion that returning a url with the parameters at the end isn’t very nice – it doesn’t keep the nice “clean” & bookmarkable URLS. So I have decided to do something like the following in the action handler:

protected String navigate(String mappingId, Object… params) {

HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();

PrettyContext context = PrettyContext.getCurrentInstance(request);

PrettyURLBuilder builder = new PrettyURLBuilder();

UrlMapping mapping = context.getConfig().getMappingById(mappingId);

String targetURL = builder.build(mapping, true, getId());

HttpServletResponse response = (HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();

try {

response.sendRedirect(request.getContextPath() + targetURL);

} catch (IOException ioe) {

logger.error(ioe.getMessage());

}

return null;

}

But – I was wondering, is there a PrettyRedirector for doing this? Could you possibly point me to an example? Thanks in advance!