h:commandButton submit problem

hi,

i have a jsf page that simply wont submit, when you click on it, nothing happens. the same page appears again. i have other areas in my web application that will submit fine and proceed to the next page.

here is the code for the JSF page that does the submit.

h:commandButton id="submit" action="#{AuctionController.submitItemListing}" value="Submit Listing" />

next is the function in the AuctionController servlet where the submit button in the JSF page performs the action.

public String submitItemListing(){

int startingprice = Integer.parseInt(starting_price);// convert string values to integer

int buyitnowprice = Integer.parseInt(buy_it_now_price);

int reserveprice = Integer.parseInt(reserve_price);

startingprice = Math.round(startingprice*100)/100;// rounding numbers up to two decimal points

buyitnowprice = Math.round(buyitnowprice*100)/100;

reserveprice = Math.round(reserveprice*100)/100;

starting_price = Integer.toString(startingprice);// convert integers values back into strings.

buy_it_now_price = Integer.toString(buyitnowprice);

reserve_price = Integer.toString(reserveprice);

return"success";

}

then next is the navigation rule declared in the faces-config.xml

<navigation-rule>

<from-view-id>/sell.jsp</from-view-id>

<navigation-case>

<from-outcome>success</from-outcome>

<to-view-id>/sellconfirmation.jsp</to-view-id>

</navigation-case>

<navigation-case>

<from-outcome>failure</from-outcome>

<to-view-id>/sell.jsp</to-view-id>

</navigation-case>

</navigation-rule>

if you need further declaration of the code or you want me to provide more code, please do not hesitate to reply. All comments are much appreciated.

thanks.

[2360 byte] By [dharam.pa] at [2007-10-2 8:53:36]
# 1

I would change "AuctionController" to a java class and map this class to your faces config file

Example

<managed-bean>

<managed-bean-name>AuctionController</managed-bean-name>

<managed-bean-class>com.AuctionController</managed-bean-class>

<managed-bean-scope>request</managed-bean-scope>

</managed-bean>

a01480a at 2007-7-16 22:57:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Do you have an h:messages tag in sell.jsp? Is there any clue in your servlet container log?

My initial guess is that something is going wrong with one of your parseInt calls -- it might be worthwhile to wrap them (or even the entire method body) in a try/catch to see if there's an unexpected exception bubbling out and sending you back to the originating page.

kcounsella at 2007-7-16 22:57:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

hi thanks for the replies, i checked the logs and there isn't anything there to show that there is an unexpected error. i also wrapped the method and the conversion part in a try catch, just in case. but still no luck.

as to your question i do have <h:message > tags in the sell.jsp page, should do this effect this in anyway.?

Also, a01480, u asked for me to put the AuctionController in a class as you have demonstrated in your reply. i dont fully understand what and how to do this. please if u could give me more of insight into this.

thanks once again for your help.

dharam.pa at 2007-7-16 22:57:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Having <h:messages/> will show all messages generated while processing the page, not just the ones that you have set up for specific components using a <h:message for="xxx"/>. It is a useful indicator of whether or not something strange is happening with, for example,
kcounsella at 2007-7-16 22:57:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
hey thanks four your help people, i solved the problem. i did as u suggested by adding the <h:messages/> tag. which was returning an error, which i was then able to fix. but it wasnt displaying this before.anyway thanks for the help.
dharam.pa at 2007-7-16 22:57:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
I am glad that it helped -- <h:messages/> is everyone's friend!
kcounsella at 2007-7-16 22:57:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...