Forums Register Login

Saving an h: inputText 2 times

+Pie Number of slices to send: Send
Hello everyone,,,,, I hope this finds you well ..

Sorry to bother. But I'm a bit new to jsf,
and would like to help me with a problem I have

the problem is the following

Want to save the value from h: inputText ... 2 times just click save I will save 2 times the same value ..


would be something like:

<h:inputText value="#{vistaGuardar.valorguardar}" />

the input text that save me 2 times

<a4j:commandButton actionListener="#{vistaGuardar.insertarValor2veces }" value="Save" />



I hope you can help me ..
Thanks for your time .....
1
+Pie Number of slices to send: Send
If what you mean is that the "setValorguardar" method is being invoked multiple times from 1 submit request, that is normal. JSF can invoked a property's set/get methods many times in the process of handling a request/response cycle. I've seen 5 or 6 in some cases.

What is important is not how many times the get or set methods are invoked as it is that they should be idempotent. That is, they should not have side-effects that change if the method is invoked more than once nor should they perform long-running actions (since that will drag down performance doing redundant work).

This is why JSF has action methods. So that we're not forced to do our business and database logic in the property methods, but instead do them when a commandButton or commandLink is clicked. The action methods do only get invoked once.

I do not recommend using actionListeners, however. The have their (rare) uses, but a straight (POJO) action method is cleaner and makes for code that's easier to reuse and to debug.
I don't always make ads but when I do they're tiny
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 545 times.
Similar Threads
Wierd DataTable Problem
question for h:inputText with struts tile 1.1
Dan Mock Exam Question(Hascode)
How to prevent new record creation on page reload?
Save form data to server hard disk via JSP
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 06:19:53.