Re: Calculating wicket page URL in JavaScript

2011-02-06 Thread mbrictson

My solution is to put a  tag on every page with a reference to the home
page URL. That way scripts can always build URLs based on the home page
root.

For example:

BasePage.html


  


BasePage.java

add(new BookmarkablePageLink("home-link", getApplication().getHomePage()));

Then your JavaScript can do something like this (jQuery):

var projectPageUrl = $("link[rel='home']").attr("href") + "project/" +
projectId;
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Calculating-wicket-page-URL-in-JavaScript-tp3262459p3263084.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Calculating wicket page URL in JavaScript

2011-02-05 Thread Alec Swan
Hello,

I have a common.js file which has a JavaScript function
getProjectPageUrl(projectId) which should return the URL to the Wicket
ProjectPage object which displays properties of the project with the
specified projectId. I am not sure if this is relevant, but ProjectPage is
mounted in my Wicket application as follows mount(new
HybridUrlCodingStrategy("project", ProjectPage.class)).

I would like getProjectPageUrl function to work in DEV, QA and PROD
environments, so I can't hard-code the server IP and webapp context.

I remember there was a similar discussion where somebody suggested declaring
a variable in common.js, e.g. var projectUrl = $projectUrl$, and then
replacing $projectUrl$ on the Java side, but I can't find that forum thread
anymore.

Any help will be greatly appreciated.

Thanks,

Alec