Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DataTable Connection porblem

 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
In my application i am dynamically generating tables by using h:datable along with that fields i am generating one view commandbutton for each and every row, if i click on that button it is not going to next page,here i am pasting my code please help me,

//jsp page

<h:column>
<f:facet name="header">
<%-- <hutputText value="#{msgs['header.message']}" /> --%>
</f:facet>
<h:commandButton value="View" actionListener="#{AllotmentBooking.viewAllotmentBooking}" />
</h:column>

</h:dataTable>

//java class

public String viewAllotmentBooking(ActionListener actionListener){
return "viewAllotmentBooking";
}

//faces-config.xml code

<navigation-rule>
<from-view-id>/AllotmentBooking.jsp</from-view-id>
<navigation-case>
<from-outcome>viewAllotmentBooking</from-outcome>
<to-view-id>/ViewAllotment.jsp</to-view-id>
</navigation-case>
</navigation-rule>

here AllotmentBooking.jsp is my main page from here i am moving to ViewAllotment.jsp.

Please help me to slove this problem

Regards,
Vardhan
 
Jerwin Louise Uy
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand it correctly, you want your command button to navigate to the second page. If not then ignore the message below.

If so, the actionListener does not in any way affect navigation. Change the actionListener attribute in the commandButton to action.

Modifications -



Regards.
 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jerwin,

I tried by changing my code what ever you said but it is giving but it is not working

public String viewAllotmentBooking(){
return "viewAllotmentBooking";
}

<h:commandButton value="View" action="#{AllotmentBooking.viewAllotmentBooking}" />

Thanks,
Vardhan
 
Jerwin Louise Uy
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it is not working then I would appreciate if you could post a the log file of the exception when you clicked the method.

Usually, there will be a check when the command button fires an ActionSource

- If the method is found in the declared backing bean
- If the method signature is correct

Thanks.
 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is not showing any error, when i click the control is not moving any page and page is getting refresh.

Regards,
Vardhan
 
Jerwin Louise Uy
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If that is true, then you either you are using an actionlistener or an action with a return null.

Regards.
 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
first i tried with ActionListener after that i tried with Action parameter but in both conditions it is not working and not showing any error,

i think the control is not going to next page and i don't know where the problem is i tried my best and still working on that....please find where the porblem is ..

Regards,
Vardhan
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A couple of causes:

1) A validation or conversion error is being thrown which skipped the invoke action phase. It might be uncaught by the page because of a lacking h:message or h:messages tag. If you were using JSF 1.2, those errors should be printed in the application server logs. If you are using JSF 1.1 or older, then add <h:messages /> to the page to take note of all validation and conversion errors.

2) The getter of the datatable value doesn't return the same datamodel during the apply request values phase of the next request. So JSF wouldn't be able to determine which row has invoked which action method. To do a quick test, try placing the bean in the session scope. If it solves the problem and you want to keep the bean request scoped, then you should review your data loading logic so that it returns exactly the same datamodel in the both requests of displaying the table and processing the submit.

3) The from-view-id of the navigation case doesn't match the actual view id. Verify it, it is case sensitive. The same applies to the to-view-id.

At least also verify if the action method is actually invoked by adding a simple debug statement to it so that you can read in the logs if it is actually invoked. E.g.
[ August 24, 2008: Message edited by: Bauke Scholtz ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic