I know it will sound crazy, but I'm looking for a way to make an anchor (like <a href="#someId">
) that could be called from a backing bean method using JavaScript. For some reasons I need to make it this way, with a commandButton
that is set with ajax="false"
.
I'm trying something like this:
RequestContext.getCurrentInstance().execute("JAVASCRIPT THAT FOCUSES MY PAGE ON A HTML COMPONENT GIVEN ITS ID");
The idea is that even without ajax I could render my page showing it back to where it was.
Any ideas? It might be a simple JavaScript command, but I'm not really into JavaScript and I didn't find any simple solution that works...
Simply set location 's hash fragment.
In JavaScript:
location.hash = "someId";
In JSF/PrimeFaces (if really necessary):
RequestContext.getCurrentInstance().execute("location.hash='someId'");
The alternative would be to send a redirect:
externalContext.redirect(request.getRequestURI() + "#someId");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.