This week's book giveaway is in the Cloud forum.
We're giving away four copies of Terraform in Action and have Scott Winkler on-line!
See this thread for details.
Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

JSF dataTable parameter call problem

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Saloon Keeper
Posts: 24575
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Paolo Pinkel
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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


 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic