简体   繁体   English

单击按钮时如何更新html / jsp页面的特定部分?

[英]How to update a specific section of html/jsp page on click of button?

i has been stuck at a point. 我被困在一个点上。 I will try to explain my problem in the simple way- 我将尝试以简单的方式解释我的问题-
This is my jsp page - 这是我的jsp页面-

在此处输入图片说明

This is my jsp code - 这是我的jsp代码-

    <%@page import="org.w3c.dom.Document"%>
    <%@page import="com.Search.Struts2.DataEnterActionClass"%>
    <%@ page contentType="text/html; charset=UTF-8" %>
    <%@ page import="javax.servlet.http.HttpServletResponse"%>
    <%-- <%@ page import="com.Search.Struts2.AccessCheckComponent"%> --%>
    <jsp:include page="SessionCheckout.jsp"></jsp:include>

    <html>
    <head>
    <%
    response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
    response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
    response.setDateHeader("Expires", 0); // Proxies.
    response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
    %>

     <div id="nav" style="width:150px; float:left;">
    <table>
     <% 

          String StrParentObjectName = "";
          StrParentObjectName =  (String) DataEnterActionClass.getDocumentName(strObjectId)  ;           
        String hidingRowL1 = HidingRows(strObjectId, ConnectedData, "L1"); 
        String StrGlobal3dXML = (String) DataEnterActionClass.getFile(strObjectId);      
          %>
                <tr>
         <td width="25px"><b><a style="text-decoration: none;"
            href="javascript:toggle_visibility('tbl1', '<%=strObjectId.toString()%>' ,  '<%=true%>', '<%= hidingRowL1  %>');">
                        <div id="<%=strObjectId + "plus"  %>" name="lnk1">+</div>   </a></b></td>           
                    <td align="left"   style="font-size: 120%;">
 <a onclick="Here i will have to set value for param tag using javascript">
             <%=StrParentObjectName%> </a>  
     </td>    
                    </tr>   
               <% 


                        if(ConnectedData.keySet().contains(strObjectId))
                            {  
                            ArrayList   childList = (ArrayList) ConnectedData.get(strObjectId);
                            Collections.sort(childList);
                            for(int i=0; i<childList.size(); i++)   
                            {       
                        String childObjectId = (String) childList.get(i);
                String hidingRowL2 = HidingRows(childObjectId, MapAll5thLevelChild, "L2");   // 2
                        String prientedData = (String) DataEnterActionClass.getDocumentName(childObjectId)  ;   
                  String RowIdCreationL1 = strObjectId + childObjectId + "L1";   // 1
                 StrGlobal3dXML = (String) DataEnterActionClass.getFile(childObjectId)  ;      
                              %>
                            <tr id="<%= RowIdCreationL1 %>" > 
         <td><b><a style="text-decoration: none;"
            href="javascript:toggle_visibility('tbl1', '<%=childObjectId.toString()%>' ,  '<%=true%>', '<%= hidingRowL2  %>');">
                        <div id="<%=childObjectId + "plus"  %>" name="lnk1">+</div>   </a></b></td>     
                    <td align="left"  height="10" style="font-size: 90%;"> &nbsp;&nbsp; 
 <a onclick="Here i will have to set value for param tag using javascript">   
<%=prientedData%> </a> <sup>1</sup>  </td>
                    </tr>   
                    <script>
            window.onload =  VisibleFalse('<%=RowIdCreationL1%>');
                            </script>   

            <%
                                    }
                                }           
            %>
      </table>

    </div>


    <div id="section" style = "width:800px; height:700px; float:left;" >
    <object type='application/x-3dxmlplugin' id='3DXMLPluginId' style="width: 600px; height: 500px;">
    <!-- <param name='DocumentFile' value='D:\IETM\CheckedInFiles\Model\Compart_Two\watch.3dxml'>
     -->
     <param name='DocumentFile' id="fileId" value= " This i want to change dynamically ">
    </object>
    </div>

    </html>

Here simply I am using two div's one with id='nav' & other with id='section'. 在这里,我只是简单地使用两个div,一个ID ='nav',另一个ID ='section'。

In image if i click on Boat hyperlink(left side), then 3dxml image attached with boat should be displayed in right side. 在图像中,如果我单击Boat超链接(左侧),则随船附送的3dxml图像应显示在右侧。 For this i am calling javascript on boat hyperlink & try to update param tag value (like hard-coded) & that div 'section' too. 为此,我在船超链接上调用javascript,并尝试更新param标签值(如硬编码)以及该div的“ section”。 I am getting this value in java 'StrGlobal3dXML' string variable. 我在java'StrGlobal3dXML'字符串变量中获取此值。

I tried to achieve by so many ways, like by js, by ajax, but unsuccessful. 我尝试通过多种方式来实现,例如通过js,通过ajax实现,但均未成功。

This is very crucial for me. 这对我来说至关重要。 Any way to achieve this or any suggestion, hint will be very very helpful. 任何实现此建议或任何建议的方法,提示都会非常有帮助。 Please try to give the solution in javascript or any other way excepting jQuery. 请尝试使用javascript或jQuery以外的任何其他方式提供解决方案。 i don't know even abc of jQuery. 我什至不知道jQuery的abc。

Thank you !! 谢谢 !!

Finally I got the answer. 终于我得到了答案。

In the Ajax, You call your object tag like this - 在Ajax中,您可以这样调用对象标签-

  <object type='application/x-3dxmlplugin' id='3DXMLPluginId' style="width: 800px; height: 700px; ">
<param name='DocumentFile' value="\\10.60.3.47/IETM_CheckedInFiles/Model/Deck_One/watch.3dxml">
</object>

Now in TreeView.jsp - 现在在TreeView.jsp中-

function Print3dXML()
    {
        var xmlhttp;        
        if (window.XMLHttpRequest)
          {// code for IE7+, Firefox, Chrome, Opera, Safari
          xmlhttp=new XMLHttpRequest();
          }
        else
          {// code for IE6, IE5
          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
          }  

          xmlhttp.open("GET","IETMAjaxCall_getFile.jsp?q=",true);
          xmlhttp.send();        
        xmlhttp.onreadystatechange=function()
          {
          if (xmlhttp.readyState==4 && xmlhttp.status==200)
            {     
             document.getElementById("section").innerHTML = xmlhttp.responseText;
            }
          }

    }

I think , this may complete your requirement. 我认为,这可能会满足您的要求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM