-
1. Re: Setting actionparam value
sam-user Jun 24, 2009 9:26 AM (in response to sam-user)Hello again,
could anyone help me with this. I'm really stuck here - I searched in this forum and in the documentation but so far I was unable to figure out what I am doing wrong.
Thanks -
2. Re: Setting actionparam value
ilya_shaikovsky Jun 24, 2009 9:38 AM (in response to sam-user)add ajaxSingle true to the button.
-
3. Re: Setting actionparam value
sam-user Jun 24, 2009 9:53 AM (in response to sam-user)That changed the behavior, but not as I expected it. I can now get the value of the "previous" request.
So if I typed "value1" in the the text field and click the button , in my action bean I get null. The second time I click the button I get "value1" in my bean.
That can't be right, can it?
Actually I just gave it another go without the ajaxSingle attribute and it does exactly the same thing - the bean gets the previous value of the field - something I didn't notice before. -
4. Re: Setting actionparam value
sam-user Jun 25, 2009 4:33 AM (in response to sam-user)Ignore the last statement of my previous post - it's not true.
But I still cannot pass the value of the input text field via actionparam to the action bean with the first click on the button. It onlly works the second time.
Any thoughts what might be the reason?
Thank you. -
5. Re: Setting actionparam value
ilya_shaikovsky Jun 25, 2009 4:59 AM (in response to sam-user)I see two problems with initial code:
1) parameter encoded during button encode. And initially it is null. So button passes this null after clicked current parameter. it's not evaluated after button click but just passed. So you can't use it like you defined. Just get the submitted #{alHome.instance.alLoc} in your action.
2) support on onblur and button will cause two concurrent request fired if the input focused and button clicked. And this not seems good approach. -
6. Re: Setting actionparam value
sam-user Jun 25, 2009 5:29 AM (in response to sam-user)Thanks Ilya,
It's clearer now, but still some gray areas (obviously still trying to find my way around).1) parameter encoded during button encode. And initially it is null. So button passes this null after clicked current parameter. it's not evaluated after button click but just passed. So you can't use it like you defined
That explains the missing value the first time the button is clicked, but what do you mean by:
Just get the submitted #{alHome.instance.alLoc} in your action.
Not quite sure how to do that.
Alsosupport on onblur and button will cause two concurrent request fired if the input focused and button clicked. And this not seems good approach.
Isn't there order in which these are executed?
Thank you. -
7. Re: Setting actionparam value
ilya_shaikovsky Jun 25, 2009 6:06 AM (in response to sam-user)"Just get the submitted #{alHome.instance.alLoc} in your action."
after you clicking button the #{alHome.instance.alLoc} model objects gets updated with new value. Just use this value.
"Isn't there order in which these are executed?"
using queue (described in documentation) will allow to send them one by one. -
8. Re: Setting actionparam value
sam-user Jun 25, 2009 6:44 AM (in response to sam-user)Thanks Ilya,
after you clicking button the #{alHome.instance.alLoc} model objects gets updated with new value. Just use this value.
This worked, but only after I removed thebypassUpdates="true"
from the onblur support.
Just one more question, though - if I have this<s:decorate id="locField" template="layout/edit.xhtml"> <ui:define name="label">Loc</ui:define> <h:inputText id="aLoc" value="#{alHome.instance.alLoc}"> <a:support event="onblur" reRender="locField" ajaxSingle="true" eventsQueue="locLookup"/> </h:inputText> <a:commandButton value="Search" image="img/search.GIF" id="searchImg" action="#{locSearch.search}" eventsQueue="locLookup"> <a:actionparam name="aLoc" value="#{alHome.instance.alLoc}" assignTo="#{locSearch.searchString}"/> </a:commandButton> </s:decorate>
Wouldn't it be correct to assume that once a text is typed in the text field(aLoc) and the onblur event occurs and re-renders the locField tree, then the actionparam value is updated with the entered text and the actual value of alHome.instance.alLoc is passed to the bean via actionparam?
Thanks. -
9. Re: Setting actionparam value
ilya_shaikovsky Jun 25, 2009 6:58 AM (in response to sam-user)Thanks Ilya,
Quote:
after you clicking button the #{alHome.instance.alLoc} model objects gets updated with new value. Just use this value.
This worked, but only after I removed the
Code:
bypassUpdates="true"
talking about support yes. But the button had no bypass and ajax single flags from the beggining in your code. So it should update the model correctly after clicked.
And your assumption about last code seems correct. But it still not clear for me why you need this param at all. you could get just the #{alHome.instance.alLoc} submitted value from #{locSearch.search}. -
10. Re: Setting actionparam value
sam-user Jun 25, 2009 7:06 AM (in response to sam-user)But it still not clear for me why you need this param at all. you could get just the #{alHome.instance.alLoc} submitted value from #{locSearch.search}.
I guess you mean in #{locSearch.search} instead of from.
Mainly, because I'm still learning and I hadn't thought about getting the value I need directly from the Home instance. Old habits die hard :-)
Thanks a lot for your help.