I’m trying to get this to work, in a Wicket renderHead-method the parameter IHeaderResponse response is passing a javascript, to show respectively hide links in the calling parent page.
This is a part of a mobile web app served via an Apache Tomcat server.
StartPage.html, (the calling parent page, where the links to be hidden/shown is)
<li class="ui-block-e">
<a wicket:id="logoutlink" id="logout" href="#" data-theme="a" class="ui-btn-corner- all ui-btn ui-btn-up-a ui-btn-icon-top">
<span class="ui-btn-inner ui-btn-corner-all">
<span class="ui-btn-text">Logga ut</span>
<span class="ui-icon ui-icon-custom"></span>
</span>
<a wicket:id="loginlink" id="login" href="/domain/mobile/login" data-theme="a" class="ui-btn-corner-all ui-btn ui-btn-up-a ui-btn-icon-top">
<span class="ui-btn-inner ui-btn-corner-all">
<span class="ui-btn-text">Logga in</span>
<span class="ui-icon ui-icon-custom"></span>
</span>
</a>
</li>
LoginRedirectPage.java, (the page containing the redirecting js)
@Override
public void renderHead(IHeaderResponse response) {
log.info("Redirecting to " + redirectUrl);//to check via log
// if the parent is the mobile app..
response.renderOnDomReadyJavascript(
"if(parent && parent.$ && parent.$.mobile){" +
"parent.$('#logout').show();" +
"parent.$('#login').hide();" +
"parent.history.go(-2);" +
"console.log('redirecting with jqm "+redirectUrl+"');" +//logging
"}");
However, (saw this coming huh !?),
the lines “parent.$(‘#logout’).show();” and “parent.$(‘#login’).hide();”
does what they are supposed to in a browser (via a PC), the logout link is enabled and the login link is hidden ( if the user is logged in).
But while doing this via an Android phone the links is not shown/hidden as they are supposed to, the login link is still sitting there. As if i wasn’t logged in, although the logs shows that i’m logged in.
The constant “redirectUrl” point in this case back to the StartPage.html.
By the way, i also tried to use some old-style js, ex. “parent.document.getElementById(‘logout’).style.display=’block’;”, to no avail.
Thanks in advance.
//Kalle
Ok, it’s been a while, but here is what i finally did to get it to work out for me, at this point i want to thank jbrookover for his quick answer.
The solution however turned out to be a more “oldfasioned” one.
In the case of using JQueryMobile, pages are stored in a cache, in order to reduce the cost of loading pages.
This meant that the page from where one start also is stored in the cache, thus storing the way the different links are rendered in the Android phone, and the solution was taking advantage of oldfasioned HTML.
By incorporating the following in the head section of the startpage,
this page was never stored in the JQueryMobile’s cache, and the javscript code,
was actually taking effect.
Hopefully this may come to use for someone else having an issue with the JQueryMobile caching at some point.
Sinc.