2011-02-18 1 views
-1

이 페이지는 newwindow에서 열립니다. 하나의 텍스트 상자와 두 개의 단추가 있습니다 (h : commandbutton 및 a4j : commandButton).기본 동작 방지

커서 포커스를 텍스트 필드로 이동 (설정)합니다.

내 문제는 텍스트 필드에서 입력 버튼을 누르면 자동으로 h : comandButton 작업이 호출되고 새 창이 닫힙니다. 이것을 피하는 방법.

하지만, 내가 버튼을 입력 A4J 커서의 포커스를 이동 쳤을 때 내가 필요 : 내가 textfiled에서 버튼을 입력 치면있는 명령

<f:view> 
<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <script type="text/javascript"> 

      function a4jButtonClick() 
      { 
       alert("A4J Command Buton clicked..."); 
      } 
     </script> 

    </head> 
    <body> 
     <h:form id="sampleForm"> 
      <rich:panel id="samplePanel"> 

      <h:outputText value="User Name : "/> 
      <h:inputText/> 

      <h:commandButton value="Closing-CommandButton" 
          onclick="javascript:window.close();return false;"/> 

      <a4j:commandButton value="A4JCommandButton" onclick="a4jButtonClick()"/>      

      </rich:panel> 
     </h:form> 
    </body> 
</html> 
</f:view> 

, 난 "(A4J를 스크립트 경고를 호출 할 Command Buton 클릭 ... ");

도와주세요. 감사합니다.

답변

1

봅니다 온 클릭 핸들러에서 false를 반환를 추가합니다 :

<h:commandButton value="HCommandButton" onclick="hButtonClick();return false;"/> 
<a4j:commandButton value="A4JCommandButton" onclick="a4jButtonClick();return false;"/> 

그러나 당신이 버튼을 누르면 다음 양식이 제출되지 않습니다.

+0

답변 해 주셔서 감사합니다. 이제 내 질문을 업데이트합니다. 나는 false를 반환합니다. 사건이 창문이 닫히고 있습니다. – Eswar

+0

물론 닫히기 전에 window.close()가 호출됩니다. false –

+0

ok. 먼저 onclick "return false; javascript : window.close();"를 사용합니다. 하지만 수동으로 "Closing-CommandButton"을 클릭하면 새 창이 닫히지 않습니다. – Eswar

0

키보드의 Enter/Return 키를 누르면 의 첫 번째 단추이 활성화됩니다. 디자인하지 않는, 그래서 당신은 여전히 ​​원래의 순서로 그들에게 스타일을 지정할 수 있습니다

<a4j:commandButton value="A4JCommandButton" onclick="a4jButtonClick()"/> 
<h:commandButton value="Closing-CommandButton" onclick="javascript:window.close();return false;"/> 

곰을 마음에 :

그래서 당신은이에 마크 업에서 버튼의 순서를 변경해야 변화.