File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF dataTable parameter call problem" Watch "JSF dataTable parameter call problem" New topic

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: 17417

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.

An IDE is no substitute for an Intelligent Developer.
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

I agree. Here's the link:
subject: JSF dataTable parameter call problem
It's not a secret anymore!