does not execute action listener

Splash Forums PrettyFaces Users does not execute action listener

This topic contains 22 replies, has 4 voices, and was last updated by  Christian Kaltepoth 8 years, 11 months ago.

Viewing 15 posts - 1 through 15 (of 23 total)
  • Author
  • #19110


    I have started with prettyfaces yesterday.

    And today I have very stupid problems.

    I have big register form and this button at the bottom

    <h:commandButton id="registerButton" class="registerButton" value="Register" type="submit" action="#{registerBacking.create}" />

    Everything was working very well before. But yesterday I embedded pretty-confg.xml and it stopped working

    registerBacking.create is not called at all !!!. This method should persist new user and navigate him to secured

    page causing FORM based authentication to redirect him to login.xhtml. There can’t be validation or conversion error.

    Method registerBacking.create is not called because the first line is print statement which never appears in server.log

    The second problem is that when unauthrised user accesses any secured page user is not redirected

    to login.xhtml by container security mechanism but is sent directly to that secured page.

    ALL this was working very well before I embedded prettyfaces.

    Please tell me what to do?


    Hi. Could you please tell us which version of PrettyFaces you are using and post you pretty-config.xml and web.xml. Thanks. :)




    Thank you for reply!

    In pom.xml I have:


    I have resolved security issues by specifying url-pattern in security-constraint to be the same as ‘pattern’ processed by


    BUT I still I have problems with invoking action method by this button

    <h:commandButton id="registerButton" class="registerButton" value="Register" type="submit" action="#{registerBacking.create}" />

    Method create is not called at all! Instead the page is simply reloading which is proved by print statement in constructor

    of view scoped backing bean. Even if I deliberetely leave validation errors nothing changes. The page is simply reloaded

    after that button is clicked.

    Why is that I don’t know because it worked very well before!



    My pretty-config.xml looks as follows:

    <?xml version="1.0" encoding="UTF-8"?>
    <pretty-config xmlns=""

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

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

    <url-mapping id="logout">
    <pattern value="/guest" />
    <view-id value="/index.xhtml" />

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

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

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

    <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" />-->
    <view-id value="/forum.xhtml" />

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


    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 {

    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;

    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.


    If you debug the validator, what is causing it to fail validation?



    About shortConverter

    [#|2012-12-06T21:30:58.359+0200|SEVERE|glassfish3.1.2|javax.enterprise.resource.webcontainer.jsf.application|_ThreadID=117;_ThreadName=Thread-9;|JSF1005: Cannot instantiate validator of type shortConverter|#]

    BUT now my main problem is this:

    I still I have problems with invoking action method by this button

    <h:commandButton id=”registerButton” class=”registerButton” value=”Register” type=”submit” action=”#{registerBacking.create}” />

    Method create is not called at all! Instead the page is simply reloading which is proved by print statement in constructor

    of view scoped backing bean. Even if I deliberetely leave validation errors nothing changes. The page is simply reloaded

    after that button is clicked.

    Why is that I don’t know because it worked very well before!



    I have made sure that action method is not invoked solely because of this mapping in pretty-config.xml

    <url-mapping id=”register” onPostback=”false”>

    <pattern value=”/register” />

    <view-id value=”/register.xhtml” />


    After I commented out this mapping my register form is submitting data as expected. The problem is just in this mapping.

    What can I do here?


    I don’t see any reason why postbacks shouldn’t work any more when using a pretty URL. I never had this kind of problem.

    The typical root cause for action methods not being invoked any more is that some parent component of the button is rendered="false" when the postback is processed. Mostly this happens because request scoped beans lost their values. But you wrote that you are using view scope, right? You could (just for a test) set the scopes of all beans used by the page to session and try it again. If it works with this change, it is usually a scoping issue.

    A strategy that I sometimes use to debug theses problems is to add a special PhaseListener implementation to my application that logs the start and end of each JSF phase. By looking at the logs one can then easily see, if the request processes the INVOKE_APPLICATION phase at all. If not, it is usually some kind of problem in the validation phase.

    I hope this helps a bit.

    Perhaps it is possible for you to trim down you app or create a minimal application that reproduces this issue? In this case I could have a look at your code.




    I set up phase listener which is simplest. It is registered in faces-config.xml and the path is correct !!!

    This listener is not invoked on any phase. Logger does not log anything.

    How can it be?

    Next, WITHOUT that register mapping in pretty-config.xml action method is invoked and I am redirected to correct page and data is persisted( it is exactly) regardless of browser notification.

    BUT there is one thing to note. After I click that register button I have (but not always) notification from browser:

    httpError: Http Transport returns a 0 transport code. This is usually the result of mixing ajax and full requests. This is usually undesired both for performance and data integrity reasons!

    As I understand some error occurred. I don’t know what else to check but this error still occurs.

    I set up try catch where something bad can happen. Nothing is logged about any error!

    How can I catch the error because of which that notification appeares?

    Please, help poor beginner!


    There is something weird going on in your app.

    Are you using the correct logger in your phase listener? It’s really very strange, that your phase listener isn’t working at all. You could test it by replacing your log statements with something like System.out.println().

    Regarding the error you are getting. I never saw this message before. You should try to find out what this message really means. There seem to be many posts on the net regarding this, like:



    PrettyFaces is good and good!

    That notification from browser was because my whole form is cramped up with ajax calls.

    But submit button sends the full form through full request not partial( <f:ajax>).

    This caused two rquests to be mixed. I found solution at

    After I changed my command button to

    <h:commandButton id=”registerButton” class=”registerButton” value=”Register” type=”submit” action=”#{registerBacking.create}”>

    <f:ajax render=”@form” />


    everything is working well. New user is persisted and I am redirected finally to needed page after register form.

    When I commented away my register mapping in pretty-config.xml I still had that notification but application was working

    well !!!

    Why did phase listener log nothing I don’t want to say!

    Can I ask you one more question?

    How to allow mapping in pretty-config.xml to be used only within my site but not from path typed in browser

    If user clicks link on my site this mapping is called, but this mapping is not called if user types path that matches pattern of the same mapping !!!

    Thank you!


    Nice to hear you fixed you first problem.

    But I’m not sure I understand your second question correctly. Do you want that a certain URL doesn’t work when it is manually entered into the browser bar but it should work when a link within your application is clicked?




    I just want what you said!


    There is not way for PrettyFaces to distinguish between the two kind requests. I doubt that something like this makes sense. The only way to implement something like this would be to manually check the “Referer” header.



    It makes sense!

    I have this command link that should assign forumBacking.forumName property with needed forum’s name

    <h:commandLink action="pretty: forumInnerLink" styleClass="forumNameLink" value="#{}">
    <f:setPropertyActionListener target="#{forumBacking.forumName}" value="#{}" />

    When I click this link I have correct forum name assigned to forumBacking.forumName . But I want to move to next page clicking this link without passing any parameters. I have mapping in pretty-config

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

    This mapping is bad because it matches parent_mapping(forums) + “/”. It means that user types in browser bar what matches and receives nothing because forumBacking.forumName is null .

    I dont’ want to pass as a parameter because moderator on javaranch told me:

    <qoute>Passing parameters on the View is something that should be avoided. So is using an object locator.

    In JSF, the preferred way to pass objects around is to keep them in Managed Beans and inject them as Managed Properties into the beans that use them. It makes for less network traffic (objects don’t have to be serialized out and back), more security (nothing exposed to the client side where it can be hacked), and simpler coding. </qoute>

Viewing 15 posts - 1 through 15 (of 23 total)

The forum ‘PrettyFaces Users’ is closed to new topics and replies.

Comments are closed.