Re: PrettyFaces, CDI and the case of the missing ?cid=xxx…

Splash Forums PrettyFaces Users PrettyFaces, CDI and the case of the missing ?cid=xxx… Re: PrettyFaces, CDI and the case of the missing ?cid=xxx…


Tony Herstell

I have managed to move over to annotations:

// Tell prettyfaces to use this bean when the pattern matches and show the manageUsers page. Also support a Query Param (cid).
@URLMapping(id = "manageUsers", pattern = "/users/manage", viewId = "/pages/users/manageUsers.xhtml")
private String cid;

I have also had to push out exceptions so that I can put them on another page:

public class MyExceptionHandler extends ExceptionHandlerWrapper {
private static final String ERROR_NAV = "pretty:error";
String navigationToReturn = ERROR_NAV;
Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
requestMap.put("exception", messageToReturn);
nav.handleNavigation(facesContext, null, navigationToReturn);

To see them on the exception page:

<url-mapping id="error">
<pattern value="/error"></pattern>
<view-id value="/pages/error/generalError.xhtml"/>
<query-param name="exception">#{exception}</query-param>

And the page:


<h1>Sorry; An error happened.</h1>

<div class="error">
<h:outputText escape="false" value="#{exception}" />

<h1>This has been logged and will be looked into.</h1>

<p:commandButton action="#{exceptionController.finished}" value="#{messages.button_home}" immediate="true"/>


Sadly I have not managed to figure out the annotations to put in exceptionController bean; but this may because I may be short-cutting the life-cycle.