[xwiki-users] Using one Class and Template for creating documents in more than one space...
Hi again, If I create a class similar to the one in the FAQ tutorial but add one or more new properties to define a space and category could I use this class and associated design sheet and template to create FAQ documents for more than one space? Is it possible to programatically determine what space a document should be created in when it is saved? Are there any simple examples of how something like this would be done? I've gone through just about every piece of documentation but the development process is still unclear. Thanks! .:. Kevin -- View this message in context: http://n2.nabble.com/Using-one-Class-and-Template-for-creating-documents-in-... Sent from the XWiki- Users mailing list archive at Nabble.com.
Hi, i am quite new to XWiki, but i hope i can help.
If I create a class similar to the one in the FAQ tutorial but add one or more new properties to define a space and category could I use this class and associated design sheet and template to create FAQ documents for more than one space?
I used this form to create blog entries from Main.WebHome : Add a news : <form action="" id="newdoc" method="post"> <div> <input type="hidden" name="parent" value="Blog.WebHome" /> <input type="hidden" name="template" value="XWiki.ArticleClassTemplate" /> <input type="hidden" name="sheet" value="1" /> <input type="hidden" name="webname" value="Blog"/> <input type="hidden" name="name" value=""/> <input type="text" name="title" value="news name" size="18"/> <input type="button" value="Add" onclick='if (updateName(this.form.title,this.form.name)) { action="../../inline/" + this.form.webname.value + "/" + this.form.name.value; this.form.submit(); }' /> </div> </form> if you change the webname value you should be able to create entries in other spaces using the ArticleClassTemplate. If you replace the XWiki.ArticleClassTemplate with your template, I guess you should create an entry of your template in the said space.
Is it possible to programatically determine what space a document should be created in when it is saved?
I think this is not possible, but maybe you can create the link with conditions so that it creates the page following the link.
Are there any simple examples of how something like this would be done? I've gone through just about every piece of documentation but the development process is still unclear.
Write velocity script to determine your $space and $page variables, write a [link>$space.$page] and this should work. I am not sure about what i am writing but I would investigate this way. Hope this helps Jean -- ---- Jean Couteau Code Lutin - http://www.codelutin.com 44 Bd des Pas Enchantés - 44230 St-Sébastien/Loire Tél : 02 40 50 29 28 - Fax : 09 59 92 29 28
OK, that makes sense.. In fact I think I saw something similar in the ToDo tutorial, I should have remembered that. Do you know how I would go about querying for the 5 most recently created documents of a given type within a space? What I'm trying to accomplish is something like: FAQs Space 1 * Doc 1 * Doc 2 * Doc 3 * Doc 4 * Doc 5 Space 2 * Doc 1 * Doc 2 * Doc 3 * Doc 4 * Doc 5 and so on... I know you can query for docs of a specific type but what about narrowing the search to a space? Thanks! .:. Kevin -- View this message in context: http://n2.nabble.com/Using-one-Class-and-Template-for-creating-documents-in-... Sent from the XWiki- Users mailing list archive at Nabble.com.
I would have a look to this sql request. #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='${doc.space}.${class}Class' and obj.name<>'${doc.space}.${class}ClassTemplate' and obj.space='Space 1') I am not sure as i do not have the same configuration, but i think it should be quite close, or maybe with obj.spaceName='Space 1' I am quite interested in your results cause i might implement something similar in the future. Hope this helps. Kevin_C a écrit :
OK, that makes sense.. In fact I think I saw something similar in the ToDo tutorial, I should have remembered that. Do you know how I would go about querying for the 5 most recently created documents of a given type within a space?
What I'm trying to accomplish is something like:
FAQs
Space 1 * Doc 1 * Doc 2 * Doc 3 * Doc 4 * Doc 5
Space 2 * Doc 1 * Doc 2 * Doc 3 * Doc 4 * Doc 5
and so on...
I know you can query for docs of a specific type but what about narrowing the search to a space?
Thanks! .:. Kevin
-- ---- Jean Couteau Code Lutin - http://www.codelutin.com 44 Bd des Pas Enchantés - 44230 St-Sébastien/Loire Tél : 02 40 50 29 28 - Fax : 09 59 92 29 28
I have installed the xwiki-eclipse-rcp-win32-win32-x86-1.2-rc-1.zip simply copiing the content of the ZIP file into a directory and I started xEclipse. I created a new connection to http://localhost:8080/xwiki/xmlrpc/confluence with username Admin and the password respectively. After starting it gives a warning: A conflict occurred for CTRL+P:Binding(CTRL+P, ParameterizedCommand(Command(org.eclipse.ui.file.print,Print, Print, but this seems to be fairly harmless. When I tried to edit an object and to alter a "select list" value it only listed the current value and did not display the possible values. When I pressed 'Add' and then 'Cancel' on the pop-up window it gave another error: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at org.xwiki.eclipse.ui.editors.propertyeditors.ListPropertyEditor$2.widgetSelected(Unknown Source) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.xwiki.eclipse.rcp.Application.start(Unknown Source) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:386) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504) at org.eclipse.equinox.launcher.Main.run(Main.java:1236) This is harmless, but this also happens when I try to add a value. This time it is not that harmless, because it prevents me to add a new value to the object. The format of the fields is nice and neat, but it has nothing to do with the ordering that I defined in the class the object belongs to. Then I double-click on a page to open it in wiki editing mode. It opens fine. Then I double click on the page again and I get the error: Problems occurred when invoking code from plug-in: "org.eclipse.jface". com.thoughtworks.xstream.io.StreamException: : Invalid byte 2 of 3-byte UTF-8 sequence. at com.thoughtworks.xstream.io.xml.DomDriver.createReader(DomDriver.java:88) at com.thoughtworks.xstream.io.xml.DomDriver.createReader(DomDriver.java:70) at com.thoughtworks.xstream.XStream.fromXML(XStream.java:869) at org.xwiki.eclipse.core.utils.CoreUtils.readDataFromXML(Unknown Source) at org.xwiki.eclipse.core.storage.LocalXWikiDataStorage.getPage(Unknown Source) at org.xwiki.eclipse.core.DataManager.getPage(Unknown Source) at org.xwiki.eclipse.ui.actions.OpenXWikiModelObjectAction.run(Unknown Source) at org.eclipse.ui.actions.RetargetAction.run(RetargetAction.java:221) at org.eclipse.ui.internal.navigator.CommonNavigatorManager$3.open(CommonNavigatorManager.java:184) at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredViewer.java:820) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.core.runtime.Platform.run(Platform.java:880) at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175) at org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:818) at org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:1079) at org.eclipse.ui.navigator.CommonViewer.handleOpen(CommonViewer.java:372) at org.eclipse.jface.viewers.StructuredViewer$6.handleOpen(StructuredViewer.java:1183) at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:263) at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.java:257) at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:297) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.xwiki.eclipse.rcp.Application.start(Unknown Source) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:386) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504) at org.eclipse.equinox.launcher.Main.run(Main.java:1236) Caused by: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 2 of 3-byte UTF-8 sequence. at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:674) at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:398) at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1742) at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipChar(XMLEntityScanner.java:1416) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2784) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107) at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:225) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:283) at com.thoughtworks.xstream.io.xml.DomDriver.createReader(DomDriver.java:79) ... 44 more It seems to be harmless, but I can not open the page again even if it was closed. I restart xeclipse and still: I can not open the page! This renders xeclipse UNUSABLE. Then I exit xeclipse and I go into the file system on my Windows XP and I delete the XEP file that seems to be the local copy of the page. First xEclipse tells me that there is some communication problem, and closes the connection. I reconnect and now I can open the page. Next time I try to connect to our external installation. This time the url is: https://myserver//xwiki/xmlrpc/confluence It opens fine and when I click on the '+' in front of the connection it shows the spaces. When I try to open a space it gives me an error: An internal error occurred during: "Fetching children of Main". org.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:3777) at org.eclipse.swt.SWT.error(SWT.java:3695) at org.eclipse.swt.SWT.error(SWT.java:3666) at org.eclipse.swt.widgets.Display.error(Display.java:1180) at org.eclipse.swt.widgets.Display.checkDevice(Display.java:703) at org.eclipse.swt.widgets.Display.getActiveShell(Display.java:1349) at org.xwiki.eclipse.ui.adapters.XWikiEclipseSpaceSummaryAdapter.getChildren(Unknown Source) at org.xwiki.eclipse.ui.adapters.XWikiEclipseSpaceSummaryAdapter.fetchDeferredChildren(Unknown Source) at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:234) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Jean, Perfect! Had to make a couple little modifications but that was pretty spot on.. Here's what I ended up with: #set($hql = ", BaseObject as obj where obj.name=doc.fullName and obj.name<>'${doc.space}.${class}ClassTemplate' and doc.space='MySpace'") Thanks again! .:. Kevin -- View this message in context: http://n2.nabble.com/Using-one-Class-and-Template-for-creating-documents-in-... Sent from the XWiki- Users mailing list archive at Nabble.com.
You might want to start your own thread for this so people who might be more familiar with your issue can respond. I've never tried to use XEclipse as a plugin because I don't have Eclipse Ganymede installed. Sorry for no help! -- View this message in context: http://n2.nabble.com/Using-one-Class-and-Template-for-creating-documents-in-... Sent from the XWiki- Users mailing list archive at Nabble.com.
I believe I sent this mail to the users list. Didn't I? Btw: You need not install Eclipse Ganymede. Just download the ZIP file, extract it to a directory and start xeclipse.exe It is a clean and nice piece of software that does not make nasty traces of itself into files, registry or anywhere else. This is true for Windows XP as I tried, but I believe has to be true for unices as well. Neverthelsess there are a lot of problems in this rc1 version. Peter Kevin_C wrote:
You might want to start your own thread for this so people who might be more familiar with your issue can respond. I've never tried to use XEclipse as a plugin because I don't have Eclipse Ganymede installed.
Sorry for no help!
Well, it went to the users list but it's showing up under a thread I started in the forum view. Maybe it's just messed up. In order to use XEclipse as a plugin you have to have the Ganymede version of Eclipse. The way you are running it you aren't actually running it as a plugin. To run it as a plugin you unzip it to the plugins folder and then open Eclipse, and you should have a new Perspective for XEclipse. By running xeclipse.exe you are just running XEclipse in stand alone mode. .:. Kevin -- View this message in context: http://n2.nabble.com/Using-one-Class-and-Template-for-creating-documents-in-... Sent from the XWiki- Users mailing list archive at Nabble.com.
Jean Couteau wrote:
I would have a look to this sql request.
#set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='${doc.space}.${class}Class' and obj.name<>'${doc.space}.${class}ClassTemplate' and obj.space='Space 1')
I am not sure as i do not have the same configuration, but i think it should be quite close, or maybe with obj.spaceName='Space 1'
To better understand these queries, you should look at the hibernate mapping files and the HQL documentation. http://svn.xwiki.org/svnroot/xwiki/platform/core/trunk/xwiki-core/src/main/r... http://www.hibernate.org/hib_docs/reference/en/html/queryhql.html We're lacking documentation on this, and queries using HQL are pretty much developer oriented. We're working on alternative querying models which are already available, but not ready for general use yet.
I am quite interested in your results cause i might implement something similar in the future.
Hope this helps.
Kevin_C a écrit :
OK, that makes sense.. In fact I think I saw something similar in the ToDo tutorial, I should have remembered that. Do you know how I would go about querying for the 5 most recently created documents of a given type within a space?
What I'm trying to accomplish is something like:
FAQs
Space 1 * Doc 1 * Doc 2 * Doc 3 * Doc 4 * Doc 5
Space 2 * Doc 1 * Doc 2 * Doc 3 * Doc 4 * Doc 5
and so on...
I know you can query for docs of a specific type but what about narrowing the search to a space?
Thanks! .:. Kevin
-- Sergiu Dumitriu http://purl.org/net/sergiu/
Verhás Péter wrote: Hi Peter, first of all thank you for your feedback.
After starting it gives a warning: A conflict occurred for CTRL+P:Binding(CTRL+P, ParameterizedCommand(Command(org.eclipse.ui.file.print,Print, Print, but this seems to be fairly harmless.
This is strange since the command is bound to M1+CTRL+P. Anyway I'll check it.
When I tried to edit an object and to alter a "select list" value it only listed the current value and did not display the possible values. When I pressed 'Add' and then 'Cancel' on the pop-up window it gave another error:
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List at org.xwiki.eclipse.ui.editors.propertyeditors.ListPropertyEditor$2.widgetSelected(Unknown Source)
This is bad actually. What was the class of the object you were trying to edit and the type of the field?
This is harmless, but this also happens when I try to add a value. This time it is not that harmless, because it prevents me to add a new value to the object. The format of the fields is nice and neat, but it has nothing to do with the ordering that I defined in the class the object belongs to.
Ok will fix this.
Then I double-click on a page to open it in wiki editing mode. It opens fine. Then I double click on the page again and I get the error:
Problems occurred when invoking code from plug-in: "org.eclipse.jface".
com.thoughtworks.xstream.io.StreamException: : Invalid byte 2 of 3-byte UTF-8 sequence. at com.thoughtworks.xstream.io.xml.DomDriver.createReader(DomDriver.java:88) at com.thoughtworks.xstream.io.xml.DomDriver.createReader(DomDriver.java:70) at com.thoughtworks.xstream.XStream.fromXML(XStream.java:869) at org.xwiki.eclipse.core.utils.CoreUtils.readDataFromXML(Unknown Source) at org.xwiki.eclipse.core.storage.LocalXWikiDataStorage.getPage(Unknown Source) at org.xwiki.eclipse.core.DataManager.getPage(Unknown Source)
This looks like some kind of encoding problem that XStream is not able to handle. It's strange because I delegate XStream all the serialization/deserialization work so I don't want that this is due to an XStream bug. Could you please send me the page that creates the issue?
Next time I try to connect to our external installation. This time the url is: https://myserver//xwiki/xmlrpc/confluence
It opens fine and when I click on the '+' in front of the connection it shows the spaces. When I try to open a space it gives me an error:
An internal error occurred during: "Fetching children of Main". org.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:3777) at org.eclipse.swt.SWT.error(SWT.java:3695) at org.eclipse.swt.SWT.error(SWT.java:3666) at org.eclipse.swt.widgets.Display.error(Display.java:1180) at org.eclipse.swt.widgets.Display.checkDevice(Display.java:703) at org.eclipse.swt.widgets.Display.getActiveShell(Display.java:1349) at org.xwiki.eclipse.ui.adapters.XWikiEclipseSpaceSummaryAdapter.getChildren(Unknown Source) at org.xwiki.eclipse.ui.adapters.XWikiEclipseSpaceSummaryAdapter.fetchDeferredChildren(Unknown Source) at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:234) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
This is hard :( It looks like the interaction between the DeferredTreeContentManager and the Viewer has some issues. But this is an eclipse provided class... It will take some time to investigate this because AFAIU it's not easily reproducible as well. Thank you for your feedback. I will try to address these problems asap. -Fabio
Well, in order to create any kind of customizations for xwiki you have to understand how this works because everything is stored in the DB.. I'm a developer but I've only worked with Hibernate a very little bit, I'm looking forward to either some more detailed documentation on how to access various common bits of information via HQL or an alternative method to query for that information. Thanks for your reply! .:. Kevin -- View this message in context: http://n2.nabble.com/Using-one-Class-and-Template-for-creating-documents-in-... Sent from the XWiki- Users mailing list archive at Nabble.com.
participants (5)
-
Fabio Mancinelli -
Jean Couteau -
Kevin_C -
Sergiu Dumitriu -
Verhás Péter