Hoping someone can help. I have built a simple GWT app and would like
to pass some parameters into the app depending on which HTML page I am
including the GWT app on. So for example below I have two pages that
call the same GWT app and on the first page I would like to pass one
value and on the other a different value.
Is this possible? Any direction on this would be great.
Cheers,
Alan.
- indexA.html
<html>
<head>
<title>Wrapper HTML for Slicr</title>
<meta name='gwt:module' content='my.gwt.app.MyApp'>
</head>
<body>
<script language="javascript" src="gwt.js"></script>
<iframe id="__gwt_historyFrame" style="width:0;height:0;border:
0"></iframe>
<h1>My App -A</h1>
<div id="slot1"></div>
</body>
</html>
- indexB.html
<html>
<head>
<title>Wrapper HTML for Slicr</title>
<meta name='gwt:module' content='my.gwt.app.MyApp'>
</head>
<body>
<script language="javascript" src="gwt.js"></script>
<iframe id="__gwt_historyFrame" style="width:0;height:0;border:
0"></iframe>
<h1>My App -B</h1>
<div id="slot1"></div>
</body>
</html>
Ensure that each host page contains a hidden div element with an id
and the arbitrary text value, like that:
<div id="page.params" style="visibility: hidden;" >Hello</div>
And then in your code, use something along these lines:
RootPanel params = RootPanel.get("page.params");
if (params != null) {
String value = Dom.getInnerText(params);
...
}
Regards,
Kostis
Much appreciated.
:-D
On May 22, 3:05 pm, "Nikolas Everett" <nik9...@gmail.com> wrote:
> I haven't really thought about using a hidden <input> instead of a <div>. I
> guess <div> just seemed an easier target for abuse.
>
> --Nik
>
> On 22/05/07, Rob Coops <rco...@gmail.com> wrote:
>
>
>
> > Just a silly question but why a <div>? Why not use a <input type="hiden">
> > for this? as long as it is not part of a form it will not get submitted
> > anywhere and it is in my opinion a nicer solution then just abusing a <div>
> > tag for this.
>
You can create your own meta tags and read those. e.g:
<meta name="myproject:config" content="something you parse with GWT">
you would parse this by using DOM.getElementsByTagName. Or if that
method doesn't exist, some JSNI magic (loop through each entity given
by document.getElementsByTagName("meta"))
On May 22, 3:45 pm, "Rob Coops" <rco...@gmail.com> wrote:
> Just a silly question but why a <div>? Why not use a <input type="hiden">
> for this? as long as it is not part of a form it will not get submitted
> anywhere and it is in my opinion a nicer solution then just abusing a <div>
> tag for this.
>
I choose it, because for me, it is more difficult to think of using
<input> elements outside <form> elements.
Anyway, i believe your are more appropriately to judge it, since i
have a more java-centric background.
Kostis
On May 22, 4:45 pm, "Rob Coops" <rco...@gmail.com> wrote:
> Just a silly question but why a <div>? Why not use a <input type="hiden">
> for this? as long as it is not part of a form it will not get submitted
> anywhere and it is in my opinion a nicer solution then just abusing a <div>
> tag for this.
>
On May 22, 7:07 am, "al.hi...@gmail.com" <al.hi...@gmail.com> wrote: