簡體   English   中英

如何在Struts2磁貼中啟動jQuery模式彈出窗口?

[英]How to launch jquery modal popup in Struts2 tiles?

我正在開發購物車應用程序。 在我的申請中有客戶登記表。 我正在使用Struts2磁貼。 當客戶端單擊“注冊”按鈕時,我的應用程序將彈出一個jquery模型窗口。 在我的NewUser.java動作類中,重寫了ActionSupport類的validate()方法。 如果電子郵件字段為空,我該如何彈出帶有錯誤的注冊表格。

我的動作課:

@Override
public void validate() {
    if (customer.getEmail().equals("")) {
        addFieldError("email", "First Name is Required.");
    }
}


我的彈出窗口:

 <div id="register" class="modal hide fade" tabindex="-1"> <form action="CustomerAdd"> <label class="control-label" for="email">Email address</label> <div class="controls"> <s:textfield name="customer.email" cssClass="input-xlarge"/> </div> </form> </div> <a href="#register" class="btn btn-small" data-toggle="modal"> Register now &nbsp; <i class="icon-chevron-right"></i> </a> 


Struts2動作:

  <action name="CustomerAdd" class="com.shopping.op.customer.CustomerAdd"> <result name="success" type="tiles">success_customer</result> <result name="failed" type="tiles">failed_customer</result> <result name="not_available" type="tiles">user_already_added</result> <result name="input" type="tiles">validate_customer</result> </action> 


瓷磚定義:

 <definition name="validate_customer" extends="baselayout"> <put-attribute name="opr" value="/customer/customer.jsp"/> <put-attribute name="body" value="/login.jsp"/><!--This page has the Register button--> </definition> 


提前致謝!

在彈出窗口中,您需要添加actionerror標記以顯示錯誤。 像這樣,

<form action="CustomerAdd">
  <label class="control-label" for="email">Email address</label>
  <div class="controls">
    <s:textfield name="customer.email" cssClass="input-xlarge"/>
    <s:actionerror/>
  </div>  
</form>

我希望如果您正確地處理了驗證方法,您可能直到輸入電子郵件后才能提交。 您錯過的是在彈出窗口中顯示錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM