Hello,
i like the REST-API and have a library in Java which works perfect. Now i
want to use the RESTful API in Javascript. But i am new to javascript and
tried a lot, but nothing seems to work. Is there a simple example in
javascript with the rest-api?
I don't get what i am doing wrong, because i am not good in javascript.
I tried
require(['jquery'], function ($) {
$.ajax({
accepts: {xml: 'text/xml', text: 'text/plain'},
url: 'http://HOST/xwiki/rest',
type: 'GET',
dataType: 'xml',
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
converters: {'text xml': jQuery.parseXML},
crossDomain: true,
async: true,
username: 'username',
password: 'apassword',
success: function(data){
alert("Success: "+JSON.stringify(data));
},
error: function(data){
alert("Error: "+ JSON.stringify(data));
}
});
});
Also i tried
var httpRequest = new XMLHttpRequest();
httpRequest.open('PUT', 'http://HOST/xwiki/rest');
httpRequest.setRequestHeader('Accept', 'application/xml');
httpRequest.send( null );
alert( JSON.stringify(httpRequest.responseText) );
httpRequest.onreadystatechange = function(){
if(this.readyState == 4){
if(this.status == 200){
alert(this.responseText);
}
else{
alert(this.statusText);
}
}
}
I recognized a difference in ajax when i switched to jsonp because i tried
on localhost. But anyway my example work when i use my server outside.
Can you help me?
Regards,
Matthias
--
View this message in context: http://xwiki.475771.n2.nabble.com/Javascript-RESTful-tp7594084.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
I'd like to be able to generate pure JSON from a wiki page, to use in other pages via AJAX. To that end I created a page with the following content:
{{velocity wiki="false"}}
$response.setContentType('application/json')
{
"greeting" : "Hello",
"location": "World"
}
{{/velocity}}
Calling this via /xwiki/bin/get/Sandbox/JsonTest I get the following code:
<p><br/>{<br/>"greeting" : "Hello",<br/>"location": "World"<br/>}</p>
I get the same via /xwiki/bin/view/AlertDB/JsonTest?xpage=plain.
If I remove the $response.setContentType('application/json')
https://dev.alertnessdb.net/xwiki/bin/view/AlertDB/JsonTest?xpage=plain
Currently, I'm using something like this to generate a list of pages whose
prefix is "Prefix:" and link to them:
{velocity}} (((
#foreach ($row in $services.query.hql("select doc.name, doc.fullName from
XWikiDocument doc where doc.space.hidden = false and doc.space not in
('XWiki', 'Sandbox', 'Main', 'Macros') and doc.name like
'Prefix:%'").execute())
* **[[$row[0].replaceFirst("Prefix: *", "").replaceAll("~",
"~~~~").replaceAll("[\x20-\x7f&&[^a-zA-Z0-9 ~]]",
"~~$0")>>doc:$row[1].replaceAll("~", "~~").replaceAll("[\x5b\x5d|]", "\\$0
<file:///\\$0> ")]]**
#end
))) {{/velocity}}
I have tested with some heavy test cases like
Prefix:
~~~!!!```@@@$$$%%%^^^&&&***((()))___----+++==={{{}}}[[[]]]\\\|||:::;;;'''"""
???///...>>>,,,<<<
And what I have above works correctly (both showing the title and linking to
the document). I only work on a few hard test cases, though, so I'm not sure
if I missed anything.
Is there a method that does all this automatically? Or is there a better
approach to this?
I have a Groovy script that takes input from a form textarea. I'd like to prevent html (and JS) markup from being submitted and, if HTML is submitted, strip it out. Is there a tool already packaged within XWiki to do this, or should I look to an external package like Jericho?
Thanks,
Bryn
Hi,
As I tried XWiki, I used my laptop as server with the Windows standalone
install.
Now, I want to have XWiki installed on a standard server with a standard
DB/web server using the XWiki RPM (I guess this RPM will not install
Jetty/SQLite, but Tomcat/??).
But, I would better not have to reinstall the various extensions,
recreate the users (with the same login/passwords) and rewrite the pages
I already have.
Is there any synchronisation mechanism available that would allow me to
give the "official" XWiki my "prototype" one as a kind of upstream
server and make sure their content and config is synchronized ?
Thanks
--
Nicolas Delsaux
We are having an issue where some links that have been created are not opening up in a new tab or window. An unregistered user is prompted to download the linked attached document rather than opening up in a new tab or window, even if the option is set in the link.
If the contributor that created the link does not have program right, we see the above behavior. If the admin account created the link, it works as expected.
We are on version 6.3
Please advise.
This e-mail, and any attachments, is intended only for the use of the
addressee(s) named herein and may contain legally privileged and/or confidential
information. If you are not the intended recipient of this e-mail, you are
hereby notified that any dissemination, distribution or copying of this e-mail,
and any attachments, is strictly prohibited. If you have received this e-mail in
error, please notify me via return e-mail immediately and permanently delete the
original from your computer. Thank you, Mangar Industries Inc.
Hello
I created an application:
- my Class EAClass contain a field DG MOA * : (P1_DgMoa: Database List)
Display Type: select
Sort: Id
XWiki Class Name: FormSMQ.ListeDGClass
Id Field Name: DGId
Value Field Name: DGLib
My Class (source of select list) FormSMQ.ListeDGClass have 2 fields:
DG Id (DGId: String): contain l'Id of my list
DG Lib (DGLib: String): contain lib (pretty name like) who is displayed on my list select.
My data are:
DGId:20_dgaln / DGLib: DGALN
DGId:25_dgec / DGLib: DGEC
DGId:30_dgitm / DGLib: DGITM
...
Everything going well:
-all pages based on EAClass displayed Lib Value in view mode and in edit mode too (the id value is stored in the page)...
Except for search engine: I have some problems:
- "search page" searching only Id value and not lib value (of course because it is the id value that is stored in EAClass object)
i.e. I found pages, if I search "25_dgec" but not if I search "DGEC"
- Result "search page" displayed property name (and not the pretty name) FAQ have same issue.
- my solr facet displayed my id value too.
Do you know how can I fix this issue (if someone understand my problem ;-) )?
Here I paste a nice screenchot: http://snag.gy/Joa7q.jpg
Thanks.
Pascal B
--- En date de : Ven 27.3.15, Pascal BASTIEN <pbasnews-xwiki(a)yahoo.fr> a écrit :
> De: Pascal BASTIEN <pbasnews-xwiki(a)yahoo.fr>
> Objet: [xwiki-users] livetable with multiple class?
> À: "XWiki Users" <users(a)xwiki.org>
> Date: Vendredi 27 mars 2015, 14h19
> If I understand documentation, to use
> Livetable with multiple Class (with 3 or 4 common
> properties: same name) I must use
> Parameter $options:
> resultPage The full name of the page to
> use as a JSON data provider for the table. This option
> allows to use a different data source than the default one
> (XWiki.LiveTableResults) for specific needs not handled by
> LiveTableResults (for example: complex cross-classes
> queries, external data retrieved with a groovy script,
> etc.).
>
...
> Can I do it with query in one (or two) shots or I must use a
> foreach loop to rendering my JSON data?
I found my query, something like this:
#set($hql = "select obj.name, prop.value from BaseObject obj, StringProperty prop where ( obj.className='FormSMQ.EAClass' or obj.className='FormSMQ.PiacJ2Class' ) and prop.id.id=obj.id and prop.name='TypeFiche_RO'")
Now I need the JSON format of my JSON data provider (resultPage parameter: full name of the page to use as a JSON data provider for the table)
Hello there,
I am maybe asking a stupid question, but I am the administrator of an old xwiki that have to be updated.
My current users has done lots of documentation on this xWiki, and we would like to find a way to explode some parts of our xwiki without using too mutch the rights systems.
The fact :
- We are a software development company and we put allmost everything on the xwiki
- Some of our customers has right to see "customer's" pages uppon rights they currently have
- I (maybe I am not really up to date with xwiki) cannot figure what pages can be accesseed by each users (if someone can tell me how to find that I will be pleased to pay him/her a pint of Guinness).
- We are on xwiki 2.1.1 and all trys to upgrade to 6.x have fail on randoms parts (mostly rights that has been exploded, eg. everybody can see anything), or some pages being broken (people that hack too mutch groovy, they should not).
So to avoid issues with rights, we have an idea to split our xwiki into 2 servers :
- one for internal, if this too mutch rights this is not an issue
- one for external users (customers !), with only the pages that should be online for users, with reset of user's list and clean rights management.
Now I want to find a way to automaticaly sync some spaces between our master xwiki and some slave xwiki... Any good pointers?
Regards,
Xavier
--
Xavier Beaudouin - Senior Network and System Administrator
Infrastructure and network director
Horizon Software - http://www.hsoftware.com/
13 rue La Fayette - 75009 PARIS - France
Phone: +33 (0)1 4260 9490 Fax: +33 (0)1 44 56 97 01