0

We are upgrading from jsf 1.2 to jsf 2. We are using apache myfaces 2.1 and rich faces 4.3.

We have onload-phase listener configured like below (for JSF 1.2)

web.xml :

<context-param>
        <param-name>onload-config</param-name>
        <param-value>/WEB-INF/onload-config.xml</param-value>
</context-param>

and corresponding phase listener configured in faces-config.xml as :

<lifecycle>
    <phase-listener>net.sf.jsfcomp.ext.onload.OnLoadPhaseListener</phase-listener>
<lifecycle>

We are using same configuration as is for migrating to JSF 2 and as I know we don't need to include any extra jar for above set up to work. (jsf implementation and commons-logging jars are the only pre-requisites)

However when a url is clicked which is to invoke an action method for configuration in onload-config.xml as below :

<navigation-rule>
    <view-id>/from-page.xhtml</view-id>
    <action>#{bean.action}</action> 
</navigation-rule> 

bean.action is not getting invoked and resource not found error is returned.

Am i missing any configuration ? or do i need to add any extra libs ? Please help.

EDIT 1 : Adding more details for the issue :

The page being rendered after bean.action method is returned is as below :

<ui:composition>

            <a4j:form id="sample-Form">

                <ui:include src="#{bean.panel}">
                </ui:include>

                        <h:commandButton id="button1" value="Go" action="#{bean.next}"/> 

            </a4j:form>

</ui:composition>

where on clicking the next button , same page is rendered with dynamic panel name (bean.panel) returned from back end

Atul
  • 1,560
  • 5
  • 30
  • 75
  • 2
    Why not just use `@PostConstruct` (available since JSF 1.2) or `` (available since JSF 2.0) or `` (available since JSF 2.2)? – BalusC Jan 20 '14 at 11:20
  • Thanks for your repply. I can't use the , because as I know ,the listener method is called every time a view is renderd. I want the method to be called only once since every time i click on next button , same page is rendered. Regarding @PostConstruct , as i understand , post construct method is called after bean is constructed and all properties are set which is also a difficult choice for me since i cannot control initialisation of the bean in question.It is done at some other part of the code. – Atul Jan 20 '14 at 13:20
  • 1
    As to `@PostConstruct`, just use a `@ViewScoped` bean. As to ``, add a check on `FacesContext#isPostback()`. See also among others http://stackoverflow.com/questions/8506033/is-it-possible-to-disable-fevent-type-prerenderview-listener-on-postback/8506088#8506088 and http://stackoverflow.com/questions/9844526/when-to-use-prerenderview-versus-postconstruct – BalusC Jan 20 '14 at 13:28
  • @BalusC:Thanks a lot for your repply.I am trying the above solution out.But just for curiosity , is it not a good practice to use above listener in JSF 2 since you seem to not mentioning about it ? – Atul Jan 20 '14 at 14:05
  • It's originally designed for the prehistoric JSF 1.0/1.1 versions when `@PostConstruct` and view scope didn't exist. If something can be solved using standard API solutions, it should be preferred over 3rd party ones. Let me know if that works out for you, then I'll summarize the comments into a true answer. – BalusC Jan 20 '14 at 14:31
  • @BalusC:Thanks for your repply.Since my application is bit complex with design considering JSF 1.2 in mind , i need to change the files a bit and hence it is taking time , i will let you know as soon as i run the above set up. – Atul Jan 21 '14 at 13:22

0 Answers0