Cristian..
Thank you so much for that input. I am able to create a new page with an
object added to it.
About the "inline" and "edit" modes, when I tried to open the page in edit
mode, it did not copy the template for me. Is that how it works, or did I
make nay mistake in the querystring for getURL method...
When I changed it to inline...it worked ...
I need to know this because, now I am going to use an HTML form to enter the
values of Object properties and when I submit that form, I should add the
values of the text fields to the object and directly display the new page in
a "view" mode...(with inline, it opens it in the edit mode right!)
So, will the template be copied to my new page if I open it in "view"
mode!!!
Thanks
On Tue, Apr 15, 2008 at 4:45 PM, <[EMAIL PROTECTED]> wrote:
> Hi Jain,
> Well, from what I see, you add the object to the page but you don't save
> the document. Nothing is final until you call $doc.save() or
> $doc.saveWithProgrammingRights()
> $xwiki.getDocument($docname) will only give you an unsaved version of the
> document.
>
> So you should add $newdoc.save() before the redirect.
>
> Also, it might be better to use the inline action rather than the edit one
> with object editor . I personally would use
>
> $response.sendRedirect($newdoc.getURL("inline","template=${etemplate}&parent=${eparent}&title=$etitle"))
> but the object editor might work for you (it deppends on what you want to
> do).
> Note that the inline action requires that the class has a sheet. (if you
> created it with xwiki class editor it should have a default one).
>
>
> > Hello Cristian,
> >
> > I tried that. But this does not direct me to the Object "form" that I
> can
> > fill out with the values for all the properties.
> >
> > basically, I want to be able to create a new page and then when the user
> > is
> > redirected to that page, the object should already be there for him to
> > fill
> > in.
> >
> > I use this script to create a new page: (Obtained from create.vm)
> >
> > #set($title = $request.getParameter("title"))
> > #set($template = "")
> > #set($template = $request.getParameter("template"))
> > #set($parent = "")
> > #set($parent=$request.getParameter("parent"))
> > #set($auxparams="")
> > #set($auxparams=$request.getParameter("auxparams"))
> > #set($docname=$title.replaceAll("/", "."))
> > #set($newdoc=$xwiki.getDocument($docname))
> > #set($etitle = $util.encodeURI($title))
> > #set($etemplate = $util.encodeURI("${template}"))
> > #set($eparent = $util.encodeURI("${parent}${auxparams}"))
> > #set($object =
> > $newdoc.newObject("PublishAnAsset.createMarketingFlyerClass"))
> > $response.sendRedirect($newdoc.getURL("edit",
> > "template=${etemplate}&parent=${eparent}&title=$etitle&editor=object"))
> > ###includeForm("XWiki.TodoClassSheet")
> >
> > But this jsut creates the new page for me.What should I add to this
> script
> > so that the new page is created with an object of the class mentioned!
> >
> > Thanks a lot for all help
> >
> > On Tue, Apr 15, 2008 at 2:25 PM, <[EMAIL PROTECTED]> wrote:
> >
> >> Hi,
> >> What you're looking for is the createNewObject method in Document Api.
> >> Here's a link to javadoc:
> >>
> >>
> http://platform.xwiki.org/xwiki/bin/download/DevGuide/API/xwiki%2Dcore%2D1.3.2%2Djavadoc.zip/com/xpn/xwiki/api/Document.html#createNewObject(java.lang.String)<http://platform.xwiki.org/xwiki/bin/download/DevGuide/API/xwiki%2Dcore%2D1.3.2%2Djavadoc.zip/com/xpn/xwiki/api/Document.html#createNewObject%28java.lang.String%29>
> <
> http://platform.xwiki.org/xwiki/bin/download/DevGuide/API/xwiki%2Dcore%2D1.3.2%2Djavadoc.zip/com/xpn/xwiki/api/Document.html#createNewObject%28java.lang.String%29
> >
> >>
> >> So you can do:
> >> #set( $objnr = $doc.createNewObject("MySpace.MyClass"))
> >> or
> >> #set( $objnr =
> >>
> >>
> $xwiki.getDocument("MySpace.MyDocument").createNewObject("MySpace.MyClass"))
> >> This will return you the number of the object.
> >>
> >> Then you can do #set( $myobj = $doc.getObject("MySpace.MyClass",$objnr)
> >> )
> >> and this will get you the actual object
> >>
> >> Hope it helps ;)
> >>
> >> Kamna Jain wrote:
> >>
> >> > Hello,
> >> > Can anybody tell me how to add an object of an already created class
> >> to
> >> a
> >> > new page using Velocity...not the interface provided by Xwiki.
> >> > Which method do I need to call to achieve this!!!
> >> >
> >> > Thanks
> >> > _______________________________________________
> >> > devs mailing list
> >> > [email protected]
> >> > http://lists.xwiki.org/mailman/listinfo/devs
> >> >
> >>
> >>
> >>
> >
>
>
>
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs