Re: [xwiki-users] [xwiki-devs] Questions about Blog Example

2012-03-28 Thread du du
Hi, Anca,

Thanks very much for your response, I understand how data are saved to
database now, but I got another question:

 In the following code from BlogPostSheet
dl
  dt$msg.get('xe.blog.sheet.title')/dt
  dd$doc.display('title', 'edit', $entryObj)/dd
  dt$msg.get('xe.blog.sheet.content')/dt
  dd$doc.display('content', 'edit', $entryObj)/dd
  dtFeature ID:/dt
   dd$doc.display('FID', 'view', $entryObj)/dd
  dtPackage ID:/dt
dd$doc.display('PID', 'view', $entryObj)/dd

  div class=clearfloats/div
  /dd
  /dl

If I change the 'view' to 'edit' for both FID and PID, then both of FID and
PID will be saved to database, and I can query retrieve them, but I have
use view, then they are not saved to database. the problem is I donot want
these two fields editable, so I have to use view, any workaround for this?
so the bottom line is I want them to be saved to database and not editable
from the inline form.

Thanks again for your help.

Dave

On Wed, Mar 28, 2012 at 4:47 AM, Anca Luca lu...@xwiki.com wrote:

 Hi Dave,

 You should read http://platform.xwiki.org/**xwiki/bin/view/DevGuide/**
 Architecturehttp://platform.xwiki.org/xwiki/bin/view/DevGuide/Architecture, 
 but I understand that it might be cryptic for a first time usage so here
 we go:
 must know that xwiki is a java engine, so there is some java code that
 does things, it's not all done in velocity.
 Basically, there is a java platform that can handle documents, objects
 in documents, classes, etc (load, save) and then there is the velocity
 scripting that you can do in wiki pages which **uses** this core (injected
 variables like $xwiki, $doc). See here about how this scripting in pages
 works: 
 http://platform.xwiki.org/**xwiki/bin/view/DevGuide/**Scriptinghttp://platform.xwiki.org/xwiki/bin/view/DevGuide/Scripting.
 Also, there are some interesting information about the data model here
 http://platform.xwiki.org/**xwiki/bin/view/DevGuide/**DataModelhttp://platform.xwiki.org/xwiki/bin/view/DevGuide/DataModel.

 The 'platform' project on git contains all this 'platform' code: java
 sources, default templates, default js, css, etc, which you can enhance in
 wiki pages (but we don't do everything in wiki pages, so you should not
 look for it only in wiki pages).

 Also, there are a bunch of default velocity templates that handle the
 default layout and actions for the wiki (in the webapps/xwiki/templates
 folder of the installation). For example, the save and view button is
 generated by these templates, along with the url to which the data in the
 form is posted.

 I recommend firebug and LiveHttpheaders extensions of firefox to study
 what data is posted to which URL, etc what data is received. from then on,
 with the help of http://platform.xwiki.org/**xwiki/bin/view/DevGuide/**
 Architecture#**HUnderstandinghowHTTPrequestsa**rehandledhttp://platform.xwiki.org/xwiki/bin/view/DevGuide/Architecture#HUnderstandinghowHTTPrequestsarehandled,
  you should be able to find the code that actually does the save.

 Have fun,
 Anca


 On 03/28/2012 05:42 AM, du du wrote:

 Also from the following BlogPostSheet wiki code, after users type in
 message from the inline form, users click Save  View button, how are the

 messages saved to database?
 see the attached code:
 {{include document=Blog.BlogCode/}}

 {{include document=Blog.CategoriesCode**/}}

 {{velocity filter=none}}
 {{html clean=false wiki=true}}
 $xwiki.jsx.use('Blog.**ManageCategories', {'mode' : 'select'})##
 $xwiki.ssx.use('Blog.**ManageCategories')##
 #getEntryObject($doc $entryObj)
 #if($!entryObj == '')
   #warning($msg.get('xe.blog.**sheet.notpost'))
 ## Keep testing the inline action for backward compatibility with older
 blog posts.
 #elseif($xcontext.action != 'edit'  $xcontext.action != 'inline')
   ## View mode
   #isPublished($entryObj $isPublished)
   #isHidden($entryObj $isHidden)
   ## displayBlog requires a list of documents, and whether to display only
 an extract or the full entry.
   #displayBlog([$tdoc] 'single' false false)
 #else
   dl
   dt$msg.get('xe.blog.sheet.**title')/dt
   dd$doc.display('title', 'edit', $entryObj)/dd
   dt$msg.get('xe.blog.sheet.**content')/dt
   dd$doc.display('content', 'edit', $entryObj)/dd
   dt$msg.get('xe.blog.sheet.**summary')/dt
   dd$doc.display('extract', 'edit', $entryObj)/dd
   dt$msg.get('xe.blog.sheet.**category')/dt
   dd
   #**displayCategoryManagementTree(**'' 'selectable')
   div class=clearfloats/div
   /dd
   /dl
   #template('tagedit.vm')
   #isPublished($entryObj $isPublished)
   #if($isPublished)
 #if($doc.creator == $xcontext.user)
   #publishMessageBox($msg.get('**xe.blog.sheet.publicationdate'**,
 [${doc.display('publishDate', 'view', $entryObj)}]))
   #set($hideArticle = ${doc.display('hidden', 'edit', $entryObj)})
   #hideMessageBox($msg.get('xe.**blog.sheet.hidearticle',
 [${hideArticle}]))
 #end
   #else
 #set($defaultDate =
 

