+ Start a Discussion
tdeptdep 

Multiple Conditions for Rendered Attribute

Hi,

 

I am currently having an issue with the rendered attribute for an outputpanel. I currently have it check against an inputfield to see if it is blank.

 

It works with 1 condition: <apex:outputPanel rendered="{!LEN(address)<1}"  >

 

But if I want to add in an additional OR || statement to check for {!LEN(city)<1} than it breaks.

 

I tried the following:

 

<apex:outputPanel rendered="{!LEN(address)<1} || {!LEN(city)<1}">

<apex:outputPanel rendered="{!LEN(address)<1} OR {!LEN(city)<1}">

<apex:outputPanel rendered="{!LEN(address) || !LEN(city) <1}">

<apex:outputPanel rendered="{!LEN(address) OR !LEN(city) <1}">

 

I am probably missing something super simple. Any help would be greatly appreciated. 

 

Thanks in advance!

Best Answer chosen by Admin (Salesforce Developers) 
tdeptdep

Hey Bob,

 

Thanks for the quick response.

 

Unfortunately that makes it so when both inputs are populated it will cause the panel to disappear. 

 

It just popped into my head, by adding the LEN of the 2 values together and checking if it is lower than 1 it works.

 

So this worked to show the panel only when both inputs were blank:

 

<apex:outputPanel rendered="{!LEN(address) + LEN(city) < 1}">

 

Again, thanks for your help!

 

All Answers

bob_buzzardbob_buzzard

I think the following should work:

 

<apex:outputPanel rendered="{!LEN(address)<1 || LEN(city)<1}">

 

tdeptdep

Hey Bob,

 

Thanks for the quick response.

 

Unfortunately that makes it so when both inputs are populated it will cause the panel to disappear. 

 

It just popped into my head, by adding the LEN of the 2 values together and checking if it is lower than 1 it works.

 

So this worked to show the panel only when both inputs were blank:

 

<apex:outputPanel rendered="{!LEN(address) + LEN(city) < 1}">

 

Again, thanks for your help!

 

This was selected as the best answer
Mariappan PerumalMariappan Perumal

Hi bob.

 

I have written a vf page in which i am comparing 2 fieldset and have one more condition 

 

I tried to rendered the inputfield based on condition , Its working fine but the problem is it simply hide the field.

and showing me blank row for the condition which didn't met the condition.

 

I have pasted the code below.

 

apex:repeat value="{!PersonalinfoFields}" var="f">
<apex:repeat value="{!Fieldsconfig}" var="conf">
<tr><td> <p>
<apex:outputlabel value="{!f.label}" rendered="{!AND(a[conf.fieldPath]==true,f.label==conf.label)}" /></p></td><td>
<apex:inputField value="{!app[f.fieldPath]}" rendered="{!AND(a[conf.fieldPath]==true,f.label==conf.label)}" style="width: 250px; height: 20px; border:inset 2px;" id="fname"
/></td></tr>
</apex:repeat>
</apex:repeat>

 

 

Is there a way to avoid this thing. 

bob_buzzardbob_buzzard

It will do, as you have only changed the rendering on the individual fields, but the table rows and cells are still being outout.

 

You should put the entire table row inside an outputpanel and conditionally render that I'd say - make sure to set the layout attribute to 'none' or it will output markup that will mess up the table.

Mariappan PerumalMariappan Perumal

Thanks bob.

 

Its been  head ache for me for the past 2 days and its working fine.

 

Thank you so much.

Mariappan PerumalMariappan Perumal

Hi bob.

 

I need some assistance on this.

 

I have been working on json parsing which came from my google analytics via webservice .

 

I got the response from google analytics and json file is little confusing me.

 

It doesn't seem like json and rows are like 

{

"totalsForAllResults":
{
"ga:visitors":"31",
"ga:newVisits":"25"
},
"rows":
[
["20130401","0","0"],
["20130402","0","0"],
["20130403","0","0"] ]

}

Incase of totalforallresult node we can refer the no of visitors and newvisits through the nodeName ga:visitors and ga:newVisits respectively .

 

But what can we do in case of parsing the rows .

 

I tried in many ways but couldn't get the solutions. 

 

Can you please assist me on this.

 

Thanks in advance

John Jenkins 4John Jenkins 4
I ran into a similar issue and only one of the above solutions worked for me:
<apex:outputPanel rendered="{AND(!errorCheck == true, !luserFail != true)}" >

This did not work:
<apex:outputPanel rendered="{!errorCheck == true && !luserFail != true}" >

Hope this helps anyone that was trying to get "rendered" to look at multiple values from the custom controller.