GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — JEE Web Integration JEE Web Integration
Martijn Dashorst edited this page
The JEEWebResolver is used to embed Servlet, JSP abd JSF content into wicked HTML pages, by a custom Wicket-Tag. It is tested with Wicket 6.x / 7.x. Because include is used to apply the content, every restrictions of include is applied to the embed content. (No header modifications and so on). To use it you should registered it to the page settings in the init-Method of the Wicket-Application: WebApplication: @Override protected void init() { super.init(); getPageSettings().addComponentResolver(new JEEWebResolver()); } A tag specifies the location which embed content to load. (The argument is given to the getRequestDispatcher method of the ServletContext): <wicket:jsp file="/de/test/jsp/TestPage.jsp"/> or <wicket:servlet path="/de/test/servlet/Servlet/"> or <wicket:jsf file="/TestPage.xhtml"/> JSP: <%@ taglib prefix="wicket" uri="http://wicketstuff-jee-web.org/functions/jsp" %> JSF: <div xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:wicket="http://wicketstuff-jee-web.org/functions/jsf"> Tag: url // Parameters: page(required), query(optional) // Example: JSP Example: <a href="<wicket:url page="mypage.MyTestPage" query="param1=value1¶m2=value2"/>">LINK</a> JSF Example: Tag is the same but should not be used within a href, please refer to the EL-Functions JSP: <%@ taglib prefix="wicket" uri="http://wicketstuff-jee-web.org/functions/jsp" %>
JSF: <div xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html" xmlns:wicket="http://wicketstuff-jee-web.org/functions/jsf">
EL-Function:
${wicket:url('mypackage.MyPage')}
${wicket:urlWithQuery('mypackage.MyPage','param1=value1')}
POST: JSP-Fragment: <form action="<wicket:url page="mypackage.MyPage2"/>" method="POST"> <input type="hidden" name="hiddenparam" value="testvalue"> <input type="submit" value="Submit"> </form> mypackage.TestPage2: public TestPage2(PageParameters parameters){ String hiddenparam = RequestCycle.get().getRequest() .getPostParameters().getParameterValue("hiddenparam"); } GET: JSP-Fragment: <form action="<wicket:url page="mypackage.MyPage2"/>" method="GET"> <input type="hidden" name="hiddenparam" value="testvalue"> <input type="submit" value="Submit"> </form> mypackage.TestPage2: public TestPage2(PageParameters parameters){ String hiddenparam = parameters.get("hiddenparam").toString(); } WebApplication: @Override protected void init() { super.init(); getPageSettings().addComponentResolver(new JEEWebResolver()); JEEWebGlobalAjaxHandler.configure(this); } WebPage (IMPORTANT: In constructor use setStatelessHint(false); !!!): @Override public void onEvent(IEvent<?> event) { JEEWebGlobalAjaxEvent castedEvent = JEEWebGlobalAjaxEvent.getCastedEvent(event); if (castedEvent!= null) { AjaxRequestTarget ajaxRequestTarget = castedEvent.getAjaxRequestTarget(); // Get-Request castedEvent.getPageParameters().get("param"); // Post-Request castedEvent.getPostParameters().getParameterValue("param") } } In JSP: <a href="#" onClick="${wicket:ajaxGetWithQuery('param=value')}">Update</a>
<a href="#" onClick="${wicket:ajaxGet()}">Update</a>
In JSP with Javascript: <script type="text/javascript">
function processCallBack(){
var url = '${wicket:ajaxCallbackUrl()}';
var urlWithPreRenderedArgs =
'${wicket:ajaxCallbackUrlWithQuery("param=value")}';
// Get-Request
var url = Wicket.Ajax.applyGetParameters(url,{"param":"value"})
Wicket.Ajax.wrapget(url);
// Post-Request
Wicket.Ajax.wrappost(url,{"param":"value"});
}
processCallBack();
</script>
Forms (GET / POST given as String to the EL function) <form onsubmit="${wicket:ajaxFormSubmit('POST')}"> .... </form>
<dependency> <groupId>org.wicketstuff</groupId> <artifactId>wicketstuff-jee-web</artifactId> <version>/version/</version> </dependency> Clone this wiki locally |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |