[JSF] Blank out bean properties when assign HTML element is "emtpy"

  • Thread starter Christoph Dahlen
  • Start date
C

Christoph Dahlen

Hi,

I noticed a problem from "old school" JSP times is also present in JSF.
Assume I have a Managed Bean in my session names "myBean". Also assume
that I have bound the property "prop" of myBean to a <h:inputText>
component.

<h:inputText value="#{myBean.prop}" />

Now, when I enter some text into the generated HTML <input> field and
send the form, this text is - of course - written into the assigned
property.

But, when - after this - I clear the HTML <input> field and send the
form again, the properties value is _not_ removed, the appropriate
setter is not called, when the input from the <input> field is empty
(that is: null or zero-length string).

Can this be avoided?

Gruß,

Christoph
 
C

cicap

Christoph Dahlen said:
But, when - after this - I clear the HTML <input> field and send the
form again, the properties value is _not_ removed, the appropriate
setter is not called, when the input from the <input> field is empty
(that is: null or zero-length string).
are you sure that your inputText has not required="true" ?
 
C

Christoph Dahlen

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
are you sure that your inputText has not required="true" ?

I am.

Gruss,

Christoph
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFAnHeX94TMRoWcFYRAqZaAKCj9Cg6mF8awoePu7UarMSNc7CnKQCgs4dM
LvVuyl9W89SIzsG0zH8C9P8=
=TeZf
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top