开发者

How to pass Hidden field Value from html page to GWT page ? both page in different application

How do I pass a hidden field value from one application(html) page to GWT page? Access them in destination i.e. GWT PAGE , both pages in different application

My html page contains a hidden field value. I want to transfer that hidden field value in to another page(GWT page) which is located in http://localhost:8080/gwtApp so that GWT page can access that hidden field .

Description: Hidden fields present in html page, in that page when I click button "send" then page redirec开发者_如何学Goted to different app (GWT app : http://localhost:8080/gwtApp). Call made to GWT app. Now I want to access that hidden fields present in 1st html page.

I tried DOM.getElementById("myID")).getValue() and got Unable to get hidden field

I am stuck in this issue.

  • Any servlet needed in between these pages to access hidden fields ?

  • Is there any way to access hidden field in child page(GWT page) from parent page (html) ?

  • Is there any relation between both pages html and GWT page(basically html) ? parent-child ?

Any help or guidance in this matter would be appreciated.


Just send hidden fields from html page 1 to server servlet and wrapped this hidden field in some JSONP format and send this JSONP formated string to html page2 and implement JSONP on html page2 as per the function defined in JSONP


Hidden fields are used in html forms and their value is added to POST request when submitting to server.

So, your page1 can have a form with hidden field that POSTs to server2. Server2 will then be able to send this "hidden" data to browser, via custom html attribute, cookie or any other way.

Please note that all this data is plain text and user can see it - all data sent from server to browser could be seen by user. There is no way around it.


Using Iframe we can solve this problem

1] Add destination html file in source html file using iframe.

<FORM name='formName' method='post' action='YourServlet'>    
<input id="hiddenId" type=hidden    name="hiddenId" value="">
<IFRAME  id="iframeId" name="desthtml"  src="http://localhost:8080/gwtApp/GWTRedirect.html" 
 width="100%" height="100%" style="padding-top: 10px" 
 frameborder="0" scrolling="no">                     
</IFRAME>
<FORM >

2] In Your servlet read your html using

org.enhydra.xml.xmlc.XMLObjectImpl doc = getXmlcPage(String htmlFileName);
Element hiddenElement = doc.getElementById("hiddenId");
        hiddenElement.setAttribute("value",1234));

3] access hidden fields on GWTRedirect.html using

<INPUT TYPE='hidden' value='' id='hiddenId' name='hiddenId'> 
<SCRIPT type="text/javascript" language="javascript">
document.getElementById("hiddenId").value =  window.parent.document.getElementById("hiddenId");
</SCRIPT>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