未能使用单选按钮更改选项

时间:2013-09-17 07:41:35

标签: salesforce apex-code

<!--Visual force page code-->

<apex:page controller="prgrm9cls"><apex:form >
<apex:pageBlock >


<apex:pageblockSection >
<apex:selectRadio value="{!paymentstatus}" id="paymentstatus">
<apex:selectOption itemValue="Credit" itemLabel="credit card" ></apex:selectOption>
<apex:selectOption itemValue="Po" itemLabel="PO"></apex:selectOption>
<apex:selectOption itemValue="Invoice" itemLabel="Invoice"></apex:selectOption>
<apex:actionSupport event="onchange" reRender="opid2" action="{!act}"/></apex:selectRadio></apex:pageblockSection>



<apex:pageBlockSection >

<apex:outputPanel id="opid2">
<apex:pageBlockSection rendered="{!cardz}" columns="1">
<apex:pageblockSectionItem >
<apex:outputLabel value="Credit Card Name"></apex:outputLabel><apex:inputText value="{!creditname}"  />
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:outputLabel value="Credit CardNumber"></apex:outputLabel><apex:inputText value="{!CardNumber}" />
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:outputLabel value="CVV"></apex:outputLabel><apex:inputText value="{!CVV}" />
</apex:pageblockSectionItem></apex:pageBlockSection>

<apex:pageBlockSection rendered="{!invoicess}">
<apex:outputLabel value="Invoice"></apex:outputLabel><apex:inputText value="{!Invoice}" />
</apex:pageBlockSection>

<apex:pageBlockSection rendered="{!pozz}">
<apex:outputLabel value="Routing Number"></apex:outputLabel><apex:inputText value="{!porder}" required="true"/></apex:pageBlockSection></apex:outputPanel>

</apex:pageBlockSection>

</apex:pageBlock>

 </apex:form></apex:page>
public class prgrm9cls {

    public String CVV { get; set; }

    public Integer CardNumber { get; set; }

    public String creditname { get; set; }

    public String porder { get; set; }

    public boolean pozz { get; set; }
 public String paymentstatus { get; set; }
    public String Invoice { get; set; }

    public boolean invoicess { get; set; }

       public boolean cardz { get; set; }

    public PageReference act() {

       if(paymentstatus == 'Credit'){
       cardz = true;
       invoicess = false;
       pozz = false;
       }
       if(paymentstatus == 'Invoice'){
       cardz = false;
       invoicess =true;
       pozz = false;
       }
       if(paymentstatus == 'po'){
       cardz = false;
       invoicess =false;
       pozz = true;
       }

       return null;
       }



    }

当我点击其中一个收音机选项时,它应该显示它的相关文字。它只执行了前两次并且无法连续工作。

任何人都可以解释错误已经完成

提前致谢。

1 个答案:

答案 0 :(得分:0)

抱歉,我发现了错误。这是因为在面板中使用了“必需”选项。在“路由号码”

中删除了该选项
<apex:outputLabel value="Routing Number"></apex:outputLabel><apex:inputText value="{!porder}" required="true"/>

解决了这个问题。

谢谢, 拉温德拉, Salesforce Engineer。