Dynaview View Bean method not called

Splash Forums PrettyFaces Users Dynaview View Bean method not called

This topic contains 11 replies, has 3 voices, and was last updated by  Arun Kumar 9 years, 9 months ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
  • #18308

    Arun Kumar

    I am trying to setup Prettyfaces in my environment. You can refer to this earlier post for details on the environment including web.xml and pretty-config.xml – http://ocpsoft.org/support/topic/prettyexception-failed-to-load-configuration

    In brief the environment is Weblogic 10.3.6, JSF 2.0, Prettyfaces 3.3.2

    My pretty-config.xml has this url-mapping section:

    <url-mapping id=”form-map”>

    <pattern value=”/*” />

    <view-id value=”#{forms.computeViewPath}” />


    And I have this as corresponding bean:

    @ManagedBean(name=”forms”) //The name attribute is kind of redundant but I tried it in case it was not picking this up automagically


    public class Forms implements Serializable {




    private static final long serialVersionUID = 1384083398686268456L;

    final static Logger logger = LoggerFactory.getLogger(Forms.class);

    public String computeViewPath() {

    PrettyContext pctx = PrettyContext.getCurrentInstance();

    String path = pctx.getRequestURL().toString();

    logger.debug(“Path:” + path);



    In the example for Dynaview I noticed the bean using a method called getViewPath, I tried that, and wondered if it was a problem so I tried calling bean.viewPath as a property, and finally changed it to bean.computeViewPath. I have also tried to specify the view-id value as bean.computeViewPath() (forms.computeViewPath() in my example) with no success. The logger.debug(… statement is never executed.

    Any help would be much appreciated.




    Arun Kumar

    Just and update since I’m unable to find the edit link for the post, the bean code above is missing return "/index.jsf"; after the logger.debug… line.


    I’m guessing DynaView is never called because you are specifying an invalid pattern:

    <url-mapping id="form-map">
    <pattern value="/*" />
    <view-id value="#{forms.computeViewPath}" />

    PrettyFaces uses regular expression patterns, so right now your pattern matches anything like, “/”, or “/////////////////////////////////”.

    You should use this instead:

    <pattern value="/.*" />

    Note the extra ‘.’ character. This is the regular expression token for “match anything,” followed by ‘*’, which means, “zero or more times.”

    Hope this helps.


    I’m not completely sure this will work either. I think regular expressions only work in parameters and not in the static part of the pattern. So if this doesn’t work you should try something like:

    <pattern value="/#{ /.*/ path }" />

    But I may be wrong and Lincoln’s approach will work. I’m not sure. :)


    That’s only true for Rewrite and PrettyFaces 4 – In PrettyFaces 3 this should work fine. The only problem is that URLs won’t be generated properly going outbound – but this is a documented limitation of using regular expressions in your URL-patterns.


    Oh, interesting. Didn’t know that. :)


    It’s not something to advertise – your approach is actually much better IMO.


    I guess I always used my approach because typically I want to access the variable part of the pattern somehow. So in most cases I simply inject it somewhere and in this case I need to add a parameter anyway. :)


    Arun Kumar

    An update. Using the patter that Lincoln suggested:

    <pattern value=”/.*” />

    did not work. The debug log message is never printed. But changing it to

    <pattern value=”/forms/#{formId}” />

    did work.

    Although I’m not using CDI or Seam, so the variable formId is really never injected or used. But with that pattern my bean method is called. Not sure why the plain /.* wouldn’t work.


    Arun Kumar

    Christian, I also tried your: <pattern value=”/#{ /.*/ path }” />

    but I got this error:

    com.ocpsoft.pretty.PrettyException: Could not forward to view: #{forms.computeViewPath}

    at com.ocpsoft.pretty.faces.config.dynaview.DynaviewEngine.processDynaView(DynaviewEngine.java:109)

    at com.ocpsoft.pretty.faces.event.PrettyPhaseListener.afterPhase(PrettyPhaseListener.java:109)

    at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:185)

    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:103)

    at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:107)

    Truncated. see log file for complete stacktrace

    Caused By: javax.el.ELException: java.lang.ArrayIndexOutOfBoundsException: 2

    at com.sun.el.parser.AstValue.invoke(AstValue.java:238)

    at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)

    at com.ocpsoft.pretty.faces.util.FacesElUtils.invokeMethod(FacesElUtils.java:70)

    at com.ocpsoft.pretty.faces.util.FacesElUtils.invokeMethod(FacesElUtils.java:62)

    at com.ocpsoft.pretty.faces.config.dynaview.DynaviewEngine.calculateDynaviewId(DynaviewEngine.java:149)

    Truncated. see log file for complete stacktrace

    Caused By: java.lang.ArrayIndexOutOfBoundsException: 2

    at com.saggezza.mmfsl.loanapp.bean.system.Forms.computeViewPath(Forms.java:66)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

    at java.lang.reflect.Method.invoke(Method.java:616)


    Yes, it looks like there is an error in your own method:

    Caused By: java.lang.ArrayIndexOutOfBoundsException: 2
    at com.saggezza.mmfsl.loanapp.bean.system.Forms.computeViewPath(Forms.java:66)

    Fix that and your application should work.


    Arun Kumar

    Sorry should have spotted that one. Thank you both for your help.

Viewing 12 posts - 1 through 12 (of 12 total)

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

Comments are closed.