Skip to content

A way to integrate JEE web components into your wicket application.

Notifications You must be signed in to change notification settings

klopfdreh/wicketstuff-jee-web

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 

Repository files navigation

wicketstuff-jee-web (previously wicket.jsp)

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:

IMPORTANT

  • Is now available in Version 6.18.0 / 7.0.0-M4 of its own wicketstuff project. (wicketstuff-jee-web)
  • Dependency:
   <dependency>
      <groupId>org.wicketstuff</groupId>
      <artifactId>wicketstuff-jee-web</artifactId>
      <version>/version/</version>
   </dependency>

Links to Wicketstuff

Setup

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):

Usage

<wicket:jsp file="/de/test/jsp/TestPage.jsp"/>

or 

<wicket:servlet path="/de/test/servlet/Servlet/">

or

<wicket:jsf file="/TestPage.xhtml"/>

Tags for JSP / JSF

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

EL-Functions for JSP / JSF

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')}

Forms (GET / POST)

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();
}

Ajax-Support

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>

Links

About

A way to integrate JEE web components into your wicket application.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published