Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JFS + JAVA + MYSQL  RSS feed

 
Zsolt Fugedi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

I have a problem, the deleteOsszesito method does not work, but the getGetSetDatabase method is work. Why doesn't work deleteOsszesito method?








############Set Get osztály##########################






#####jsf kód###################################x






Thank you very much
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The PreparedStatement only has one parameter (that ? character at the end). But the following code tries to set four parameters. This will throw an exception, and then the code in your exception handler will deal with it. Only one problem:



Your exception handler ignores the error and carries on as if nothing had happened. At least print the stack trace, like this:




 
Zsolt Fugedi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you very much.

I modify my code, but delete and update method not work, my modify code:






##Set ang get class:







#####jsf page:




 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Any time you have a problem in JSF and you're dealing with a Request scope backing bean, change its scope to View or Session scope. Request Scope is almost 100% useless in JSF.

2. The convention in JSF is that class names start with an uppercase letter, but instance names and property names start with a lowercase letter. So on your View Template, the preferred reference would be "tezt", not "Tezt". JSF will not automatically reject failure to adhere to naming standards, but you may encounter places where things don't work right.

3. Action methods are not method calls from the View. They are method references. Thus, the construct action="#{Teszt.deleteOsszesito(c)}" is improper. Ideally, it should simply be action="#{teszt.deleteOsszesito}". JSF itself calls the action method, so there should be no parameters or function-call syntax "()".

You do not normally need parameters on an action method because JSF is designed to work with data from the Model. In the case of a delete button on a table, the table's row data should be wrapped in a DataModel object, and that object presented by the backing bean (Model) as the property referenced by the dataTable's value= attribute. If you do that, then the action method will know which row you clicked on by invoking the DataModel's "getRowData()" method without the need for View-side parameters.

Even if you don't explicitly define a DataModel, JSF is going to construct one, but if JSF constructs a DataModel for a dataTable, it will not be accessible to the backing bean logic and thus no "getRowData()", so it's better to have the backing bean construct a DataModel explicitly.

And, returning to item #1, Request scope is 100% useless if you use a dataTable, because the DataModel contains essential row cursor information and that information is destroyed when a request scope backing bean is destroyed and re-created as part of a normal page postback request.
 
Zsolt Fugedi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

now the deleteOsszesito does work, and updateOsszesito dosen't work. The chaged code part:

jsf page:




Teszt.java deleteOsszesito method:




Teszt.java updateOsszesito method:




And i changed scope to Session scope:



 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To repeat:

Action methods do not take parameters. They get their data directly from the Model.
 
Zsolt Fugedi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody!

My codes work, delete method works, select method works, but the update method dosen't work because overwrite the same, here it is the code:













There are three fields. These fields are in inputText. When I modify the fields and i click update button, then the fields return to original state :(
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!