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…

#22103

Tony Herstell
Participant

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")
...
@SuppressWarnings("unused")
@URLQueryParameter("cid")
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);
facesContext.renderResponse();
...

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>
</url-mapping>

And the page:

<h:form>

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

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

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

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

</h:form>

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.