Reputation: 1261
I am working on button.
My component code is as follows.
<apex:commandButton action="{!sendAction}"
value="SEND" styleClass="Button" rerender="messageId" immediate="true"/>
<apex:outputpanel rendered="{!showmsg}" id="messageId">
<apex:outputtext value="{!outputMessage}" style="color:red;font-size:13px;font-weight:bold;"/>
<br />
</apex:outputpanel>
My controller code is as follows.
public PageReference sendAction()
{
showmsg=true;
outputMessage='working';
return null;
}
But my action method sendAction is not getting called. When I open my page containing in new window , function is getting called. But in same window it is not getting called.
Any help is really appreciate.
Upvotes: 2
Views: 4432
Reputation: 121
You can try the following approaches in the case when your<apex:commandButton>
or <apex:commandLink>
doesn't seem to call the apex controller method.
Try setting the attribute immediate = true
for these two. That works in some cases.
Try calling the apex controller method using the <apex:actionFunction>
.
If somehow you're still unable to call the apex controller method using the <apex:actionFunction>
, refer to this link.
Upvotes: 0
Reputation: 1231
If, as Matthew already hinted your controller is refered by your page or component I believe it may be caused by the showmsg variable.
If the messageId outputpanel is not renderd because showMsg is initially false, it will also not rerender, and thereby not display your message. If i'm right, the following would make more sense, and fix your problem.
<apex:outputpanel id="messageId">
<apex:outputtext rendered="{!showmsg}" value="{!outputMessage}" style="color:red;font-size:13px;font-weight:bold;"/>
<br />
</apex:outputpanel>
Upvotes: 2