function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vishal_ThoriyaVishal_Thoriya 

How to pass the value of variable in to condition of rendering?

i have simple problem but i dont know how to solve..

 

here it is

<apex:outputLabel rendered="{!(agenda.Committed__c== false && agenda.Employee__r.Name == 'Vishal Thoriya' )}" ><span><apex:outputLink onclick="editAgendaPopUp('{!agenda.Id}');return false;" styleClass="Links">Edit</apex:outputLink></span>&nbsp;|&nbsp;<span><apex:outputLink onclick="commitAgenda('{!agenda.Id}');return false;" styleClass="Links">Commit</apex:outputLink></span>  &nbsp;|&nbsp;<span><apex:outputLink onclick="deleteAgenda('{!agenda.Id}');return false;" styleClass="Links">Del</apex:outputLink></span></apex:outputLabel>

 i am rendering the elements based on conditions 

 

here in my code i have passed 'Vishal Thoriya'

 

which is a value of userName in my code

 

userName is 

like

public string UserName{get;set;}

 

i am getting the value of userName as 'Vishal Thoriya'

 

but my problem is that how to pass it to my code like

 

rendered="{!(agenda.Committed__c== false && agenda.Employee__r.Name == !userNAme)}"

 

but this is giving me syntax error........

 

any suggestions for this kind of problem....

 

any kind of help will be appriciated..............

 

Thanks in Advance 

 

 

Vishal Thoriya

 

Best Answer chosen by Admin (Salesforce Developers) 
Vishal_ThoriyaVishal_Thoriya
public String userName
    {
        get
        {
            userName = UserNameValue;
            return userName;
        }
        set
        {
            
        }
    }


and this is the userNameValue

public String UserNameValue = EngineeringSession.getUserName(sessionID);

 hello friends........

good news.......... there was small mistake in my code........

 

i have shown it above........

 

your idea worked thanks 

Chamil and Rahul For the help......

much much appriciated....

 

All Answers

Rahul SharmaRahul Sharma

Vishal,

When you use IF condition then you have to use == as operator,

but if you dont use a If statement then you have to use sungle ('=') sign,

Try changing your code from:

<apex:outputLabel rendered="{!(agenda.Committed__c == false && agenda.Employee__r.Name == 'Vishal Thoriya' )}" >

to

<apex:outputLabel rendered="{!(agenda.Committed__c = false && agenda.Employee__r.Name = 'Vishal Thoriya' )}" >



Vishal_ThoriyaVishal_Thoriya

thanks for the help buddy

 

but i want to pass the userName value but 

 

with 'Vishal Thoriya' code works well......

Chamil MadusankaChamil Madusanka

 

Use following

 

rendered="{!(agenda.Committed__c== false && agenda.Employee__r.Name == userNAme)}"

 

instead of

 

rendered="{!(agenda.Committed__c== false && agenda.Employee__r.Name == ! userNAme)}"

 

If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.

Rahul SharmaRahul Sharma

oops, i didn't read your whole post,

Try this:

rendered="{!(agenda.Committed__c== false && agenda.Employee__r.Name != userNAme)}"

Vishal_ThoriyaVishal_Thoriya
public String userName
    {
        get
        {
            return userName;
        }
        set
        {
            userName = UserNameValue;
        }
    }


and this is the userNameValue

public String UserNameValue = EngineeringSession.getUserName(sessionID);

 your ideas are not working guys 

suggest me something else

 

thanks for the help

Vishal_ThoriyaVishal_Thoriya
public String userName
    {
        get
        {
            userName = UserNameValue;
            return userName;
        }
        set
        {
            
        }
    }


and this is the userNameValue

public String UserNameValue = EngineeringSession.getUserName(sessionID);

 hello friends........

good news.......... there was small mistake in my code........

 

i have shown it above........

 

your idea worked thanks 

Chamil and Rahul For the help......

much much appriciated....

 

This was selected as the best answer