Re: does not execute action listener

Splash Forums PrettyFaces Users does not execute action listener Re: does not execute action listener

#23241

jllado
Participant

My pretty-config.xml looks as follows:

<?xml version="1.0" encoding="UTF-8"?>
<pretty-config xmlns="http://ocpsoft.org/prettyfaces/3.3.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ocpsoft.org/prettyfaces/3.3.3 http://ocpsoft.org/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.3.xsd">

<url-mapping id="home">
<pattern value="/" />
<view-id value="/index.xhtml" />
<action>#{user.notifyUserOfActivation}</action>
</url-mapping>

<url-mapping id="login">
<pattern value="/login" />
<view-id value="/index.xhtml" />
<action>#{user.redirectLoggedInUser}</action>
</url-mapping>

<url-mapping id="logout">
<pattern value="/guest" />
<view-id value="/index.xhtml" />
<action>#{user.logout}</action>
</url-mapping>

<url-mapping id="register">
<pattern value="/register" />
<view-id value="/register.xhtml" />
</url-mapping>

<url-mapping id="myProfile">
<pattern value="/myProfile" />
<view-id value="/user/userProfile.xhtml" />
</url-mapping>

<url-mapping id="forums">
<pattern value="/forums" />
<view-id value="/forums.xhtml" />
</url-mapping>

<rewrite match="/forum.xhtml" substitute="/prettyurl" redirect="301" />

<url-mapping parentId="forums" id="forum" onPostback="false">
<pattern value="/#{forumId}">
<!--<validate index="0" validatorIds="shortConverter" onError="pretty: home" />-->
</pattern>
<view-id value="/forum.xhtml" />
</url-mapping>

<url-mapping id="newTopic" onPostback="false">
<pattern value="/newTopic">
</pattern>
<view-id value="/forums.xhtml" />
</url-mapping>

</pretty-config>

I recollected that also this line causes my page not to be rendered:

<validate index="0" validatorIds="shortConverter" onError="pretty: home" />

I type /forums/2 and instead to receive page that displays topics in forum with id=2 I have pretty: home.

By shortConverter is really simple :

@FacesConverter(value = "shortConverter",forClass=Short.class)
public class ShortConverter implements Converter {

@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
if (value == null) {
return value;
}

Short shortValue;
try {
shortValue = Short.valueOf(value);
} catch (NumberFormatException e) {
System.out.println("ShortConverter.getasobject=" + e);
throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, LocaleBean.getString("age_notvalid"), JavaHelpConstants.HIDE_MESSAGE.toString()));
}

if (value.length() > 2) { //this should not happen
throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, LocaleBean.getString("age_toolong"), JavaHelpConstants.HIDE_MESSAGE.toString()));
}

return shortValue;
}

@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
if (value == null) {
return null;
}

if (value instanceof Short) {
return value.toString();
}
Logger.getLogger("shortconverter").info("GETASSTRING exception in shortconvertern");
throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Internal error! Converted value is not of type Short", JavaHelpConstants.HIDE_MESSAGE.toString()));
}
}

Without this validator everything works as expected.