2012-08-24 56 views
0

我有一个树登录页面作为我在调查中的第一页。问题是,如果用户没有选择任何节点并点击下一个按钮,他将被重定向到同一页面。问题是他没有收到任何错误消息。在树登录页面中不显示错误消息

我希望用户收到一条错误消息“请选择一组” 请看下面的代码做这个动作

(PS检查显示()函数)

纠正我在哪里我出错了

<?php 
/** 
* File: TreeLoginWidget.php 
* 
* 
* Purpose: display tree page. 
* 
* Dependents: none 
* 
* Dependencies: SurveyItem 
* 
* Classes: 
* 1. PinWidget 
* 
* Interface/public functions: 
* 
* Notes: ??? 
* 
* Todo: none 
* 
**/ 

class DisplayTreeLoginWidget extends DisplayItem 
{ 

    function DisplayTreeLoginWidget(& $sourceObj) 
    { 
     // debug 
     if($pDebugTraceFlag == _ID_FLAG_ON) GDebugTraceFunc(__CLASS__." :: ".__FUNCTION__); 
     $this->node = 0; 
     $surveywidget = getDataFromSession("surveywidget"); 
     DisplayItem::DisplayItem(); 
     $_SESSION["profile"]["rootNode"]=0; 
     if($_GET["nodeId"]) { 
      setDataToSession("postVar",""); 
     } 
     $this->sourceObj =& $sourceObj; 
    } 

    /** 
    * Purpose: display pin page label text 
    * 
    * Input Params: none 
    * 
    * Output Params: none 
    * 
    * Return Value: none 
    * 
    * Notes: 
    */ 

    function display() 
    { 
     global $skin_path,$skin,$path; 
     setDataToSession("skipPage", 0); 
     setDataToSession('HideSave&Resume',0); 
     $currentPageNumber = currentPageNumber(); 
     if($currentPageNumber!=1) { 
      setDataToSession('HideSave&Resume',1); 
     } 

     echo "<script type=\"text/javascript\" src=\"".$path."../lib/java/commonFuncs.js\"></script>"; 

     // include the header 
     include_once ("../lib/include/path.inc.php"); 
     include_once ("../lib/include/jshelper.php"); 
     include_once("display/tree.inc.php"); 
     include_once("display/commonTreeLayout.php"); 
     include_once ("../lib/include/commonTreeCode.php"); 

     setUpTreeAppProperty(); 
     $postVar = getDataFromSession("postVar"); 

     if(is_array($postVar)) { 
      $_POST = $postVar; 
     } 

     if($this->sourceObj->displayType == "expanded") { 
      $postVar["Expand_All"] = "Expand All"; 
      $this->sourceObj->displayType = ""; 
     } 
     if($this->sourceObj->levelShowing != "") { 
      setDataToSession("levelShowing",$this->sourceObj->levelShowing); 
     } 

     setUpElist($postVar, $_GET); 
     $verifiedStartingNode = getTreeStartingNode(); 

     /** $matchedIdArr contains matched nodeIds or empty if no matches found/no search performed */ 
     $matchedIdArr = doSearch($verifiedStartingNode, $postVar); 
     $eList = getEList(); 

     $Tree = new TreeWithRadioButton($this->sourceObj); 

     $Tree->reSetupElist(); 

     $startingNode = &$Tree->nodesArr[$verifiedStartingNode]; 
     echo "<div class=\"body2 IE6trans\">"; 

     displaySearchTable(); 

     if(!$postVar["searchSubmit"]) { 
      $matchedIdArr = array(getDataFromSession("data,node_id")); 
     } 

     displayTree('Search Organization Structure', '', '', $startingNode, $eList, $matchedIdArr, $maxDepth, get_path_prefix(),$this->sourceObj->_errorMsg,$this->sourceObj->_prompt); 

     echo "<script type=\"text/javascript\">"; 
     echo "$(document).ready(function() { $('input[name=\"wildText\"]').keyup(function(event){ if(event.keyCode == 13){ $('input[name=\"searchSubmit\"]').click(); } }); });"; 
     echo "</script>"; 

     echo "</div>"; 
    } 

    /** 
    * Purpose: storing error message to _errorMsg 
    * 
    * Input Params: none 
    * 
    * Output Params: none 
    * 
    * Return Value: Boolean - true or false 
    * 
    * Notes: 
    */ 