Re: [xwiki-users] [xwiki-devs] Questions about Blog Example

2012-03-28 Thread du du
By the way I added these two fields for testing.

Dave

On Wed, Mar 28, 2012 at 10:01 PM, du du ddd...@gmail.com wrote:

 Hi, Anca,

 Thanks very much for your response, I understand how data are saved to
 database now, but I got another question:

  In the following code from BlogPostSheet

 dl
   dt$msg.get('xe.blog.sheet.title')/dt
   dd$doc.display('title', 'edit', $entryObj)/dd
   dt$msg.get('xe.blog.sheet.content')/dt
   dd$doc.display('content', 'edit', $entryObj)/dd
   dtFID:/dt
dd$doc.display('FID', 'view', $entryObj)/dd
   dtPID:/dt
 dd$doc.display('PID', 'view', $entryObj)/dd


   div class=clearfloats/div
   /dd
   /dl

 If I change the 'view' to 'edit' for both FID and PID, then both of FID
 and PID will be saved to database, and I can query retrieve them, but I
 have use view, then they are not saved to database. the problem is I donot
 want these two fields editable, so I have to use view, any workaround for
 this? so the bottom line is I want them to be saved to database and not
 editable from the inline form.

 Thanks again for your help.

 Dave


 On Wed, Mar 28, 2012 at 4:47 AM, Anca Luca lu...@xwiki.com wrote:

 Hi Dave,

 You should read http://platform.xwiki.org/**xwiki/bin/view/DevGuide/**
 Architecturehttp://platform.xwiki.org/xwiki/bin/view/DevGuide/Architecture,
  but I understand that it might be cryptic for a first time usage so here
 we go:
 must know that xwiki is a java engine, so there is some java code that
 does things, it's not all done in velocity.
 Basically, there is a java platform that can handle documents, objects
 in documents, classes, etc (load, save) and then there is the velocity
 scripting that you can do in wiki pages which **uses** this core (injected
 variables like $xwiki, $doc). See here about how this scripting in pages
 works: 
 http://platform.xwiki.org/**xwiki/bin/view/DevGuide/**Scriptinghttp://platform.xwiki.org/xwiki/bin/view/DevGuide/Scripting.
 Also, there are some interesting information about the data model here
 http://platform.xwiki.org/**xwiki/bin/view/DevGuide/**DataModelhttp://platform.xwiki.org/xwiki/bin/view/DevGuide/DataModel.

 The 'platform' project on git contains all this 'platform' code: java
 sources, default templates, default js, css, etc, which you can enhance in
 wiki pages (but we don't do everything in wiki pages, so you should not
 look for it only in wiki pages).

 Also, there are a bunch of default velocity templates that handle the
 default layout and actions for the wiki (in the webapps/xwiki/templates
 folder of the installation). For example, the save and view button is
 generated by these templates, along with the url to which the data in the
 form is posted.

 I recommend firebug and LiveHttpheaders extensions of firefox to study
 what data is posted to which URL, etc what data is received. from then on,
 with the help of http://platform.xwiki.org/**xwiki/bin/view/DevGuide/**
 Architecture#**HUnderstandinghowHTTPrequestsa**rehandledhttp://platform.xwiki.org/xwiki/bin/view/DevGuide/Architecture#HUnderstandinghowHTTPrequestsarehandled,
  you should be able to find the code that actually does the save.

 Have fun,
 Anca


 On 03/28/2012 05:42 AM, du du wrote:

 Also from the following BlogPostSheet wiki code, after users type in
 message from the inline form, users click Save  View button, how are the

 messages saved to database?
 see the attached code:
 {{include document=Blog.BlogCode/}}

 {{include document=Blog.CategoriesCode**/}}

 {{velocity filter=none}}
 {{html clean=false wiki=true}}
 $xwiki.jsx.use('Blog.**ManageCategories', {'mode' : 'select'})##
 $xwiki.ssx.use('Blog.**ManageCategories')##
 #getEntryObject($doc $entryObj)
 #if($!entryObj == '')
   #warning($msg.get('xe.blog.**sheet.notpost'))
 ## Keep testing the inline action for backward compatibility with older
 blog posts.
 #elseif($xcontext.action != 'edit'  $xcontext.action != 'inline')
   ## View mode
   #isPublished($entryObj $isPublished)
   #isHidden($entryObj $isHidden)
   ## displayBlog requires a list of documents, and whether to display
 only
 an extract or the full entry.
   #displayBlog([$tdoc] 'single' false false)
 #else
   dl
   dt$msg.get('xe.blog.sheet.**title')/dt
   dd$doc.display('title', 'edit', $entryObj)/dd
   dt$msg.get('xe.blog.sheet.**content')/dt
   dd$doc.display('content', 'edit', $entryObj)/dd
   dt$msg.get('xe.blog.sheet.**summary')/dt
   dd$doc.display('extract', 'edit', $entryObj)/dd
   dt$msg.get('xe.blog.sheet.**category')/dt
   dd
   #**displayCategoryManagementTree(**'' 'selectable')
   div class=clearfloats/div
   /dd
   /dl
   #template('tagedit.vm')
   #isPublished($entryObj $isPublished)
   #if($isPublished)
 #if($doc.creator == $xcontext.user)
   #publishMessageBox($msg.get('**xe.blog.sheet.publicationdate'**,
 [${doc.display('publishDate', 'view', $entryObj)}]))
   #set($hideArticle = ${doc.display('hidden', 'edit', $entryObj)})
   

