[xwiki-users] How to use GET/POST in xwiki

Thomas Krämer tk at ontopica.de
Thu May 10 15:30:59 CEST 2007


hi evelina,


A not too extensive but very good conceptual introduction is this one:
http://click.sourceforge.net/docs/velocity/VelocityUsersGuide.pdf

43 pages that are worth reading.


I am not sure if I did entirely understand your question.
Do you want to set a variable in a velocity template programatically
(i.e. setting it in the template itself), like

#set($force = $!request.get("force"))

Or do you want to remote control an existing wiki page (that in the
background is made up of velocity templates)?

The following method makes use of the apache commons httpclient to
establish a connection to xwiki and delete a group from the wiki.

Basically, it performs an http POST to the page of the group "group".

If you have a look at com.xpn.xwiki.web.DeleteAction, you see, that the
 parameter "confirm" must be set to 1, if DeleteAction.action() should
succeed.

Thence, in the method below I set this parameter to 1
(to avoid a javascript alert / confirmation page).

Hope that helps

Thomas


Note, that you have to perform a login first, if you want that method to
succeed.
/**
 * Removes a group from the xwiki user management
 * Author        : Thomas Kraemer <mailto:tk at ontopica.de>
 * Creation Date : 02.05.2007 00:57:37
 * @param group
 */
public void removeGroup(String group) {
	try {
		result = 0;
		PostMethod remGroup = new PostMethod(server
				+ "/xwiki/bin/delete/XWiki/"+group
				+ "?confirm=1&language=en");
		httpclient.executeMethod(remGroup);
		remGroup.releaseConnection();
	} catch (HttpException e) {
			e.printStackTrace();
	} catch (IOException e) {
			e.printStackTrace();
	}
}

evelyne24 at gmail.com schrieb:
> I have a question regarding the use of GET/POST in xwiki. How do I send to a velocity script a string using GET or maybe something similar (like $context??) in xwiki? 
> I read something about xwiki context, like getResponse() and getRequest(), but I would like an example to understand better, because the api is very lacunal. Thank you.
> Evelina Slatineanu
> 
> 
> 
> ------------------------------------------------------------------------
> 
> 
> --
> You receive this message as a subscriber of the xwiki-users at objectweb.org mailing list.
> To unsubscribe: mailto:xwiki-users-unsubscribe at objectweb.org
> For general help: mailto:sympa at objectweb.org?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws

-- 
ontopica

Thomas Krämer

Krämer&Okpue GbR

Kurfürstenstr. 66
53115 Bonn

Fon 	0228 - 180 99 737
Fax	0228 - 242 78 60
Email 	tk at ontopica.de




More information about the users mailing list