    function validate() 
    { 
     // debug 
     if($pDebugTraceFlag == _ID_FLAG_ON) GDebugTraceFunc(__CLASS__." :: ".__FUNCTION__);  
     $surveywidget = getDataFromSession('surveywidget'); 
     $this->getPostData(); 
     $this->sourceObj->_errorMsg = ""; 
     $lastVisitedWidgetOid_Tree = getDataFromSession("lastVisitedWidgetOid_Tree");  
     setDataToSession("lastVisitedWidgetOid" , $lastVisitedWidgetOid_Tree); 

     setLoginUserLanguage($this->node); 

     $operations = ((strcmp($this->operation,getText2($surveywidget->saveResumeButtonText)) == 0)|| 
            (strcmp($this->operation,getText2($surveywidget->backButtonText)) == 0)|| 
            (strcmp($this->operation,getText2($surveywidget->nextButtonText)) == 0)); 

     if(($operations) && ($this->node != "")) { 
      setDataToSession("data,node_id",$this->node); 

      // used to track the node id assigned to this pin when more than one login is used 
      setDataToSession("tree_login,node_id",$this->node); 
      setDataToSession("tree_login_before_saveresume,node_id",$this->node); 


      //Custom - 
      $oids = getListOfOidAndNodes(Array($this->node)); 
      $_SESSION["conditionNodeList"] = $oids; 
      //End Custom 

      if(!getDataFromSession('multiLoginIndex')) { 
       $multiLoginIndex = 1; 
      } else { 
       $multiLoginIndex = getDataFromSession('multiLoginIndex'); 
      } 
      $multiLoginIndex++; 
      setDataToSession("multiLoginIndex",$multiLoginIndex); 

      $this->sourceObj->_errorMsg = ""; 
     } else if(($operations) && ($this->node == "")){ 
      $this->sourceObj->_errorMsg = "Please select a group"; 
      return false; 
     } else { 
      return false; 
     } 

     if($this->node == "") { 
      $this->node = 0; 
     } 
     // user click save&resume before visiting login page, we are redirecting to login page, That time user enter invalid node_id we are mainting save&resume flag to 1 for displaying submitbutton(it act like as save&resume) 
     if(getDataFromSession('save&resumeflag') == 1) { 
      setDataToSession('save&resumeloginpage',1); 
     } 

     return true; 
    } 

    /** 
    * Purpose: get post data 
    * 
    * Input Params: none 
    * 
    * Output Params: none 
    * 
    * Return Value: none 
    * 
    * Notes: 
    */ 

    function getPostData() 
    { 
     // debug 
     if($pDebugTraceFlag == _ID_FLAG_ON) GDebugTraceFunc(__CLASS__." :: ".__FUNCTION__); 
     $postVar["exactText"] = (empty($_REQUEST["exactText"])==1) ?""  :stripslashes($_REQUEST["exactText"]); 
     $postVar["wildText"] =  (empty($_REQUEST["wildText"])==1)  ?""  :stripslashes($_REQUEST["wildText"]); 
     $postVar["searchSubmit"] = (empty($_REQUEST["searchSubmit"])==1) ?""  :$_REQUEST["searchSubmit"]; 
     $postVar["Collapse_All"] = (empty($_REQUEST["Collapse_All"])==1) ?""  :$_REQUEST["Collapse_All"]; 
     $postVar["idText"] =  (empty($_REQUEST["idText"])==1)  ?""  :$_REQUEST["idText"]; 
     $postVar["node"] =   (empty($_REQUEST["node"])==1)   ?""  :$_REQUEST["node"]; 
     $this->node =    ($_REQUEST["node"] == "")    ?""  :$_REQUEST["node"]; 
     $this->operation =   (empty($_REQUEST["Operation"])==1) ?""  :$_REQUEST["Operation"]; 

     if($postVar["Collapse_All"]) { 
      $postVar["wildText"] = ""; 
     } 

     setDataToSession('postVar',$postVar); 
     setDataToSession('Operation',$this->operation); 
     setDataToSession('node',$this->node); 
    } 

} 
?> 

回答

0

你的代码很长,我没看过。

但是,执行此操作的典型方法是传递url参数,并且如果该参数存在,则将其作为消息打印出来。

+0

我在Display()中做了一个愚蠢的错误,不幸的是不知道在哪里。 – Justin

+0

@Justin对不起,我对你正在使用的课程一无所知。 – Ariel

相关问题