You need to sign in to do that
Don't have an account?
Scott.M
Set <apex:param> value with Javascript
Hi,
Is it possible to set the value of a param object in visual force. For example if I defined a action function as follows:
and I've loaded the prototype library should I be able to do something like this
Is there a different way of setting the value of the parameter in javascript. Also it'd be nice if in the object reference examples the source code (javascript and html) generated for the tag was shown.
Is it possible to set the value of a param object in visual force. For example if I defined a action function as follows:
Code:
<apex:actionFunction name="testAction" action="{!testAction}" rerender="ListTable" immediate="true"> <apex:param name="reference" id="update_reference" value="0" /> </apex:actionFunction>
and I've loaded the prototype library should I be able to do something like this
Code:
$('update_reference).value = '1';
Is there a different way of setting the value of the parameter in javascript. Also it'd be nice if in the object reference examples the source code (javascript and html) generated for the tag was shown.
'{!$Component.update_reference}' should work depending on where you reference it in your page. There is some good doc around $Component's usage that should help you.
It sounds like it's exactly what I was looking for unfortunately it's not working for the param object in the actionFunction. How are the paramters in action functions handled. I had a look at the documentation in the pages document but it's very brief and doesn't specifically talk about using the global $component object with the actionFunction tag.
onchange="$('{!$Component.updateId}').value= '1'";
gives the javascript error:
$("j_id0:j_id3:updateId") is null
When actionFunction tag gets rendered is it part of the DOM? Is there a better way to pass paramters to an actionFunction?
I don't think there's a way for you to dynamically set the value of the param through javascript. You could use an expression and get it from you controller, but that seems to be it.
I settled on passing the parameter by binding it to a variable in the controller. The only problem now is that I need the action to be immediate, validation rules shouldn't be processed. The reason it's a problem is that if I set the action to immediate = "true" the controller variables don't get updated before I reference them. Is there a way to force the setters to happen before i use the variable. It works fine if immediate is set to false and there are no errors.
BTW I have seen quite a few folks dropping to apex:actionFunction when in most cases apex:actionSupport is a much better option - can't tell from your posted code if this is the case for you or not - can you post your entire page/controller code here?
Message Edited by dchasman on 07-02-2008 03:01 PM
Message Edited by Scott.M on 07-03-2008 07:52 AM