+ Start a Discussion
bujjibujji 

Regarding Apex Message tab

Hi,

 

i have a field called "err"  which of type 'String' in controller if its value is null then i have to display some message in visual force page. If it is not null than no message has to be displayed.

 

How can we do it. I tried but i am not getting.

 

<apex:pageMessage summary="{!Err}" severity="warning" rendered="IF(ISBLANK({!Err}),true,false)" id="errID" />

 

It is urgent.

 

Thanks,

Bujji

Best Answer chosen by Admin (Salesforce Developers) 
Abhay AroraAbhay Arora

Hi ,

 

You can easily do this with rerenedred

 

<apex:form >
 <apex:pageBlock id="header">
<apex:pageMessage summary="hello this is message" severity="warning" rendered="{!lstCon.size>0}" id="errID" />
 </apex:pageBlock>
<apex:commandButton value="myBtn" reRender="header" action="{!populateData}"/>
 </apex:form>
</apex:page>

 

And your class

 

public with sharing class AllCasesCon {

    public PageReference populateData() {
       lstCon=[select id,firstname,lastname from contact limit 10000];
        return null;
    }

    public list<contact> lstCon{get;set;}
    public String AllCasess { get; set; }
    public user cuser{get;set;}
    public AllCasesCon(){
       lstCon=new list<Contact>();
    }
}

 

 

All Answers

vishal@forcevishal@force

Try this and let me know if it works :

 

 

<apex:pageMessage summary="{!Err}" severity="warning" rendered="{!AND(Err != Null, Err != '')}" id="errID" />

bujjibujji

Hi,

 

There is no true,false options. even though it is not working.

 

Bujji.

bujjibujji

Hi,

 

Please tell me suppose if i have a command button, if click the button than some page block section item has to display else it should not and intially it will be in disabled mode.

Is it possible.

 

Thanks,

Bujji

vishal@forcevishal@force

Are you rerendering the section you want to show and hide on click of the button? You need to re-render the sections in order for rendered to work if your data is changing from server side.

Abhay AroraAbhay Arora

Hi ,

 

You can easily do this with rerenedred

 

<apex:form >
 <apex:pageBlock id="header">
<apex:pageMessage summary="hello this is message" severity="warning" rendered="{!lstCon.size>0}" id="errID" />
 </apex:pageBlock>
<apex:commandButton value="myBtn" reRender="header" action="{!populateData}"/>
 </apex:form>
</apex:page>

 

And your class

 

public with sharing class AllCasesCon {

    public PageReference populateData() {
       lstCon=[select id,firstname,lastname from contact limit 10000];
        return null;
    }

    public list<contact> lstCon{get;set;}
    public String AllCasess { get; set; }
    public user cuser{get;set;}
    public AllCasesCon(){
       lstCon=new list<Contact>();
    }
}

 

 

This was selected as the best answer