【问题标题】:parameter value null is redirected to url参数值 null 被重定向到 url
【发布时间】:2012-12-03 06:18:02
【问题描述】:

您好,我正在用代码编写一个简单的控制器类

public class OMTime1 {

    public String xx { get; set; }


  public PageReference continue1(){
    String url='/apex/OneMoreTime?id='+ApexPages.currentPage().getParameters().get('id')+'&process='+xx;
    PageReference page=new PageReference(url);
     page.setRedirect(true);
        return page;
    }
}

和一个带有代码的简单 VF 页面

<apex:page controller="OMTime1" >
  <!-- Begin Default Content REMOVE THIS -->

  <!-- End Default Content REMOVE THIS -->
  <apex:form >
   <apex:selectList id="chooseColor" value="{!xx}" size="1">
            <apex:selectOption itemValue="1" itemLabel="Terminate Resource"/>
            <apex:selectOption itemValue="2"
             itemLabel="Change Resource Position at Same Location"/>
            <apex:selectOption itemValue="3" itemLabel="Change Resource Position with in same Location "/>
            <apex:selectOption itemValue="4"  itemLabel="Change Resource Position to a Different Location"/>
        </apex:selectList>
               </apex:form>
               <apex:form >
             <apex:commandButton value="Continue" action="{!continue1}"    id="theButton"/>
</apex:form>
</apex:page>

当用户单击按钮名称作为继续页面时,我的任务将重定向到它的 url /apex/OneMoreTime?id=record_id&process=some_value some_value=1、2、3 或 4 但是当我点击按钮时,它会重定向到 /apex/OneMoreTime?id=record_id&process=null

为什么这个空值出现在参数中我想重定向一个与选择选项标签相关的值。请建议如何解决它

【问题讨论】:

    标签: salesforce apex-code visualforce


    【解决方案1】:

    简答:因为&lt;apex:commandButton&gt; 坏了;)

    最近我在 Salesforce 专用的 stackexchange 网站上发布了 2 个最常见的解决方法的说明:https://salesforce.stackexchange.com/questions/4937/command-button-vs-command-link

    使用&lt;apex:commandLink styleClass="btn"&gt;,它会在看起来几乎与按钮相同的情况下工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多