Anand Shankar
Anand Shankar

Reputation: 73

<f:viewParam> not setting value to bean

I want to implement a simple PRG approach which for some reason is not working as per my expectation. Please help.

1) I do a POST from firstpage.xhtml

                <p:column>
                    <p:menuButton value="#{i18n['actions']}">
                        <p:menuitem value="#{i18n['edit-course']}" icon="ui-icon-pencil" ajax="false" 
                            action="#{courseDesignerBackingBean.navigateToEditCourse(course.courseId)}" />
                        <p:menuitem value="#{i18n['delete-course']}" icon="ui-icon-trash" ajax="false"/>
                    </p:menuButton>
                </p:column>                 

2) Here, I am handling the action and making redirect.

public String navigateToEditCourse(long courseId){
  String outcome = "editCourse?faces-redirect=true" + "&amp;courseId=" + courseId;
  System.out.println(outcome);
  return outcome;
}

3) In page editCourse.xhtml, I am reading the request parameters.

<f:metadata>
  <f:viewParam name="courseId" value="#{courseModelBean.courseId}"/>
  <f:event listener="#{courseDesignerBackingBean.updateModelBeanByCourseId}" type="preRenderView"/>
</f:metadata>

My expectation on 3rd step was that first setCourseId() of courseModelBean would have got called followed by courseDesignerBackingBean.updateModelBeanByCourseId. But, setCourseId() of courseModelBean is not getting called.

Any hints?

Best regards, Anand.

Upvotes: 0

Views: 608

Answers (0)

Related Questions