Hello,
no..it does not work, because it creates a new space(website)
this is my code from the interface:
<form action = "$xwiki.getDocument("createPage.vm").getURL("view")">
<table border="0" cellspacing="0" cellpadding="0" class="panelright" >
<tbody>
<tr>
<td>
#template("createPage.vm")
Write the name of the new page: <br />
<input type="text" name="text" value="$!request.text" />
<input type="submit" name="addpage" value="add"/>
</td>
</tr>
</tbody>
</table>
</form>
and in createPage.vm i have the code from bellow.
and it creates the space(website) called createPage and the page: vm
this is so confunzing... it should haev only create a page in my current space.
Jean-Vincent Drean <[EMAIL PROTECTED]> wrote: Does this script produce an error
? Do you see a new page with a wrong
name in the what's new ?
Btw at first sight I'd try to protect velocity variables :
#set($space = $!request.space)
#set($text = $!request.text )
afisare textfield: $text
#set ($mydoc = $xwiki.getDocument("${space}.${text}"))
$mydoc.setContent("test")
$mydoc.save()
Some tests to avoid empty strings would be good to have too.
On Wed, May 14, 2008 at 4:11 PM, Gabriela Radu wrote:
> hello Vincent,
> i found your link most usefull , but it's made static. when i tried to give
> the parameters dinamically(the name of the space, and the text from a
> textfield) like this...it does not let me :
>
> #set($space = $request.space)
> #set($text = $!request.text )
> afisare textfield: $text
> #set ($mydoc = $xwiki.getDocument("$space.$text"))
> $mydoc.setContent("test")
> $mydoc.save()
>
> i know this question is kind of a long shoot to ask..but i have no ideea why
> can't it work.
>
> Vincent Massol wrote:
> On May 14, 2008, at 1:49 PM, Vincent Massol wrote:
>
>> Hi,
>>
>> On May 14, 2008, at 1:41 PM, Gabriela Radu wrote:
>>
>>> hello!
>>>
>>> where can i find the code that creates a new xwiki page? i know i
>>> can create new pages from xeclipse. but i wanna be able to create
>>> the pages from an interface. for instance to have a text field and a
>>> button, and when the button is pressed a new page will be created
>>> with the name given in the text field.
>>>
>>> thank you for your time
>>
>> See http://code.xwiki.org/xwiki/bin/view/Snippets/CreatePageSnippet
>>
>> For HTML forms, see the FAQ or TODO tutorial for example.
>
> Would be good if you update the
> http://code.xwiki.org/xwiki/bin/view/Snippets/CreatePageSnippet
> page when you find out how to use a form to create a new page for ex.
>
> Another hint: check the Create Panel which does exactly this.
>
> Thanks
> -Vincent
>
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/users
>
>
>
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/users
>
--
Jean-Vincent Drean
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users
Take care ,
Gabriela Radu :)
www.gabrielaradu.com
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users