I want to be able to populate the Rendered attribute of an apex:variable
tag with the results of a function for different components i have, which are being displayed using <input>
tags.
So let's say I am using Action Function like so:
<apex:variable value="x" var="y" rendered="{!myFunctionResult}"/>
<a>Input 1: </a>
<input name="input1"/>
<apex:actionFunction name="" immediate="true" action="{!function}">
<apex:param value="input1" name="fieldName"/>
I am able to pass the input that I want to validate back to the controller function and I have a true/false returned, which I can then use to render the input.
How can I do this, so that when a page loads, this will occur automatically?
[[ Updated ]] Still not working even when rerendering component…
<apex:component controller="FormExtensionController" >
<apex:attribute type="String" description="test" name="fieldName" assignTo="{!fieldApiName}" />
<apex:outPutPanel id="mycomponent">
<apex:outPutPanel rendered="{!isRendered}">
<a>Input 1: </a>
</apex:outPutPanel>
</apex:outPutPanel>
<apex:form>
<apex:actionFunction immediate="true" name="doCallout" action="{!loadComponent}" rerender="mycomponent" />
</apex:form>
<script type="text/javascript">
(function() {
window.addEventListener("load", function() { doCallout(); });
})();
</script>
</apex:component>
Best Answer
The value would not be passed back to your page unless you rerender component
ie.
You need the two output panels if you have not other parent elements. You could also serenader the page. You cannot rerender the element with the conditional rendering directly in this case.