| From | Sent On | Attachments |
|---|---|---|
| Stephen Carpenter | Dec 15, 2006 4:54 pm | |
| Craig McClanahan | Dec 15, 2006 5:09 pm | |
| Stephen Carpenter | Dec 18, 2006 9:26 am | |
| Craig McClanahan | Dec 18, 2006 2:34 pm | |
| Stephen Carpenter | Dec 21, 2006 4:43 am |
| Subject: | Re: [nbusers] Using function in JSF page | |
|---|---|---|
| From: | Craig McClanahan (crai...@apache.org) | |
| Date: | Dec 18, 2006 2:34:57 pm | |
| List: | org.netbeans.nbusers | |
On 12/18/06, Stephen Carpenter <step...@hotmail.co.uk> wrote:
Craig,
Many thanks for the reply. I'm fine with the strategy, but this is my very first use of a function and I cannot see how to : -
'Have your popup store its returned value in the "value" attribute of the hidden field component'.
Here is how my fundtion looks : - <webuijsf:script binding="#{Edit.script1}" id="script1"> function setDelete(){ if(confirm("Are you sure you want to delete this record?")){ return "true" }else{ return "false" } } </webuijsf:script>
And here is the JSF declaration : -
<webuijsf:hiddenField binding="#{Edit.hiddenField1}" id="hiddenField1" text="#{SessionBean1.strDelete}"/>
Could you clarify please.
Assume you have a hidden field in your input form:
<webuijsf:form id="form1" ...> ... <webuijsf:hiddenField id="hiddenField1" text="" .../> ... </webuijsf:form>
Then, your javascript function would need to do something like this:
function setDelete(){ var hf = document.getElementById('form1:hiddenField1'); if (confirm("Are you sure you want to delete this record?")) { hf.value = "true"; }else{ hf.value = "false"; } }
Now, when the form is submitted, your server side logic can check the value of the hiddenField1 component to see whether the user confirmed the delete or not.
Craig





