Question

I want to know if I can change Apex VisualForce tag attributes from the controller.

Can i do something like this?:

tag:

 <apex:selectList id="Status" value="blah blah" multiselect="false" size="1">

in the controller:

if (inc.Status__c == 'Closed'){
    Status.Rendered = false
}

Hope that makes sense!

I am current doing this, which i think is a bit long winded and want to avoid:

tag

 <apex:selectList id="Status" value="blah blah" rendered="{!IncidentIsClosed}">

in the controller

   if (inc.Status__c == 'Closed'){
    IncidentIsClosed = false;
    }

    ....

    public Boolean getIncidentIsClosed() {
            return IncidentIsClosed;
        }

hope that helps!

Was it helpful?

Solution

Syntax for merge fields (stuff in {!...} brackets) is same as for validation rules, formula fields, workflow triggering conditions etc. So you can use functions like TODAY() as well as some more complex logic.

So I think that if "inc" object is visible on your page then something like

...rendered="{!not(inc.Status='Closed')}

should do the trick. If you use standard controller then replace "inc" with sObject name (like "Case").

OTHER TIPS

I came to Visualforce from a .NET environment where you could change the page from the controller (or by that means to create parts of the page from the controller), so I understand your question...

Unfortunately, you can't do the same in Visualforce.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top