This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSF and the fly likes JSF dataTable parameter call problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF dataTable parameter call problem" Watch "JSF dataTable parameter call problem" New topic
Author

JSF dataTable parameter call problem

Paolo Pinkel
Ranch Hand

Joined: May 04, 2011
Posts: 35
I have a strange problem I don't know how to fix.

I have a form with a dataTable that looks like this:


When I click the Update button, the saveProperty method is called, but the parameter (someHandler.newPropertyValue) is an empty string.

Does anyone know why?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15960
    
  19

Action methods weren't designed to be invoked with parameters. The idea is that the entire form is going to have been validated and updated into your backing bean, and in fact, if any item submitted fails validation, the action method won't be invoked at all - the JSF lifecycle will short-circuit it and display validator error message(s).

The inputText control isn't supplied with a display value expression, it's supplied with a value reference expression. Going out, the current value of the bean property is displayed, but on submit, the reverse will happen. So you don't need a "newValue", the original value will have been automatically updated for you.

JSF is very different from other web frameworks and the #1 rule in JSF is that the more code and the more complexity, the more likely you're doing it wrong. They've tried to make the common functions as simple and easy as possible.


Customer surveys are for companies who didn't pay proper attention to begin with.
Paolo Pinkel
Ranch Hand

Joined: May 04, 2011
Posts: 35
Thanks, Tim.

But I still don't know how to fix it.

The reason why I use "newPropertyValue" and "propertyValue": I get the propertyValue from some other object. My getPropertyValue method calls some other method and I can't "set" that (yet). (I hope it's clear what I mean.) Maybe I'm thinking wrong... this seems like a common problem to me. I would like to have the propertyValue as the default value displayed in the inputText field, but I wan't changes to be bound to newPropertyValue. Hm. Maybe I could initialize the bean property, buuut... it's a dataTable. :O


 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JSF dataTable parameter call problem
 
Similar Threads
Setting up a JSF project with data tables
Using of nested Datatables
JSF datatable doubt
How to determine which dataTable row was selected
jsf page that does not update values according to the model