You need to sign in to do that
Don't have an account?
shiv
the commandButton tag is not calling the my Apex function : : any help plz..
Hello can anybody find the error behind my code for why the commandButton's action attribute is not calling the Apex function??
I am actually trying to get a valid Account ID from user(in the first outputPanel). If its a valid one, it should display the corresponding Account's details in the same(second outputPanel) page (with just few properties). And if it is an invalid one, it has to show the error Text.
VF code:
<apex:page controller="ApexPopups" tabStyle="Account">
<apex:sectionHeader title="Accounts" subtitle="Home"/>
<apex:outputPanel id="out1">
<apex:form id="form1">
<apex:pageBlock title="Get Account Details">
<apex:outputText>Enter the Account Id</apex:outputText>
<apex:inputText id="accid" value="{!id1}" style="width:130px;font-size:12px;"/>
<apex:outputText value="{!dispText}" style="font-color:red;font-weight:bold;"/> <br/><br/>
<apex:commandButton action="{!checkId}" value="Fetch Account Details" rerender="out1,out2"/><br/>
</apex:pageBlock>
</apex:form>
</apex:outputPanel>
<apex:sectionHeader title="Accounts" subtitle="Home"/>
<apex:outputPanel id="out1">
<apex:form id="form1">
<apex:pageBlock title="Get Account Details">
<apex:outputText>Enter the Account Id</apex:outputText>
<apex:inputText id="accid" value="{!id1}" style="width:130px;font-size:12px;"/>
<apex:outputText value="{!dispText}" style="font-color:red;font-weight:bold;"/> <br/><br/>
<apex:commandButton action="{!checkId}" value="Fetch Account Details" rerender="out1,out2"/><br/>
</apex:pageBlock>
</apex:form>
</apex:outputPanel>
<apex:outputPanel id="out2" rendered="{!isrendered}">
<apex:form id="form2">
<apex:pageBlock title="Account Details">
<apex:pageBlockTable value="{!acc}" var="ac">
<apex:outputLabel value="{!ac.name}"/>
<apex:outputField value="{!ac.phone}"/>
<apex:outputField value="{!ac.billingCity}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:outputPanel>
</apex:page>
<apex:form id="form2">
<apex:pageBlock title="Account Details">
<apex:pageBlockTable value="{!acc}" var="ac">
<apex:outputLabel value="{!ac.name}"/>
<apex:outputField value="{!ac.phone}"/>
<apex:outputField value="{!ac.billingCity}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:outputPanel>
</apex:page>
Apex code:
public class ApexPopups {
Boolean isrendered=false;
Account acc;
Id id1;
String dispText='';
public String getDispText() {
return dispText;
}
Boolean isrendered=false;
Account acc;
Id id1;
String dispText='';
public String getDispText() {
return dispText;
}
public void setDispText(String ab){
dispText=ab;
}
public boolean getIsrendered() {
return isrendered;
}
dispText=ab;
}
public boolean getIsrendered() {
return isrendered;
}
public void setIsrendered(Boolean ab){
isrendered=ab;
}
public void checkId(){
acc=[select id,name,phone,billingCity from Account where id =: id1];
if(acc!=null){
isrendered=true;
dispText='';
}
else{
dispText='Invalid Id. Please Enter a Valid Id';
isrendered=false;
}
}
public Account getAcc() {
return acc;
}
isrendered=ab;
}
public void checkId(){
acc=[select id,name,phone,billingCity from Account where id =: id1];
if(acc!=null){
isrendered=true;
dispText='';
}
else{
dispText='Invalid Id. Please Enter a Valid Id';
isrendered=false;
}
}
public Account getAcc() {
return acc;
}
public void setAcc(Account a){
acc=a;
}
acc=a;
}
public Id getId1(){
return Id1;
}
public void setId1(Id a){
id1=a;
}
return Id1;
}
public void setId1(Id a){
id1=a;
}
}
public void checkId(){
should be
public PageReference checkId(){
and return a page reference or null
Check out the docs on action methods and navigation.
Suggest that you put a system.debug() message into your action method to verify that it is being called.
Message Edited by Ron Hess on 12-16-2008 07:05 AM