不从struts2调用Action-class方法

时间:2013-05-07 13:38:26

标签: java struts2

这是一个非常奇怪的错误,但我一直在努力这一周。 我有一个在Jboss4上运行良好的Web应用程序但是当我将它移动到Jboss6时,所有的地狱都崩溃了。 查看以下代码

的List.jsp

<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<%@ taglib prefix="display" uri="http://displaytag.sf.net" %>
<s:if test="payments != null">
  <div id="payManuallyDialog" class="defaultDialog" style="height: 150px; width: 300px;">
   <s:form onsubmit="return false;" action="PayManually" namespace="/authorized/payments" name="PayManuallyForm" id="PayManuallyForm" cssStyle="height: 100%;">
     <s:url id="payManuallyURL" action="PayManually" namespace="/authorized/payments" />
     <sx:div id="PayManuallyPanel" cssStyle="height: 100%;" formId="PayManuallyForm" formFilter="filterFields" href="%{payManuallyURL}" theme="ajax" listenTopics="view_pay" showLoadingText="false">
     </sx:div>
     <s:hidden key="paymentID" value="" />
     <s:hidden key="command" value="" />
   </s:form>
  </div>
</s:if>

顶部有一个javascript函数

function filterFields(field) {
   return field.name == "paymentID" || field.name == "command" || field.name == "payDate";
}
function pay(id) {
   document.PayManuallyForm.paymentID.value = id;
   document.PayManuallyForm.command.value = "view";
   dojo.event.topic.publish("view_pay");
   openModalDialog("payManuallyDialog");
   document.PayManuallyForm.command.focus();
}
function cancel() {
   document.PayManuallyForm.paymentID.value = "";
   document.PayManuallyForm.command.value = "";
   closeModalDialog("payManuallyDialog");
}
function save(id) {
   document.PayManuallyForm.paymentID.value = id;
   document.PayManuallyForm.command.value = "save";
   dojo.event.topic.publish("view_pay");
   closeModalDialog("payManuallyDialog");
}

payManually.jsp

<%@ taglib prefix="s" uri="/struts-tags" %>
<div class="dialogWrapper">
   <div class="dialogTitle">
      <s:text name="label.header" />:&nbsp;<s:text name="pay.paymentID" />&nbsp;<s:property value="ID" />
   </div>
   <div class="dialogContent">
      <s:date name="payDate" id="payDateId" format="yyyy-MM-dd"/>
      <s:text name="payman.date" />&nbsp;<s:textfield name="payDate" value="%{payDateId}" />
   </div>
</div>
<div class="dialogFooter">
   <a class="tableLink" href="javascript: save(<s:property value='ID'/>);"><img border="0" src="/gfx/active.gif" />&nbsp;<s:text name="label.save" /></a>
   &nbsp;<a class="tableLink" href="javascript: cancel();"><img border="0" src="/gfx/inactive.gif" />&nbsp;<s:text name="label.cancel" /></a>
</div>

我的struts.xml

<action name="PayManually" class="paymentActions" method="payManually">
   <result name="input">/WEB-INF/authorized/payments/payManually.jsp</result>
   <result name="success">/WEB-INF/authorized/payments/payManually.jsp</result>
   <result name="error" type="tiles">**error-page**</result>
</action>

我的动作类

@TransactionAttribute(TransactionAttributeType.REQUIRED)
public String payManually() {
    System.out.println("Command == "+command);
    try {
        if (logger.isInfoEnabled()) {
            logger.info("payManually called with paymentID" + paymentID + ", command=" + command + ", payDate=" + payDate);
        }
        if (paymentID != null && command != null) {
            if (command.equals("view")) {
**** Do some things ****
            } else if (command.equals("save") && payDate != null) {
**** Do some things ****
    } catch (ServerException serverException) {
        serverException.printStackTrace();
        addActionError(serverException.getMessage());
    }
    return (!hasActionErrors()) ? SUCCESS : ERROR;
}

我拥有所有吸气剂和制定者。

如您所见,我在我的javascript代码中设置了命令变量。这适用于pay(id)函数,设置了命令并设置了id。当我按下payManually.jsp页面中的保存按钮时,调用javascript函数save(id)并设置所有变量,但不调用我的actionclass方法!

我的日志显示以下行

  

2013-05-07 15:31:17:462 [http-0.0.0.0-8080-1] INFO actions.payments.PaymentActions - payManually - payManually with paymentIDnull,command =,payDate = null

     

2013-05-07 15:31:17:462 [http-0.0.0.0-8080-1] INFO actions.payments.PaymentActions - payManually - payManually with paymentIDnull,command =,payDate = null

     

2013-05-07 15:31:20:103 [http-0.0.0.0-8080-1] INFO actions.payments.PaymentActions - payManually - payManually with paymentID2846,command = view,payDate = null

     

2013-05-07 15:31:20:103 [http-0.0.0.0-8080-1] INFO actions.payments.PaymentActions - payManually - payManually with paymentID2846,command = view,payDate = null

我做错了什么?

请帮助我,因为我真的被卡住了,谷歌没有太多帮助

如果您需要更多信息,请与我们联系。

0 个答案:

没有答案