0

I'm using JSF, trying a to call a page on a button click inside a data table using the following code

 <h:column> <h:outputText value=""/> <h:commandButton id = "btn" value="History" action="#{Bean.showHistory}"> </h:commandButton> </h:column> 

My bean class icludes a method "showHistory" which returns success and I've included the navigation rule in faces-config.xml too but still the page couldn't be called. My navigation rule looks

<managed-bean> <managed-bean-name>Bean</managed-bean-name> <managed-bean-class> com.bean.HistoryBean </managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean> <navigation-rule> <display-name>List</display-name> <from-view-id>/BookList.jsp</from-view-id> <navigation-case> <from-outcome>success</from-outcome> <to-view-id>/History.jsp</to-view-id> </navigation-case> </navigation-rule> 

Bean Class consists of showHistory() as

public String showHistory() { return "success"; } 

Can I get a help to resolve this????

8
  • Is your method called at all (Letter "B" should be lowercase, a typo?). How does your navigation rule look like? Commented Mar 28, 2011 at 6:09
  • I've included my navigation rule in my post..in the BookList.jsp the button History in placed, when clicked should open History.jsp.U can also find the managed bean, where HistoryBean class consists of method showHistory() which returns success. Commented Mar 28, 2011 at 6:16
  • Do you have another action method in your bean that returns "succes"? If so, you should add the <from-action>#{bean.showHistory}</from-action> to your navigation case. Commented Mar 28, 2011 at 6:21
  • Sorryy..Couldn't get you.I dont have any other action method in this bean which returns "success", but do have a similar action method in a different bean Commented Mar 28, 2011 at 6:26
  • Could you add the showHistory method? Commented Mar 28, 2011 at 6:28

2 Answers 2

2

Ensure you put the command button inside a h:form element: it should work!

Sign up to request clarification or add additional context in comments.

Comments

0

From your source code everything looks good (of course including Pier's suggestion to use the h:form tag).

Try to debug and check if your action method is called at all.

If not, then maybe your from-view-id element does not match. As a test you could try it with an empty element (default navigation for all pages):

<from-view-id></from-view-id> 

If this works, then the problem is with your from-view-id element. Maybe it's in a different folder or an upper/lower case typo.

1 Comment

thanks for ur time Handy.I tried debugging it couldn't call the method as u said,but acc to Pier's suggestion it worked fine

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.