You need to sign in to do that
Don't have an account?
How to control rendered attribute of outputpanel based on variable's length
Hi guys,
The title pretty much explains what I need to do.
To clarify more:
I have a component with code like:
<apex:component access="global">
<apex:attribute access="global" name="RecipientLabel" description="Recipient label." type="String" required="true"/>
-------SOME MORE STUFF HERE------
<apex:outputPanel rendered="{!RecipientLabel}.length()>0"><div> <apex:outputLabel >{!RecipientLabel}:</apex:outputLabel> </div> </apex:outputPanel>
-----SOME MORE STUFF HERE -----
</apex:component>
If you look at the expression that I hae for rendered: "{!RecipientLabel}.length()>0"
That does not work it seems to be always false even though when I remove it the component shows and I can see that the output label has text in it.
Please let me know hwo to make that work.
I have tried sever different things like putting a javascript function in rendered different syntaxes but so I am not lucky enough to hit the right combination.
Thanks,
Kos
You should be able to use the LEN function for this.
Change:
to
All Answers
Hi,
You can try using a controller, through which you can set a boolean value for the output Panel based on the Reciepient Length.
Hi,
thanks you for your promt reply.
I was curious if there is a more elegant solution.
I have about 50 variables passed in to my component.
I will have to add another say 25 for a total of 75 in order to have flag but it will certainly work.
I was hoping that this can be done somehow having the label already.
If there is no better solution in a couple of day I will mark this as an answer as this will definately work.
Thanks again.
Kos
You should be able to use the LEN function for this.
Change:
to
Exactly.
Thank you very much !
Kos
Right. You have to use an expression that is evaluated by the server, in order for the server to know whether to render the component or not.
I'd say there is a bug here in that the page compiler should have complained that the value of the rendered attribute is not a simple boolean value (after evaluating the embedded expression).
Hope this works for you :
<apex:outputPanel rendered="{!IF(LEN(RecipientLabel)> 0 ,true,false)}">