弹出拟态对话框步骤

来源:互联网 发布:嵌入式软件开发团队 编辑:程序博客网 时间:2024/05/17 07:18

一、jsp页面

//添加预警信息
 function doAdd() {
 
  var url="${base}/alarm/doAdd.shtml?time="+new Date();
  var str=window.showModalDialog(url,"","location:No;status:No;help:No;dialogWidth:900px;dialogHeight:270px;");
  if("Y"==str){
   onClickQuery();
  }
 }

二、java后台

//**
  * 初始化增加
  * @return
  * @throws Exception
  */
 @Action(value = "/alarm/doAdd", results = { @Result(name = "doAdd", location = "/WEB-INF/pages/alarm/alarm_add.jsp") })
 public String doAdd()throws Exception{
  frameInit();//初始化下拉框
  return "doAdd";
 }

 

/**
  * 绕过Template,直接输出内容的简便函�?
  */
 protected void render(String text, String contentType) {
  try {
   HttpServletResponse response = ServletActionContext.getResponse();
   response.setContentType(contentType);
   response.getWriter().write(text);
  } catch (IOException e) {
   logger.error(e.getMessage(), e);
  }
 }

 /**
  * 直接输出字符�?
  */
 protected void renderText(String text) {
  render(text, "text/plain;charset=UTF-8");
 }

 

三、对话框页面

//添加预警信息
 function addAlarm() {
  if(!checkElemment()){
   return;
  }
  if (confirm("确定新增该预警么?")) {
   $.ajax({
    url:"${base}/alarm/addAlarm.shtml",
    data:$("#form1").serialize(),
    async:false,
    type: "post",
    cache : false,
    success:function(data){
     if("Y" != data){
      alert("新增失败!");
     }else{
      alert("新增成功");
      window.returnValue=data;
      window.close();
     }
    }
   });
  }
 }

 

 

附:截取字符串

<td title="${department12315.departmentName }">
          <s:if test="department12315.departmentName.length() > 10" >
           <s:property value="department12315.departmentName.substring(0,10).concat(\"...\")"/>
          </s:if>
          <s:else>
           <s:property value="department12315.departmentName"/>
          </s:else>
          <s:hidden value="department12315.id"></s:hidden>
       </td>

0 0
原创粉丝点击