[xwiki-devs] XWiki/XEclipse template/form system.
Hello, I'm currently reading about XWiki and XEclipse and would like to ask if there is any consensus about XWiki pages templates which might also be usable from XEclipse probably after some code hacking on its plugins. I'm currently working on some project for my client (source code will be contributed/available later in the project stage) where there is a need to use XEclipse and enhance it to support some predefined forms/templates for web pages creation. So far I've found just XWiki FAQ tutorial on http://platform.xwiki.org/xwiki/bin/view/DevGuide/FAQTutorial which tries to deals with some kind of templates. However this looks quite general at least so far to me and so I would like to ask the question above about consensus where and how to go with templates in xwiki/xeclipse. My current idea is to stick with the XWiki server as a provider of templates to preserve ability to use templates from both browser and xeclipse and to enhance xeclipse new page creation wizard to provide a list of available templates on the server side... Thanks for any idea where to start or where to look for more information with regarding to this project task. Karel
Hello, I'm back to this task. I've searched JIRA for related RFE/BUG but have not found anything so I created my own: http://jira.xwiki.org/jira/browse/XECLIPSE-152 My basic idea about UI is that XEclipse New Page wizard will be enhanced to provide a field "Template" where user will be able to select appropriate template provider (as they are set in Administration > Content > Templates). If he/she sets some, then while clicking on Next button (to be added) it'll render the page of the template provider form to the wizard window, the user will be able to fill it and then hit Finish button to actually save the page. Now the question is how to achieve it? Any idea where to start hacking or where to look for more information is highly appreciated here. Thanks, Karel On 04/26/11 05:38 PM, Karel Gardas wrote:
Hello,
I'm currently reading about XWiki and XEclipse and would like to ask if there is any consensus about XWiki pages templates which might also be usable from XEclipse probably after some code hacking on its plugins.
I'm currently working on some project for my client (source code will be contributed/available later in the project stage) where there is a need to use XEclipse and enhance it to support some predefined forms/templates for web pages creation. So far I've found just XWiki FAQ tutorial on http://platform.xwiki.org/xwiki/bin/view/DevGuide/FAQTutorial which tries to deals with some kind of templates. However this looks quite general at least so far to me and so I would like to ask the question above about consensus where and how to go with templates in xwiki/xeclipse.
My current idea is to stick with the XWiki server as a provider of templates to preserve ability to use templates from both browser and xeclipse and to enhance xeclipse new page creation wizard to provide a list of available templates on the server side...
Thanks for any idea where to start or where to look for more information with regarding to this project task.
Karel
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Hi Karel, On 06/02/2011 07:54 PM, Karel Gardas wrote:
Hello,
I'm back to this task. I've searched JIRA for related RFE/BUG but have not found anything so I created my own: http://jira.xwiki.org/jira/browse/XECLIPSE-152
My basic idea about UI is that XEclipse New Page wizard will be enhanced to provide a field "Template" where user will be able to select appropriate template provider (as they are set in Administration> Content> Templates). In order to get the list of templates in XEclipse, you would need a service that does internally a HQL like this:
#set($availableProviders = $xwiki.searchDocuments(", BaseObject obj where doc.fullName=obj.name and obj.className='XWiki.TemplateProviderClass' and doc.fullName!='XWiki.TemplateProviderTemplate'")) (taken from XWiki.AdminTemplatesSheet, the page that displays the content in Administration > Content > Templates) The service can be either a REST extension (java component) or a wiki page called with ?xpage=plain (to return the result in some custom xml or just csv).
If he/she sets some, then while clicking on Next button (to be added) it'll render the page of the template provider form to the wizard window, the user will be able to fill it and then hit Finish button to actually save the page. Both to avoid reimplementing the template mechanism and the rendering of the template form, one rather simple solution would be to display in an SWT Browser control the result of a page like http://localhost:8080/xwiki/bin/inline/Main/MyNewPage?parent=Main.AParentPag... (the type of link generated by the create page dialog in XWiki). Basically you show the XWiki page inside your wizard. The problem with this approach is that you end up with unnecessary header, panels and footer when you`re only interested in the page content. Besides that, you also have the save, save&continue and cancel buttons that are kind of conflicting with your wizard's buttons and flow.
Not sure about this, but one solution may be to extract from the big HTML, only the document content, excluding the bottom buttons. You`d better inspect (with firebug) the structure of the page to see what you need and what you don`t. A second partial solution would be to append ?xpage=plain to the above link and you will end up only with the rendered document content in inline mode (so you can have inputs and such). The only disadvantage I see here is that, if your template uses non-inline javascript (trough a JavaScriptExtension for example or the js already available in XWiki), it will not be available in the rendered version. Whichever you choose from the two solutions, you can then implement the Finish button of the wizard to launch a HTTP request and simulate the Save button from XWiki's page (passing all the needed parameters, including the parameters in the page the user just filled in). You can additionally stylize the displayed HTML so that it better integrates with the Eclipse wizard.
Now the question is how to achieve it? Any idea where to start hacking or where to look for more information is highly appreciated here. This is the only thing I can think of right now. Hope it helps.
Thanks, Eduard
Thanks, Karel
On 04/26/11 05:38 PM, Karel Gardas wrote:
Hello,
I'm currently reading about XWiki and XEclipse and would like to ask if there is any consensus about XWiki pages templates which might also be usable from XEclipse probably after some code hacking on its plugins.
I'm currently working on some project for my client (source code will be contributed/available later in the project stage) where there is a need to use XEclipse and enhance it to support some predefined forms/templates for web pages creation. So far I've found just XWiki FAQ tutorial on http://platform.xwiki.org/xwiki/bin/view/DevGuide/FAQTutorial which tries to deals with some kind of templates. However this looks quite general at least so far to me and so I would like to ask the question above about consensus where and how to go with templates in xwiki/xeclipse.
My current idea is to stick with the XWiki server as a provider of templates to preserve ability to use templates from both browser and xeclipse and to enhance xeclipse new page creation wizard to provide a list of available templates on the server side...
Thanks for any idea where to start or where to look for more information with regarding to this project task.
Karel
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Hi Eduard, thanks a lot for your advices given below. At this project state I'm going with as simple as possible solution so I created special simple web page for listing all the template providers as per your advice and this runs well. On the other hand I do have some issue running running SWT browser as part of new page wizard. The problem is authentication, or better its lack of. Although I pass to the browser correct page URL, the output of the browser is always: HTTP Status 404 - /xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik... type Status report message /xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik... description The requested resource (/xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...) is not available. Apache Tomcat/7.0.12 Anyway, I tested the URL in external browser and it's working fine there -- please note I'm logged in in this browser. I've attempted to hack the code to convince browser to authenticate by using authentication listener: browser = new Browser(browserComposite, SWT.NONE); browser.addAuthenticationListener(new AuthenticationListener() { public void authenticate(AuthenticationEvent event) { // TODO Auto-generated method stub System.err.println("AuthenticationListener::authenticate: " + event.toString()); event.user = "Admin"; event.password = "admin"; event.doit = true; } }); but this is not even invoked. Do you have any idea how to solve this? I see that preview browser is always running in non-authenticated mode (or what I've researched so far) although connection in Explorer is authenticated... If you are curious I'm free to submit all changes in a form of preferred diff to the original RFE, especially if it helps you advice me how to proceed from here... Thanks! Karel On 06/ 2/11 10:14 PM, Eduard Moraru wrote:
Hi Karel,
On 06/02/2011 07:54 PM, Karel Gardas wrote:
Hello,
I'm back to this task. I've searched JIRA for related RFE/BUG but have not found anything so I created my own: http://jira.xwiki.org/jira/browse/XECLIPSE-152
My basic idea about UI is that XEclipse New Page wizard will be enhanced to provide a field "Template" where user will be able to select appropriate template provider (as they are set in Administration> Content> Templates). In order to get the list of templates in XEclipse, you would need a service that does internally a HQL like this:
#set($availableProviders = $xwiki.searchDocuments(", BaseObject obj where doc.fullName=obj.name and obj.className='XWiki.TemplateProviderClass' and doc.fullName!='XWiki.TemplateProviderTemplate'")) (taken from XWiki.AdminTemplatesSheet, the page that displays the content in Administration> Content> Templates)
The service can be either a REST extension (java component) or a wiki page called with ?xpage=plain (to return the result in some custom xml or just csv).
If he/she sets some, then while clicking on Next button (to be added) it'll render the page of the template provider form to the wizard window, the user will be able to fill it and then hit Finish button to actually save the page. Both to avoid reimplementing the template mechanism and the rendering of the template form, one rather simple solution would be to display in an SWT Browser control the result of a page like http://localhost:8080/xwiki/bin/inline/Main/MyNewPage?parent=Main.AParentPag... (the type of link generated by the create page dialog in XWiki). Basically you show the XWiki page inside your wizard. The problem with this approach is that you end up with unnecessary header, panels and footer when you`re only interested in the page content. Besides that, you also have the save, save&continue and cancel buttons that are kind of conflicting with your wizard's buttons and flow.
Not sure about this, but one solution may be to extract from the big HTML, only the document content, excluding the bottom buttons. You`d better inspect (with firebug) the structure of the page to see what you need and what you don`t.
A second partial solution would be to append ?xpage=plain to the above link and you will end up only with the rendered document content in inline mode (so you can have inputs and such). The only disadvantage I see here is that, if your template uses non-inline javascript (trough a JavaScriptExtension for example or the js already available in XWiki), it will not be available in the rendered version.
Whichever you choose from the two solutions, you can then implement the Finish button of the wizard to launch a HTTP request and simulate the Save button from XWiki's page (passing all the needed parameters, including the parameters in the page the user just filled in).
You can additionally stylize the displayed HTML so that it better integrates with the Eclipse wizard.
Now the question is how to achieve it? Any idea where to start hacking or where to look for more information is highly appreciated here. This is the only thing I can think of right now. Hope it helps.
Thanks, Eduard
Thanks, Karel
On 04/26/11 05:38 PM, Karel Gardas wrote:
Hello,
I'm currently reading about XWiki and XEclipse and would like to ask if there is any consensus about XWiki pages templates which might also be usable from XEclipse probably after some code hacking on its plugins.
I'm currently working on some project for my client (source code will be contributed/available later in the project stage) where there is a need to use XEclipse and enhance it to support some predefined forms/templates for web pages creation. So far I've found just XWiki FAQ tutorial on http://platform.xwiki.org/xwiki/bin/view/DevGuide/FAQTutorial which tries to deals with some kind of templates. However this looks quite general at least so far to me and so I would like to ask the question above about consensus where and how to go with templates in xwiki/xeclipse.
My current idea is to stick with the XWiki server as a provider of templates to preserve ability to use templates from both browser and xeclipse and to enhance xeclipse new page creation wizard to provide a list of available templates on the server side...
Thanks for any idea where to start or where to look for more information with regarding to this project task.
Karel
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Hi Karel, On 06/13/2011 04:17 PM, Karel Gardas wrote:
Hi Eduard,
thanks a lot for your advices given below. At this project state I'm going with as simple as possible solution so I created special simple web page for listing all the template providers as per your advice and this runs well. On the other hand I do have some issue running running SWT browser as part of new page wizard. The problem is authentication, or better its lack of. Although I pass to the browser correct page URL, the output of the browser is always:
HTTP Status 404 - /xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...
type Status report
message /xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...
description The requested resource (/xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...) is not available. Apache Tomcat/7.0.12
Well, from what I can see, you are trying to access a malformed URL. "/xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik..." seems to have 2 problems: 1) the first part "/xwiki-enterprise-web-3.1-SNAPSHOT" does not belong here. 2) the webapp part of the URL: "http://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...", more exactly "xwiki-enterprise-web-3.1-SNAPSHOT", if you did not modify the default db in xwiki.cfg, should be just "xwiki". So, the correct URL should be: "http://localhost:8080/xwiki/bin/login/XWiki/XWikiLogin" Now, regarding authentication... A solution is to send, with each HTTP request that you do, a HTTP Auth header providing user/password. You can also choose to send it only once per session and reuse the session cookie that XWiki will return after the first request that contains the HTTP auth header. If you use the SWT Browser to directly access an XWiki page, you can pass the HTTP Auth header by using the setUrl(...) method trough something like this: browser.setUrl("http://localhost:8080/xwiki/bin/view/XWiki/APrivatePage", null, new String[] {"Authorization: Basic QWRtaW46YWRtaW4="}); the QWRtaW46YWRtaW4= is the Base64 encoding of Admin:admin. You can generate you own Base64 encoding of a user:password combination and pass that instead. If you choose to use a simple HTTP client to retrieve the HTML of a page and the render it with a browser, you`ll have to pass the user:password to that client instead.
Anyway, I tested the URL in external browser and it's working fine there -- please note I'm logged in in this browser.
I've attempted to hack the code to convince browser to authenticate by using authentication listener:
browser = new Browser(browserComposite, SWT.NONE); browser.addAuthenticationListener(new AuthenticationListener() {
public void authenticate(AuthenticationEvent event) { // TODO Auto-generated method stub
System.err.println("AuthenticationListener::authenticate: " + event.toString()); event.user = "Admin"; event.password = "admin"; event.doit = true; } });
but this is not even invoked. Do you have any idea how to solve this?
The authentication listener would not trigger because XWiki does not return 401 Unauthorized when tryin to access a restricted page, but instead provides it's own authentication ui/page. However, passing an Authorization header to a restricted page will automatically perform the login and you can then reuse the session token instead of passing the user/password for each request.
I see that preview browser is always running in non-authenticated mode (or what I've researched so far) although connection in Explorer is authenticated...
Yes, it might be a nice to have feature (authenticated preview window). Could you please add a jira issue for it? http://jira.xwiki.org/jira/browse/XECLIPSE Thanks, Eduard
If you are curious I'm free to submit all changes in a form of preferred diff to the original RFE, especially if it helps you advice me how to proceed from here...
Thanks! Karel
On 06/ 2/11 10:14 PM, Eduard Moraru wrote:
Hi Karel,
On 06/02/2011 07:54 PM, Karel Gardas wrote:
Hello,
I'm back to this task. I've searched JIRA for related RFE/BUG but have not found anything so I created my own: http://jira.xwiki.org/jira/browse/XECLIPSE-152
My basic idea about UI is that XEclipse New Page wizard will be enhanced to provide a field "Template" where user will be able to select appropriate template provider (as they are set in Administration> Content> Templates). In order to get the list of templates in XEclipse, you would need a service that does internally a HQL like this:
#set($availableProviders = $xwiki.searchDocuments(", BaseObject obj where doc.fullName=obj.name and obj.className='XWiki.TemplateProviderClass' and doc.fullName!='XWiki.TemplateProviderTemplate'")) (taken from XWiki.AdminTemplatesSheet, the page that displays the content in Administration> Content> Templates)
The service can be either a REST extension (java component) or a wiki page called with ?xpage=plain (to return the result in some custom xml or just csv).
If he/she sets some, then while clicking on Next button (to be added) it'll render the page of the template provider form to the wizard window, the user will be able to fill it and then hit Finish button to actually save the page. Both to avoid reimplementing the template mechanism and the rendering of the template form, one rather simple solution would be to display in an SWT Browser control the result of a page like http://localhost:8080/xwiki/bin/inline/Main/MyNewPage?parent=Main.AParentPag...
(the type of link generated by the create page dialog in XWiki). Basically you show the XWiki page inside your wizard. The problem with this approach is that you end up with unnecessary header, panels and footer when you`re only interested in the page content. Besides that, you also have the save, save&continue and cancel buttons that are kind of conflicting with your wizard's buttons and flow.
Not sure about this, but one solution may be to extract from the big HTML, only the document content, excluding the bottom buttons. You`d better inspect (with firebug) the structure of the page to see what you need and what you don`t.
A second partial solution would be to append ?xpage=plain to the above link and you will end up only with the rendered document content in inline mode (so you can have inputs and such). The only disadvantage I see here is that, if your template uses non-inline javascript (trough a JavaScriptExtension for example or the js already available in XWiki), it will not be available in the rendered version.
Whichever you choose from the two solutions, you can then implement the Finish button of the wizard to launch a HTTP request and simulate the Save button from XWiki's page (passing all the needed parameters, including the parameters in the page the user just filled in).
You can additionally stylize the displayed HTML so that it better integrates with the Eclipse wizard.
Now the question is how to achieve it? Any idea where to start hacking or where to look for more information is highly appreciated here. This is the only thing I can think of right now. Hope it helps.
Thanks, Eduard
Thanks, Karel
On 04/26/11 05:38 PM, Karel Gardas wrote:
Hello,
I'm currently reading about XWiki and XEclipse and would like to ask if there is any consensus about XWiki pages templates which might also be usable from XEclipse probably after some code hacking on its plugins.
I'm currently working on some project for my client (source code will be contributed/available later in the project stage) where there is a need to use XEclipse and enhance it to support some predefined forms/templates for web pages creation. So far I've found just XWiki FAQ tutorial on http://platform.xwiki.org/xwiki/bin/view/DevGuide/FAQTutorial which tries to deals with some kind of templates. However this looks quite general at least so far to me and so I would like to ask the question above about consensus where and how to go with templates in xwiki/xeclipse.
My current idea is to stick with the XWiki server as a provider of templates to preserve ability to use templates from both browser and xeclipse and to enhance xeclipse new page creation wizard to provide a list of available templates on the server side...
Thanks for any idea where to start or where to look for more information with regarding to this project task.
Karel
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Hi Eduard, thanks a lot for your prompt reply. The URL I pass directly into browser's setUrl method is correct. The problem is this is somehow corrupted xwiki server reply -- I'm talking about this attempt to load login page. I really set just http://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/.... Thanks to your help with authentication in setUrl, I've used that and now I see the browser correctly load the page. Now the problem appears when I click on <save and view> (or <preview>, <save and continue>), the result of this is always redirection to the login page which fails with the same result like before: HTTP Status 404 - /xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik... type Status report message /xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik... description The requested resource (/xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...) is not available. Apache Tomcat/7.0.12 Now my question is how to get the session cookie back from the browser after displaying the page? It seems I can use .getCookie method, but I don't know cookie's name in this case. Also I've submitted http://jira.xwiki.org/jira/browse/XECLIPSE-153 -- as per your advice. Thanks! Karel On 06/14/11 11:21 AM, Eduard Moraru wrote:
Hi Karel,
On 06/13/2011 04:17 PM, Karel Gardas wrote:
Hi Eduard,
thanks a lot for your advices given below. At this project state I'm going with as simple as possible solution so I created special simple web page for listing all the template providers as per your advice and this runs well. On the other hand I do have some issue running running SWT browser as part of new page wizard. The problem is authentication, or better its lack of. Although I pass to the browser correct page URL, the output of the browser is always:
HTTP Status 404 - /xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...
type Status report
message /xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...
description The requested resource (/xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...) is not available. Apache Tomcat/7.0.12
Well, from what I can see, you are trying to access a malformed URL. "/xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik..." seems to have 2 problems: 1) the first part "/xwiki-enterprise-web-3.1-SNAPSHOT" does not belong here. 2) the webapp part of the URL: "http://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...", more exactly "xwiki-enterprise-web-3.1-SNAPSHOT", if you did not modify the default db in xwiki.cfg, should be just "xwiki". So, the correct URL should be: "http://localhost:8080/xwiki/bin/login/XWiki/XWikiLogin"
Now, regarding authentication... A solution is to send, with each HTTP request that you do, a HTTP Auth header providing user/password. You can also choose to send it only once per session and reuse the session cookie that XWiki will return after the first request that contains the HTTP auth header.
If you use the SWT Browser to directly access an XWiki page, you can pass the HTTP Auth header by using the setUrl(...) method trough something like this: browser.setUrl("http://localhost:8080/xwiki/bin/view/XWiki/APrivatePage", null, new String[] {"Authorization: Basic QWRtaW46YWRtaW4="}); the QWRtaW46YWRtaW4= is the Base64 encoding of Admin:admin. You can generate you own Base64 encoding of a user:password combination and pass that instead. If you choose to use a simple HTTP client to retrieve the HTML of a page and the render it with a browser, you`ll have to pass the user:password to that client instead.
Anyway, I tested the URL in external browser and it's working fine there -- please note I'm logged in in this browser.
I've attempted to hack the code to convince browser to authenticate by using authentication listener:
browser = new Browser(browserComposite, SWT.NONE); browser.addAuthenticationListener(new AuthenticationListener() {
public void authenticate(AuthenticationEvent event) { // TODO Auto-generated method stub
System.err.println("AuthenticationListener::authenticate: " + event.toString()); event.user = "Admin"; event.password = "admin"; event.doit = true; } });
but this is not even invoked. Do you have any idea how to solve this?
The authentication listener would not trigger because XWiki does not return 401 Unauthorized when tryin to access a restricted page, but instead provides it's own authentication ui/page. However, passing an Authorization header to a restricted page will automatically perform the login and you can then reuse the session token instead of passing the user/password for each request.
I see that preview browser is always running in non-authenticated mode (or what I've researched so far) although connection in Explorer is authenticated...
Yes, it might be a nice to have feature (authenticated preview window). Could you please add a jira issue for it? http://jira.xwiki.org/jira/browse/XECLIPSE
Thanks, Eduard
If you are curious I'm free to submit all changes in a form of preferred diff to the original RFE, especially if it helps you advice me how to proceed from here...
Thanks! Karel
On 06/ 2/11 10:14 PM, Eduard Moraru wrote:
Hi Karel,
On 06/02/2011 07:54 PM, Karel Gardas wrote:
Hello,
I'm back to this task. I've searched JIRA for related RFE/BUG but have not found anything so I created my own: http://jira.xwiki.org/jira/browse/XECLIPSE-152
My basic idea about UI is that XEclipse New Page wizard will be enhanced to provide a field "Template" where user will be able to select appropriate template provider (as they are set in Administration> Content> Templates). In order to get the list of templates in XEclipse, you would need a service that does internally a HQL like this:
#set($availableProviders = $xwiki.searchDocuments(", BaseObject obj where doc.fullName=obj.name and obj.className='XWiki.TemplateProviderClass' and doc.fullName!='XWiki.TemplateProviderTemplate'")) (taken from XWiki.AdminTemplatesSheet, the page that displays the content in Administration> Content> Templates)
The service can be either a REST extension (java component) or a wiki page called with ?xpage=plain (to return the result in some custom xml or just csv).
If he/she sets some, then while clicking on Next button (to be added) it'll render the page of the template provider form to the wizard window, the user will be able to fill it and then hit Finish button to actually save the page.
Both to avoid reimplementing the template mechanism and the rendering of the template form, one rather simple solution would be to display in an SWT Browser control the result of a page like http://localhost:8080/xwiki/bin/inline/Main/MyNewPage?parent=Main.AParentPag...
(the type of link generated by the create page dialog in XWiki). Basically you show the XWiki page inside your wizard. The problem with this approach is that you end up with unnecessary header, panels and footer when you`re only interested in the page content. Besides that, you also have the save, save&continue and cancel buttons that are kind of conflicting with your wizard's buttons and flow.
Not sure about this, but one solution may be to extract from the big HTML, only the document content, excluding the bottom buttons. You`d better inspect (with firebug) the structure of the page to see what you need and what you don`t.
A second partial solution would be to append ?xpage=plain to the above link and you will end up only with the rendered document content in inline mode (so you can have inputs and such). The only disadvantage I see here is that, if your template uses non-inline javascript (trough a JavaScriptExtension for example or the js already available in XWiki), it will not be available in the rendered version.
Whichever you choose from the two solutions, you can then implement the Finish button of the wizard to launch a HTTP request and simulate the Save button from XWiki's page (passing all the needed parameters, including the parameters in the page the user just filled in).
You can additionally stylize the displayed HTML so that it better integrates with the Eclipse wizard.
Now the question is how to achieve it? Any idea where to start hacking or where to look for more information is highly appreciated here. This is the only thing I can think of right now. Hope it helps.
Thanks, Eduard
Thanks, Karel
On 04/26/11 05:38 PM, Karel Gardas wrote:
Hello,
I'm currently reading about XWiki and XEclipse and would like to ask if there is any consensus about XWiki pages templates which might also be usable from XEclipse probably after some code hacking on its plugins.
I'm currently working on some project for my client (source code will be contributed/available later in the project stage) where there is a need to use XEclipse and enhance it to support some predefined forms/templates for web pages creation. So far I've found just XWiki FAQ tutorial on http://platform.xwiki.org/xwiki/bin/view/DevGuide/FAQTutorial which tries to deals with some kind of templates. However this looks quite general at least so far to me and so I would like to ask the question above about consensus where and how to go with templates in xwiki/xeclipse.
My current idea is to stick with the XWiki server as a provider of templates to preserve ability to use templates from both browser and xeclipse and to enhance xeclipse new page creation wizard to provide a list of available templates on the server side...
Thanks for any idea where to start or where to look for more information with regarding to this project task.
Karel
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
On 06/15/2011 09:58 AM, Karel Gardas wrote:
Hi Eduard,
thanks a lot for your prompt reply. The URL I pass directly into browser's setUrl method is correct. The problem is this is somehow corrupted xwiki server reply -- I'm talking about this attempt to load login page. I really set just http://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/....
Thanks to your help with authentication in setUrl, I've used that and now I see the browser correctly load the page. Now the problem appears when I click on<save and view> (or<preview>,<save and continue>), the result of this is always redirection to the login page which fails with the same result like before:
HTTP Status 404 - /xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...
There are still some problems when the webapp name contains dashes. Try to rename the application to something without dashes, like simply "xwiki".
type Status report
message /xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...
description The requested resource (/xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...) is not available. Apache Tomcat/7.0.12
Now my question is how to get the session cookie back from the browser after displaying the page? It seems I can use .getCookie method, but I don't know cookie's name in this case.
Also I've submitted http://jira.xwiki.org/jira/browse/XECLIPSE-153 -- as per your advice.
Thanks! Karel
On 06/14/11 11:21 AM, Eduard Moraru wrote:
Hi Karel,
On 06/13/2011 04:17 PM, Karel Gardas wrote:
Hi Eduard,
thanks a lot for your advices given below. At this project state I'm going with as simple as possible solution so I created special simple web page for listing all the template providers as per your advice and this runs well. On the other hand I do have some issue running running SWT browser as part of new page wizard. The problem is authentication, or better its lack of. Although I pass to the browser correct page URL, the output of the browser is always:
HTTP Status 404 - /xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...
type Status report
message /xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...
description The requested resource (/xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...) is not available. Apache Tomcat/7.0.12
Well, from what I can see, you are trying to access a malformed URL. "/xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik..." seems to have 2 problems: 1) the first part "/xwiki-enterprise-web-3.1-SNAPSHOT" does not belong here. 2) the webapp part of the URL: "http://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...", more exactly "xwiki-enterprise-web-3.1-SNAPSHOT", if you did not modify the default db in xwiki.cfg, should be just "xwiki". So, the correct URL should be: "http://localhost:8080/xwiki/bin/login/XWiki/XWikiLogin"
Now, regarding authentication... A solution is to send, with each HTTP request that you do, a HTTP Auth header providing user/password. You can also choose to send it only once per session and reuse the session cookie that XWiki will return after the first request that contains the HTTP auth header.
If you use the SWT Browser to directly access an XWiki page, you can pass the HTTP Auth header by using the setUrl(...) method trough something like this: browser.setUrl("http://localhost:8080/xwiki/bin/view/XWiki/APrivatePage", null, new String[] {"Authorization: Basic QWRtaW46YWRtaW4="}); the QWRtaW46YWRtaW4= is the Base64 encoding of Admin:admin. You can generate you own Base64 encoding of a user:password combination and pass that instead. If you choose to use a simple HTTP client to retrieve the HTML of a page and the render it with a browser, you`ll have to pass the user:password to that client instead.
Anyway, I tested the URL in external browser and it's working fine there -- please note I'm logged in in this browser.
I've attempted to hack the code to convince browser to authenticate by using authentication listener:
browser = new Browser(browserComposite, SWT.NONE); browser.addAuthenticationListener(new AuthenticationListener() {
public void authenticate(AuthenticationEvent event) { // TODO Auto-generated method stub
System.err.println("AuthenticationListener::authenticate: " + event.toString()); event.user = "Admin"; event.password = "admin"; event.doit = true; } });
but this is not even invoked. Do you have any idea how to solve this?
The authentication listener would not trigger because XWiki does not return 401 Unauthorized when tryin to access a restricted page, but instead provides it's own authentication ui/page. However, passing an Authorization header to a restricted page will automatically perform the login and you can then reuse the session token instead of passing the user/password for each request.
I see that preview browser is always running in non-authenticated mode (or what I've researched so far) although connection in Explorer is authenticated...
Yes, it might be a nice to have feature (authenticated preview window). Could you please add a jira issue for it? http://jira.xwiki.org/jira/browse/XECLIPSE
Thanks, Eduard
If you are curious I'm free to submit all changes in a form of preferred diff to the original RFE, especially if it helps you advice me how to proceed from here...
Thanks! Karel
On 06/ 2/11 10:14 PM, Eduard Moraru wrote:
Hi Karel,
On 06/02/2011 07:54 PM, Karel Gardas wrote:
Hello,
I'm back to this task. I've searched JIRA for related RFE/BUG but have not found anything so I created my own: http://jira.xwiki.org/jira/browse/XECLIPSE-152
My basic idea about UI is that XEclipse New Page wizard will be enhanced to provide a field "Template" where user will be able to select appropriate template provider (as they are set in Administration> Content> Templates). In order to get the list of templates in XEclipse, you would need a service that does internally a HQL like this:
#set($availableProviders = $xwiki.searchDocuments(", BaseObject obj where doc.fullName=obj.name and obj.className='XWiki.TemplateProviderClass' and doc.fullName!='XWiki.TemplateProviderTemplate'")) (taken from XWiki.AdminTemplatesSheet, the page that displays the content in Administration> Content> Templates)
The service can be either a REST extension (java component) or a wiki page called with ?xpage=plain (to return the result in some custom xml or just csv).
If he/she sets some, then while clicking on Next button (to be added) it'll render the page of the template provider form to the wizard window, the user will be able to fill it and then hit Finish button to actually save the page.
Both to avoid reimplementing the template mechanism and the rendering of the template form, one rather simple solution would be to display in an SWT Browser control the result of a page like http://localhost:8080/xwiki/bin/inline/Main/MyNewPage?parent=Main.AParentPag...
(the type of link generated by the create page dialog in XWiki). Basically you show the XWiki page inside your wizard. The problem with this approach is that you end up with unnecessary header, panels and footer when you`re only interested in the page content. Besides that, you also have the save, save&continue and cancel buttons that are kind of conflicting with your wizard's buttons and flow.
Not sure about this, but one solution may be to extract from the big HTML, only the document content, excluding the bottom buttons. You`d better inspect (with firebug) the structure of the page to see what you need and what you don`t.
A second partial solution would be to append ?xpage=plain to the above link and you will end up only with the rendered document content in inline mode (so you can have inputs and such). The only disadvantage I see here is that, if your template uses non-inline javascript (trough a JavaScriptExtension for example or the js already available in XWiki), it will not be available in the rendered version.
Whichever you choose from the two solutions, you can then implement the Finish button of the wizard to launch a HTTP request and simulate the Save button from XWiki's page (passing all the needed parameters, including the parameters in the page the user just filled in).
You can additionally stylize the displayed HTML so that it better integrates with the Eclipse wizard.
Now the question is how to achieve it? Any idea where to start hacking or where to look for more information is highly appreciated here. This is the only thing I can think of right now. Hope it helps.
Thanks, Eduard
Thanks, Karel
On 04/26/11 05:38 PM, Karel Gardas wrote:
Hello,
I'm currently reading about XWiki and XEclipse and would like to ask if there is any consensus about XWiki pages templates which might also be usable from XEclipse probably after some code hacking on its plugins.
I'm currently working on some project for my client (source code will be contributed/available later in the project stage) where there is a need to use XEclipse and enhance it to support some predefined forms/templates for web pages creation. So far I've found just XWiki FAQ tutorial on http://platform.xwiki.org/xwiki/bin/view/DevGuide/FAQTutorial which tries to deals with some kind of templates. However this looks quite general at least so far to me and so I would like to ask the question above about consensus where and how to go with templates in xwiki/xeclipse.
My current idea is to stick with the XWiki server as a provider of templates to preserve ability to use templates from both browser and xeclipse and to enhance xeclipse new page creation wizard to provide a list of available templates on the server side...
Thanks for any idea where to start or where to look for more information with regarding to this project task.
Karel
-- Sergiu Dumitriu http://purl.org/net/sergiu/
Hello Sergiu, thanks a lot for you hint, when I renamed xwiki-enterprise-web-3.1-SNAPSHOT to simple xwiki, then after clicking on <save and view> button I got to normal login screen and when I log in the page is really created. Now, the only question is how to make authentication data kind of persistent between pages so no login page is shown in the wizard. Thanks! Karel On 06/15/11 10:44 AM, Sergiu Dumitriu wrote:
On 06/15/2011 09:58 AM, Karel Gardas wrote:
Hi Eduard,
thanks a lot for your prompt reply. The URL I pass directly into browser's setUrl method is correct. The problem is this is somehow corrupted xwiki server reply -- I'm talking about this attempt to load login page. I really set just http://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/....
Thanks to your help with authentication in setUrl, I've used that and now I see the browser correctly load the page. Now the problem appears when I click on<save and view> (or<preview>,<save and continue>), the result of this is always redirection to the login page which fails with the same result like before:
HTTP Status 404 - /xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...
There are still some problems when the webapp name contains dashes. Try to rename the application to something without dashes, like simply "xwiki".
type Status report
message /xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...
description The requested resource (/xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...) is not available. Apache Tomcat/7.0.12
Now my question is how to get the session cookie back from the browser after displaying the page? It seems I can use .getCookie method, but I don't know cookie's name in this case.
Also I've submitted http://jira.xwiki.org/jira/browse/XECLIPSE-153 -- as per your advice.
Thanks! Karel
Hi Karel, On 06/15/2011 01:54 PM, Karel Gardas wrote:
Hello Sergiu,
thanks a lot for you hint, when I renamed xwiki-enterprise-web-3.1-SNAPSHOT to simple xwiki, then after clicking on<save and view> button I got to normal login screen and when I log in the page is really created.
If you look at my first reply (with initial suggestions), you`ll see that I suggested that the actual Save action when completing the creation of a page should be performed by your wizard`s Finish button (sending a HTTP request with all the parameters set), otherwise you mix up the user by having 2 sets of buttons (XWiki`s and the wizard`s).
Now, the only question is how to make authentication data kind of persistent between pages so no login page is shown in the wizard. I don`t really understand why the Browser does not send back the cookie received from XWiki (jsessionid). You could use a sniffer and see the HTTP traffic and check if the cookie is sent by the Browser on the second request (clicking Save). I have some problems with my Eclipse setup that prevents me from testing the Browser component.
Thanks, Eduard
Thanks! Karel
On 06/15/11 10:44 AM, Sergiu Dumitriu wrote:
On 06/15/2011 09:58 AM, Karel Gardas wrote:
Hi Eduard,
thanks a lot for your prompt reply. The URL I pass directly into browser's setUrl method is correct. The problem is this is somehow corrupted xwiki server reply -- I'm talking about this attempt to load login page. I really set just http://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/....
Thanks to your help with authentication in setUrl, I've used that and now I see the browser correctly load the page. Now the problem appears when I click on<save and view> (or<preview>,<save and continue>), the result of this is always redirection to the login page which fails with the same result like before:
HTTP Status 404 - /xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik... There are still some problems when the webapp name contains dashes. Try to rename the application to something without dashes, like simply "xwiki".
type Status report
message /xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...
description The requested resource (/xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...) is not available. Apache Tomcat/7.0.12
Now my question is how to get the session cookie back from the browser after displaying the page? It seems I can use .getCookie method, but I don't know cookie's name in this case.
Also I've submitted http://jira.xwiki.org/jira/browse/XECLIPSE-153 -- as per your advice.
Thanks! Karel
devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Hi Eduard, On 06/15/11 06:59 PM, Eduard Moraru wrote:
Hi Karel,
On 06/15/2011 01:54 PM, Karel Gardas wrote:
Hello Sergiu,
thanks a lot for you hint, when I renamed xwiki-enterprise-web-3.1-SNAPSHOT to simple xwiki, then after clicking on<save and view> button I got to normal login screen and when I log in the page is really created.
If you look at my first reply (with initial suggestions), you`ll see that I suggested that the actual Save action when completing the creation of a page should be performed by your wizard`s Finish button (sending a HTTP request with all the parameters set), otherwise you mix up the user by having 2 sets of buttons (XWiki`s and the wizard`s).
I remember well your initial recommendation. Thanks for it! The way of using SWT browser directly was just rather a proof-of-concept of the idea of having browser embedded inside the wizard. Now, the situation is a little bit different. I do have: - small http client code which logs into xwiki server if needed and access the newly created page - strip all not needed information from the newly created page and leave just a form to fill the template data - show such page in the browser embedded inside the wizard window and allow user to fill the form. That's what working. Now I would like to press Finish button get the filled form from SWT browser (somehow!) and POST it to the xwiki server to save the page with entered data. The problem is that if I use getText() method on SWT browser it does not return page with filled data and I don't see any other API which should support this. So my question now is : do you have any idea how to get filled form page from the browser back into my code? Thanks a lot! Karel
After googling around on this topic, it seems that there is no clean way of doing this. The initial community-accepted way I managed to find was using javascript (Browser.execute(String)) to retrieve your data, store it in window.status and then, a BrowserStatusText listener would get that value from the status text. An example is here: http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/QueryDOMnodevalue.htm On the other hand, by checking the Eclipse/SWT API, it seems that Browser.evaluate(String) also got implemented along the way and, compared to execute(String), it actually returns the value of the executed JavaScript so you can use it directly. Documentation here: http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.i... So, to sum it up, use JS to document.getElementById(...) for each field in the form and use their names+values to build the request performed by your Finish button. Hope this helps, Eduard P.S.: Can you post a screenshot of the wizard page containing the template's form? On Tue, Jun 28, 2011 at 2:56 PM, Karel Gardas <[email protected]>wrote:
Hi Eduard,
On 06/15/11 06:59 PM, Eduard Moraru wrote:
Hi Karel,
On 06/15/2011 01:54 PM, Karel Gardas wrote:
Hello Sergiu,
thanks a lot for you hint, when I renamed xwiki-enterprise-web-3.1-SNAPSHOT to simple xwiki, then after clicking on<save and view> button I got to normal login screen and when I log in the page is really created.
If you look at my first reply (with initial suggestions), you`ll see that I suggested that the actual Save action when completing the creation of a page should be performed by your wizard`s Finish button (sending a HTTP request with all the parameters set), otherwise you mix up the user by having 2 sets of buttons (XWiki`s and the wizard`s).
I remember well your initial recommendation. Thanks for it! The way of using SWT browser directly was just rather a proof-of-concept of the idea of having browser embedded inside the wizard. Now, the situation is a little bit different. I do have:
- small http client code which logs into xwiki server if needed and access the newly created page - strip all not needed information from the newly created page and leave just a form to fill the template data - show such page in the browser embedded inside the wizard window and allow user to fill the form.
That's what working. Now I would like to press Finish button get the filled form from SWT browser (somehow!) and POST it to the xwiki server to save the page with entered data. The problem is that if I use getText() method on SWT browser it does not return page with filled data and I don't see any other API which should support this.
So my question now is : do you have any idea how to get filled form page from the browser back into my code?
Thanks a lot! Karel
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Hi Eduard, On 06/28/11 05:45 PM, Eduard Moraru wrote:
After googling around on this topic, it seems that there is no clean way of doing this.
The initial community-accepted way I managed to find was using javascript (Browser.execute(String)) to retrieve your data, store it in window.status and then, a BrowserStatusText listener would get that value from the status text. An example is here: http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/QueryDOMnodevalue.htm
On the other hand, by checking the Eclipse/SWT API, it seems that Browser.evaluate(String) also got implemented along the way and, compared to execute(String), it actually returns the value of the executed JavaScript so you can use it directly. Documentation here: http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.i...
So, to sum it up, use JS to document.getElementById(...) for each field in the form and use their names+values to build the request performed by your Finish button.
I'm afraid this is not possible. Imagine you do have completely unknown template to you and you need your new page wizard to support it. You don't know at all what id you should use and how many of them to get all the template forms values. For example let's have a template for book type with a fields: "Book name", "Author name" and "publication". Id's of those fields in my particular case are: Book store.BookClass_0_name, Book store.BookClass_0_author, Book store.BookClass_0_publication how the template wizard author should know this? So IMHO this way is not possible or at least not in this way...
P.S.: Can you post a screenshot of the wizard page containing the template's form?
It's small, so I hope nobody will be angry for attaching this directly. This is a second page of the wizard creating page for Book with name "Matka" (Mother in English), author's name is "Karel Capek" and publication date is set to "1929" -- but this is completely untrue, just my example, the first real publication was in 1938. BTW: Karel Capek is listed from the dynamic list of authors, which is a result of SPARQ query on top of Jena's DB. Code which shall be also open-source once we get green from the customer legal department... "FOUND BOOK NAME" and "FOUND AUTHOR NAME" together with "<set property operation aborted!>" are just debug messages from template .vm code where I'm using some of our semantics marcos (also to be open-sourced) -- this all is about semantic XWiki book store demo example... I'm creating pages for authors and books using author and book template. Once you add author page all the semantics props are set so you get it listed automatically inside the book template code in author name dynamic SPARQ list... Now I just need to make sure page template creation is really working even from XEclipse (this thread is all about)... Thanks! Karel
On Tue, Jun 28, 2011 at 2:56 PM, Karel Gardas<[email protected]>wrote:
Hi Eduard,
On 06/15/11 06:59 PM, Eduard Moraru wrote:
Hi Karel,
On 06/15/2011 01:54 PM, Karel Gardas wrote:
Hello Sergiu,
thanks a lot for you hint, when I renamed xwiki-enterprise-web-3.1-SNAPSHOT to simple xwiki, then after clicking on<save and view> button I got to normal login screen and when I log in the page is really created.
If you look at my first reply (with initial suggestions), you`ll see that I suggested that the actual Save action when completing the creation of a page should be performed by your wizard`s Finish button (sending a HTTP request with all the parameters set), otherwise you mix up the user by having 2 sets of buttons (XWiki`s and the wizard`s).
I remember well your initial recommendation. Thanks for it! The way of using SWT browser directly was just rather a proof-of-concept of the idea of having browser embedded inside the wizard. Now, the situation is a little bit different. I do have:
- small http client code which logs into xwiki server if needed and access the newly created page - strip all not needed information from the newly created page and leave just a form to fill the template data - show such page in the browser embedded inside the wizard window and allow user to fill the form.
That's what working. Now I would like to press Finish button get the filled form from SWT browser (somehow!) and POST it to the xwiki server to save the page with entered data. The problem is that if I use getText() method on SWT browser it does not return page with filled data and I don't see any other API which should support this.
So my question now is : do you have any idea how to get filled form page from the browser back into my code?
Thanks a lot! Karel
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Hi Karel, On 06/15/2011 10:58 AM, Karel Gardas wrote:
Hi Eduard,
thanks a lot for your prompt reply. The URL I pass directly into browser's setUrl method is correct. The problem is this is somehow corrupted xwiki server reply -- I'm talking about this attempt to load login page. I really set just http://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/....
Thanks to your help with authentication in setUrl, I've used that and now I see the browser correctly load the page. Now the problem appears when I click on <save and view> (or <preview>, <save and continue>), the result of this is always redirection to the login page which fails with the same result like before:
HTTP Status 404 - /xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...
type Status report
message /xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...
description The requested resource (/xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...) is not available. Apache Tomcat/7.0.12
Now my question is how to get the session cookie back from the browser after displaying the page? It seems I can use .getCookie method, but I don't know cookie's name in this case.
It should be "jsessionid" (as printed above). Thanks, Eduard
Also I've submitted http://jira.xwiki.org/jira/browse/XECLIPSE-153 -- as per your advice.
Thanks! Karel
On 06/14/11 11:21 AM, Eduard Moraru wrote:
Hi Karel,
On 06/13/2011 04:17 PM, Karel Gardas wrote:
Hi Eduard,
thanks a lot for your advices given below. At this project state I'm going with as simple as possible solution so I created special simple web page for listing all the template providers as per your advice and this runs well. On the other hand I do have some issue running running SWT browser as part of new page wizard. The problem is authentication, or better its lack of. Although I pass to the browser correct page URL, the output of the browser is always:
HTTP Status 404 - /xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...
type Status report
message /xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...
description The requested resource (/xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...)
is not available. Apache Tomcat/7.0.12
Well, from what I can see, you are trying to access a malformed URL. "/xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik..."
seems to have 2 problems: 1) the first part "/xwiki-enterprise-web-3.1-SNAPSHOT" does not belong here. 2) the webapp part of the URL: "http://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWik...",
more exactly "xwiki-enterprise-web-3.1-SNAPSHOT", if you did not modify the default db in xwiki.cfg, should be just "xwiki". So, the correct URL should be: "http://localhost:8080/xwiki/bin/login/XWiki/XWikiLogin"
Now, regarding authentication... A solution is to send, with each HTTP request that you do, a HTTP Auth header providing user/password. You can also choose to send it only once per session and reuse the session cookie that XWiki will return after the first request that contains the HTTP auth header.
If you use the SWT Browser to directly access an XWiki page, you can pass the HTTP Auth header by using the setUrl(...) method trough something like this: browser.setUrl("http://localhost:8080/xwiki/bin/view/XWiki/APrivatePage",
null, new String[] {"Authorization: Basic QWRtaW46YWRtaW4="}); the QWRtaW46YWRtaW4= is the Base64 encoding of Admin:admin. You can generate you own Base64 encoding of a user:password combination and pass that instead. If you choose to use a simple HTTP client to retrieve the HTML of a page and the render it with a browser, you`ll have to pass the user:password to that client instead.
Anyway, I tested the URL in external browser and it's working fine there -- please note I'm logged in in this browser.
I've attempted to hack the code to convince browser to authenticate by using authentication listener:
browser = new Browser(browserComposite, SWT.NONE); browser.addAuthenticationListener(new AuthenticationListener() {
public void authenticate(AuthenticationEvent event) { // TODO Auto-generated method stub
System.err.println("AuthenticationListener::authenticate: " + event.toString()); event.user = "Admin"; event.password = "admin"; event.doit = true; } });
but this is not even invoked. Do you have any idea how to solve this?
The authentication listener would not trigger because XWiki does not return 401 Unauthorized when tryin to access a restricted page, but instead provides it's own authentication ui/page. However, passing an Authorization header to a restricted page will automatically perform the login and you can then reuse the session token instead of passing the user/password for each request.
I see that preview browser is always running in non-authenticated mode (or what I've researched so far) although connection in Explorer is authenticated...
Yes, it might be a nice to have feature (authenticated preview window). Could you please add a jira issue for it? http://jira.xwiki.org/jira/browse/XECLIPSE
Thanks, Eduard
If you are curious I'm free to submit all changes in a form of preferred diff to the original RFE, especially if it helps you advice me how to proceed from here...
Thanks! Karel
On 06/ 2/11 10:14 PM, Eduard Moraru wrote:
Hi Karel,
On 06/02/2011 07:54 PM, Karel Gardas wrote:
Hello,
I'm back to this task. I've searched JIRA for related RFE/BUG but have not found anything so I created my own: http://jira.xwiki.org/jira/browse/XECLIPSE-152
My basic idea about UI is that XEclipse New Page wizard will be enhanced to provide a field "Template" where user will be able to select appropriate template provider (as they are set in Administration> Content> Templates). In order to get the list of templates in XEclipse, you would need a service that does internally a HQL like this:
#set($availableProviders = $xwiki.searchDocuments(", BaseObject obj where doc.fullName=obj.name and obj.className='XWiki.TemplateProviderClass' and doc.fullName!='XWiki.TemplateProviderTemplate'")) (taken from XWiki.AdminTemplatesSheet, the page that displays the content in Administration> Content> Templates)
The service can be either a REST extension (java component) or a wiki page called with ?xpage=plain (to return the result in some custom xml or just csv).
If he/she sets some, then while clicking on Next button (to be added) it'll render the page of the template provider form to the wizard window, the user will be able to fill it and then hit Finish button to actually save the page.
Both to avoid reimplementing the template mechanism and the rendering of the template form, one rather simple solution would be to display in an SWT Browser control the result of a page like http://localhost:8080/xwiki/bin/inline/Main/MyNewPage?parent=Main.AParentPag...
(the type of link generated by the create page dialog in XWiki). Basically you show the XWiki page inside your wizard. The problem with this approach is that you end up with unnecessary header, panels and footer when you`re only interested in the page content. Besides that, you also have the save, save&continue and cancel buttons that are kind of conflicting with your wizard's buttons and flow.
Not sure about this, but one solution may be to extract from the big HTML, only the document content, excluding the bottom buttons. You`d better inspect (with firebug) the structure of the page to see what you need and what you don`t.
A second partial solution would be to append ?xpage=plain to the above link and you will end up only with the rendered document content in inline mode (so you can have inputs and such). The only disadvantage I see here is that, if your template uses non-inline javascript (trough a JavaScriptExtension for example or the js already available in XWiki), it will not be available in the rendered version.
Whichever you choose from the two solutions, you can then implement the Finish button of the wizard to launch a HTTP request and simulate the Save button from XWiki's page (passing all the needed parameters, including the parameters in the page the user just filled in).
You can additionally stylize the displayed HTML so that it better integrates with the Eclipse wizard.
Now the question is how to achieve it? Any idea where to start hacking or where to look for more information is highly appreciated here. This is the only thing I can think of right now. Hope it helps.
Thanks, Eduard
Thanks, Karel
On 04/26/11 05:38 PM, Karel Gardas wrote:
Hello,
I'm currently reading about XWiki and XEclipse and would like to ask if there is any consensus about XWiki pages templates which might also be usable from XEclipse probably after some code hacking on its plugins.
I'm currently working on some project for my client (source code will be contributed/available later in the project stage) where there is a need to use XEclipse and enhance it to support some predefined forms/templates for web pages creation. So far I've found just XWiki FAQ tutorial on http://platform.xwiki.org/xwiki/bin/view/DevGuide/FAQTutorial which tries to deals with some kind of templates. However this looks quite general at least so far to me and so I would like to ask the question above about consensus where and how to go with templates in xwiki/xeclipse.
My current idea is to stick with the XWiki server as a provider of templates to preserve ability to use templates from both browser and xeclipse and to enhance xeclipse new page creation wizard to provide a list of available templates on the server side...
Thanks for any idea where to start or where to look for more information with regarding to this project task.
Karel
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
participants (4)
-
Eduard Moraru -
Eduard Moraru -
Karel Gardas -
Sergiu Dumitriu