[xwiki-devs] analog of session context accessible from velocity ?
Good day. Yet one question - I can't find way to pass parameters from one screen to another. In JSP this is usually doing thought session-scope variables. Are exists some analog in XWiki ? I.e. let I have page A and receive in one request with parameters. Than I want forward such request (with parameters) to page B. I can't find the way to do this: if in A before redirect I write $context.put("X","Y"), than in B $context.get("X") return nothing. May be I need care about passing some sessionId ? -- Ruslan Shevchenko GradSoft. http://www.gradsoft.ua
On Mon, 14 Jan 2008 17:50:27 +0300, rssh wrote
Good day.
Sorry for stupid question. $request.getHttpServletRequest().getSession().setAttribute("X",$request.get("X")) and then #set($X=$request.getHttpServletRequest().getSession().getAttribute("X")) do the trick. So, yes, XWiki can be good programming platform ;)
Yet one question - I can't find way to pass parameters from one screen to another. In JSP this is usually doing thought session- scope variables. Are exists some analog in XWiki ?
I.e. let I have page A and receive in one request with parameters. Than I want forward such request (with parameters) to page B.
I can't find the way to do this: if in A before redirect I write $context.put("X","Y"), than in B $context.get("X") return nothing.
May be I need care about passing some sessionId ?
-- Ruslan Shevchenko GradSoft. http://www.gradsoft.ua
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Ruslan Shevchenko GradSoft. http://www.gradsoft.ua
On Jan 14, 2008, at 4:53 PM, rssh wrote:
On Mon, 14 Jan 2008 17:50:27 +0300, rssh wrote
Good day.
Sorry for stupid question.
$request.getHttpServletRequest().getSession().setAttribute("X", $request.get("X")) and then #set($X= $request.getHttpServletRequest().getSession().getAttribute("X"))
do the trick.
So, yes, XWiki can be good programming platform ;)
There are several ways you can do this: * pass the parameters in the URL * use the velocity context * use the session * use the application context * use request attributes if you do a server side redirect * use the xwiki context itself Note that the only reason your code didn't work is because you need programming rights to be allowed to set values in the xwiki context: public void put(String key, java.lang.Object value) { if (hasProgrammingRights()) { getXWikiContext().put(key, value); } } -Vincent
Yet one question - I can't find way to pass parameters from one screen to another. In JSP this is usually doing thought session- scope variables. Are exists some analog in XWiki ?
I.e. let I have page A and receive in one request with parameters. Than I want forward such request (with parameters) to page B.
I can't find the way to do this: if in A before redirect I write $context.put("X","Y"), than in B $context.get("X") return nothing.
May be I need care about passing some sessionId ?
* use the velocity context
Note that the only reason your code didn't work is because you need programming rights to be allowed to set values in the xwiki context:
1. But this code does not work from superadmin. 2. I.e. we need programming rights for any evaluation of program, written by others ?
-Vincent
I can't find the way to do this: if in A before redirect I write $context.put("X","Y"), than in B $context.get("X") return nothing.
On Jan 14, 2008, at 5:32 PM, rssh wrote:
* use the velocity context
Note that the only reason your code didn't work is because you need programming rights to be allowed to set values in the xwiki context:
1. But this code does not work from superadmin.
hmm.... Some time ago I created http://jira.xwiki.org/jira/browse/XWIKI-1046 but apparently I thought it wasn't true anymore. Maybe under some conditions it's a problem? Would be interesting if you could log in with an Admin user who has programming rights and see if it works.
2. I.e. we need programming rights for any evaluation of program, written by others ?
Yes, if that code has checks for programming rights. -Vincent
also note, that com.xpn.xwiki.api.Context has no get() method.
On Jan 14, 2008, at 6:31 PM, rssh wrote:
also note, that com.xpn.xwiki.api.Context has no get() method.
I see one; public java.lang.Object get(String key) { if (hasProgrammingRights()) { return getXWikiContext().get(key); } else { return null; } } -Vincent
On Mon, 14 Jan 2008 19:04:00 +0100, Vincent Massol wrote
On Jan 14, 2008, at 6:31 PM, rssh wrote:
also note, that com.xpn.xwiki.api.Context has no get() method.
I see one;
public java.lang.Object get(String key) { if (hasProgrammingRights()) { return getXWikiContext().get(key); } else { return null; } }
Ohh, really, (and $context.hasProgramingRigths() is reduced to true. Ok, I will research more ;))
participants (2)
-
rssh -
Vincent Massol