is hibernate dao manipulation could affect struts 2 json return?
or spring framework could affect struts2 json return?
my program's struts2 json execution is success if not involve dao or spring 
call.
but if involve hibernate/spring/dao manipulation, then json return is null and 
not returned.
struts.xml<package name="default" extends="json-default">     ...     <action 
name="cart-del" class="CartAction" method="del">
                    <result name="json-data" type="json"></result>
                    
     </action>
</package>
Cart.jsp <sj:head jqueryui="true" jquerytheme="%{theme}" 
loadFromGoogle="%{google}" ajaxhistory="%{ajaxhistory}" 
defaultIndicator="myDefaultIndicator"/>
 
 <%@ taglib prefix="s" uri="/struts-tags" %>
 <%@ taglib prefix="sj" uri="/struts-jquery-tags"%> <script 
type="text/javascript">
    function delItem(sn) {
                alert("here10, sn="+sn);
                $.post('cart-del.action', {partid: sn}, function(data) {
                        alert("here20, data.deleted="+data.deleted);
                        if (data.deleted) {
                                alert("here30 - deleted");
                                $('#tr_' + sn).remove();
                                }                               }
                        else
                                alert("here40 - not delete");
                });
        }
</scipt><s:iterator value="#session.cartitems">
   <tr id="tr_${j_part_id}">
       <td><input type="checkbox" onclick="delItem('${j_part_id }')" /></td>
       <td>${part.pid}<input type="hidden" name="partids" value="${j_part_id}" 
/>>/td>
   </tr>
</s:iterator>
CartAction.java
  public class AcctAction extends ActionSupport {
     private String partid;
     private boolean deleted;
     public void setPartid(String partid) { this.partid=partid.trim(); }
     public String getPartid() { return partid; }
     public boolean getDeleted() { return deleted; }     public String del() 
throws Exception {
              /* problem is: 
                  if enable following business dao logic to delete item from 
database, the item is deleted, 
                  and this is proved from querying database, 
                  but deleted variable always 'not delete in the Cart.jsp alert 
statement.
                  without business logic, then deleted can always return true;  
           
                
              */
              /* 
               CartManagerImpl  cartmgr;
               cartmgr.dao_delete...
              */
               
              deleted=true;
              return "json-data";
     }
}
CartManagerImpl.javaimport org.apache.struts2.ServletActionContext;import 
org.springframework.web.context.WebApplicationContext;
import 
org.springframework.web.context.support.WebApplicationContextUtils;public class 
CartManagerImpl  {
    dao_delete ....
}

Reply via email to