Re: [xwiki-users] [xwiki-devs] Questions about Blog Example

2012-03-28 Thread Sergiu Dumitriu

On 03/28/2012 10:01 PM, du du wrote:

Hi, Anca,

Thanks very much for your response, I understand how data are saved to
database now, but I got another question:

  In the following code from BlogPostSheet
dl
   dt$msg.get('xe.blog.sheet.title')/dt
   dd$doc.display('title', 'edit', $entryObj)/dd
   dt$msg.get('xe.blog.sheet.content')/dt
   dd$doc.display('content', 'edit', $entryObj)/dd
   dtFeature ID:/dt
dd$doc.display('FID', 'view', $entryObj)/dd
   dtPackage ID:/dt
 dd$doc.display('PID', 'view', $entryObj)/dd

   div class=clearfloats/div
   /dd
   /dl

If I change the 'view' to 'edit' for both FID and PID, then both of FID and
PID will be saved to database, and I can query retrieve them, but I have
use view, then they are not saved to database. the problem is I donot want
these two fields editable, so I have to use view, any workaround for this?
so the bottom line is I want them to be saved to database and not editable
from the inline form.


'view' display only prints those values as text, not as form elements, 
so it's normal that the values don't get back to the database. You 
should display them again with 'hidden' as the display mode, which will 
create hidden input elements with their current value.


Still, I hope you're not using those parameters as something secure, 
since any attacker could just send any value he wants to the server; 
always make sure security is thoroughly implemented on the server, never 
trust data from the client.



Thanks again for your help.

Dave

On Wed, Mar 28, 2012 at 4:47 AM, Anca Lucalu...@xwiki.com  wrote:


Hi Dave,

You should read http://platform.xwiki.org/**xwiki/bin/view/DevGuide/**
Architecturehttp://platform.xwiki.org/xwiki/bin/view/DevGuide/Architecture, 
but I understand that it might be cryptic for a first time usage so here
we go:
must know that xwiki is a java engine, so there is some java code that
does things, it's not all done in velocity.
Basically, there is a java platform that can handle documents, objects
in documents, classes, etc (load, save) and then there is the velocity
scripting that you can do in wiki pages which **uses** this core (injected
variables like $xwiki, $doc). See here about how this scripting in pages
works: 
http://platform.xwiki.org/**xwiki/bin/view/DevGuide/**Scriptinghttp://platform.xwiki.org/xwiki/bin/view/DevGuide/Scripting.
Also, there are some interesting information about the data model here
http://platform.xwiki.org/**xwiki/bin/view/DevGuide/**DataModelhttp://platform.xwiki.org/xwiki/bin/view/DevGuide/DataModel.

The 'platform' project on git contains all this 'platform' code: java
sources, default templates, default js, css, etc, which you can enhance in
wiki pages (but we don't do everything in wiki pages, so you should not
look for it only in wiki pages).

Also, there are a bunch of default velocity templates that handle the
default layout and actions for the wiki (in the webapps/xwiki/templates
folder of the installation). For example, the save and view button is
generated by these templates, along with the url to which the data in the
form is posted.

I recommend firebug and LiveHttpheaders extensions of firefox to study
what data is posted to which URL, etc what data is received. from then on,
with the help of http://platform.xwiki.org/**xwiki/bin/view/DevGuide/**
Architecture#**HUnderstandinghowHTTPrequestsa**rehandledhttp://platform.xwiki.org/xwiki/bin/view/DevGuide/Architecture#HUnderstandinghowHTTPrequestsarehandled,
 you should be able to find the code that actually does the save.

Have fun,
Anca


On 03/28/2012 05:42 AM, du du wrote:


Also from the following BlogPostSheet wiki code, after users type in
message from the inline form, users click Save   View button, how are the

messages saved to database?
see the attached code:
{{include document=Blog.BlogCode/}}

{{include document=Blog.CategoriesCode**/}}

{{velocity filter=none}}
{{html clean=false wiki=true}}
$xwiki.jsx.use('Blog.**ManageCategories', {'mode' : 'select'})##
$xwiki.ssx.use('Blog.**ManageCategories')##
#getEntryObject($doc $entryObj)
#if($!entryObj == '')
   #warning($msg.get('xe.blog.**sheet.notpost'))
## Keep testing the inline action for backward compatibility with older
blog posts.
#elseif($xcontext.action != 'edit'   $xcontext.action != 'inline')
   ## View mode
   #isPublished($entryObj $isPublished)
   #isHidden($entryObj $isHidden)
   ## displayBlog requires a list of documents, and whether to display only
an extract or the full entry.
   #displayBlog([$tdoc] 'single' false false)
#else
   dl
   dt$msg.get('xe.blog.sheet.**title')/dt
   dd$doc.display('title', 'edit', $entryObj)/dd
   dt$msg.get('xe.blog.sheet.**content')/dt
   dd$doc.display('content', 'edit', $entryObj)/dd
   dt$msg.get('xe.blog.sheet.**summary')/dt
   dd$doc.display('extract', 'edit', $entryObj)/dd
   dt$msg.get('xe.blog.sheet.**category')/dt
   dd
   #**displayCategoryManagementTree(**'' 'selectable')
   div class=clearfloats/div
   /dd
   /dl
   

Re: [xwiki-users] [xwiki-devs] Questions about Blog Example

2012-03-28 Thread du du
Thanks, got it.
Dave

On Wed, Mar 28, 2012 at 10:49 PM, Sergiu Dumitriu ser...@xwiki.com wrote:

 On 03/28/2012 10:01 PM, du du wrote:

 Hi, Anca,

 Thanks very much for your response, I understand how data are saved to
 database now, but I got another question:

  In the following code from BlogPostSheet
 dl
   dt$msg.get('xe.blog.sheet.**title')/dt
   dd$doc.display('title', 'edit', $entryObj)/dd
   dt$msg.get('xe.blog.sheet.**content')/dt
   dd$doc.display('content', 'edit', $entryObj)/dd
   dtFeature ID:/dt
dd$doc.display('FID', 'view', $entryObj)/dd
   dtPackage ID:/dt
 dd$doc.display('PID', 'view', $entryObj)/dd

   div class=clearfloats/div
   /dd
   /dl

 If I change the 'view' to 'edit' for both FID and PID, then both of FID
 and
 PID will be saved to database, and I can query retrieve them, but I have
 use view, then they are not saved to database. the problem is I donot want
 these two fields editable, so I have to use view, any workaround for this?
 so the bottom line is I want them to be saved to database and not editable
 from the inline form.


 'view' display only prints those values as text, not as form elements, so
 it's normal that the values don't get back to the database. You should
 display them again with 'hidden' as the display mode, which will create
 hidden input elements with their current value.

 Still, I hope you're not using those parameters as something secure, since
 any attacker could just send any value he wants to the server; always make
 sure security is thoroughly implemented on the server, never trust data
 from the client.

  Thanks again for your help.

 Dave

 On Wed, Mar 28, 2012 at 4:47 AM, Anca Lucalu...@xwiki.com  wrote:

  Hi Dave,

 You should read 
 http://platform.xwiki.org/xwiki/bin/view/DevGuide/**http://platform.xwiki.org/**xwiki/bin/view/DevGuide/**
 Architecturehttp://platform.**xwiki.org/xwiki/bin/view/**
 DevGuide/Architecturehttp://platform.xwiki.org/xwiki/bin/view/DevGuide/Architecture,
 but I understand that it might be cryptic for a first time usage so here

 we go:
 must know that xwiki is a java engine, so there is some java code that
 does things, it's not all done in velocity.
 Basically, there is a java platform that can handle documents, objects
 in documents, classes, etc (load, save) and then there is the velocity
 scripting that you can do in wiki pages which **uses** this core
 (injected
 variables like $xwiki, $doc). See here about how this scripting in pages
 works: http://platform.xwiki.org/xwiki/bin/view/DevGuide/
 Scriptinghttp://platform.xwiki.org/**xwiki/bin/view/DevGuide/**Scripting
 http://platform.**xwiki.org/xwiki/bin/view/**DevGuide/Scriptinghttp://platform.xwiki.org/xwiki/bin/view/DevGuide/Scripting
 .

 Also, there are some interesting information about the data model here
 http://platform.xwiki.org/xwiki/bin/view/DevGuide/DataModelhttp://platform.xwiki.org/**xwiki/bin/view/DevGuide/**DataModel
 http://platform.**xwiki.org/xwiki/bin/view/**DevGuide/DataModelhttp://platform.xwiki.org/xwiki/bin/view/DevGuide/DataModel
 .


 The 'platform' project on git contains all this 'platform' code: java
 sources, default templates, default js, css, etc, which you can enhance
 in
 wiki pages (but we don't do everything in wiki pages, so you should not
 look for it only in wiki pages).

 Also, there are a bunch of default velocity templates that handle the
 default layout and actions for the wiki (in the webapps/xwiki/templates
 folder of the installation). For example, the save and view button is
 generated by these templates, along with the url to which the data in the
 form is posted.

 I recommend firebug and LiveHttpheaders extensions of firefox to study
 what data is posted to which URL, etc what data is received. from then
 on,
 with the help of http://platform.xwiki.org/
 xwiki/bin/view/DevGuide/**http://platform.xwiki.org/**xwiki/bin/view/DevGuide/**
 Architecture#HUnderstandinghowHTTPrequestsarehandled
 http://platform.**xwiki.org/xwiki/bin/view/**DevGuide/Architecture#**
 HUnderstandinghowHTTPrequestsa**rehandledhttp://platform.xwiki.org/xwiki/bin/view/DevGuide/Architecture#HUnderstandinghowHTTPrequestsarehandled,
 you should be able to find the code that actually does the save.


 Have fun,
 Anca


 On 03/28/2012 05:42 AM, du du wrote:

  Also from the following BlogPostSheet wiki code, after users type in
 message from the inline form, users click Save   View button, how are
 the

 messages saved to database?
 see the attached code:
 {{include document=Blog.BlogCode/}}

 {{include document=Blog.CategoriesCode/}}


 {{velocity filter=none}}
 {{html clean=false wiki=true}}
 $xwiki.jsx.use('Blog.ManageCategories', {'mode' : 'select'})##
 $xwiki.ssx.use('Blog.ManageCategories')##

 #getEntryObject($doc $entryObj)
 #if($!entryObj == '')
   #warning($msg.get('xe.blog.sheet.notpost'))

 ## Keep testing the inline action for backward compatibility with older
 blog posts.