On 21 Sep 2015 at 11:12:35, PATEL, ABDULKADAR ([email protected](mailto:[email protected])) wrote:
> Vincent, once again thanks for your reply. > > If I add link using JS code, then that link will be lost once the page is > refreshed. What you need is to save the metadata related to the link, same as what annotations do. You can do this by adding an XObject to the page for each link to add. Then the JS will use that info to create the link. > Thus I need to do something on server side. That's why I knowledge xwiki > rendering comes into picture. > Here I see two ways of achieving this : > 1. Using annotations > 2. Using comments > > Basically the question is : > How can I update a page with comment/annotation from js code? Not sure I understand. You don’t need annotations or comments. You can use your own xobject. You could reuse annotations or comments too though but not sure it’s the best, you’ll probably have some limitations. From JS you can make calls to the sever to retrieve data (either using the XWiki REST API or by creating a page containing a script that reutrns the data you need on the client side) Thanks -Vincent > Thanks & Regards, > Abdulkadar Patel > > -----Original Message----- > From: Vincent Massol [mailto:[email protected]] On Behalf Of > [email protected] > Sent: Monday, September 21, 2015 1:51 PM > To: XWiki Users > Cc: PATEL, ABDULKADAR > Subject: RE: [xwiki-devs] Display link on xwiki page > > > > > > > On 21 Sep 2015 at 10:16:00, PATEL, ABDULKADAR > ([email protected](mailto:[email protected])) > wrote: > > > > > Hi Vincent, > > > > > > > > > > > > Thanks for your response. > > > > > > I know it might be very trivial issue but as I am working on xwiki > > first time, > > > > > > I don’t know basic things and that’s why bugging all of you with my silly > > doubts. > > > > > > > > > > > > To achieve this use case, I have followed below steps : > > > > > > > > > > > > 1. Modified xwiki-min.js file to bind a javascript code which will > > display a popup dialog on click of ctrl+shift+N > > You shouldn’t do that. You should use a Javascript Extension instead, see > http://platform.xwiki.org/xwiki/bin/view/DevGuide/SkinExtensionsTutorial > > > 2. This dialog fetches projects and issue types from jira server and > > displays as dropdown > > ok > > > 3. Once user clicks on submit, a jira issue is created > > ok > > > 4. Now I need to display a link near text selected by user in step 1 but > > don’t know how to do it. > > This is not really related to XWiki (unless you wish to reuse the Annotation > code but then I don’t now this code enough to know if you can do this or > not). > > In any case you could check the Annotation code to understand how it’s done > there, basically how to find the location of some text in the content. > > I guess there are at least 2 ways: > * Do that using JS and thus insert your link using JS > * Do it on the server side using the Rendering engine (this is what > Annotation is doing I think) and add some specific HTML marker so that by > using JS you can easily insert the link. > > In any case what you wish to do is something complex and requires good > knowledge of JS (and possibly of XWiki’s Rendering if you choose this > solution). > > Thanks > -Vincent > > > I have attached code I have added in xwiki-min.js > > > > > > > > > > > > You can also suggest if this is a right approach and if I can follow some > > other approach. > > > > > > > > > > > > Thanks & Regards, > > > > > > Abdulkadar Patel > > > > > > > > > > > > > > > > > > > > P.S. I have not kept xwiki developers mail list since this mail becomes > > huge and will need approval from list moderator. > > > > > > > > > > > > > > > > > > From: Vincent Massol [mailto:[email protected]] On Behalf Of > > [email protected] > > Sent: Monday, September 21, 2015 12:52 PM > > To: XWiki Developers > > Cc: PATEL, ABDULKADAR > > Subject: Re: [xwiki-devs] Display link on xwiki page > > > > > > > > > > > > > > > > Hi there, > > > > > > > > > > > > > > > > > > On 18 Sep 2015 at 15:25:44, PATEL, ABDULKADAR > > ([email protected](mailto:[email protected]))(mailto:[email protected](mailto:[email protected]))) > > wrote: > > > > > Hi all, > > > > > > Sorry to bug all of you again and again with the same requirement. > > > But I am also helpless till I get it done. > > > > > > I have ebelow use case : > > > > > > 1. User selects some text on an xwiki page and hits some keyboard > > > shortcut say Alt+ctrl+N > > > > > > 2. This opens a popup dialog like shown below : > > > > > > [file:///Users/vmassol/Library/Containers/it.bloop.airmail.beta11/Da > > > ta/Library/Application > > > Support/Airmail/General/Local/1442819908355112192/Attachments/image0 > > > [email protected](mailto:Support/Airmail/General/Local/144281 > > > 9908355112192/Attachments/[email protected])] > > > > > > > > > > > > 3. As you can see in the screenshot, it displays list of projects, issue > > > types from JIRA server. > > > > > > Issue summary field is pre-populated with the selected text from xwiki > > > page. > > > > > > 4. Once user submits this dialog, an issue is created in JIRA and a > > > link will be created on xwiki page besides selected > > > > > > text. > > > > > > So far I have achieved 1,2 and 3 but not able to achieve 4 One > > > option I thought of is to create an annotation for the selected text > > > with text as a link to JIRA issue But I don't understand how to achive > > > this from javascript code. > > > I have written javascript code in > > > webapps/xwiki/resources/js/xwiki/xwiki-min.js file > > > > > > Please suggest me an approach to achive point no 4. > > > Also suggest me if there is a better and cleaner approach. > > > > > > > > > > > > > > I’m not sure I understand the problem. Step 4 seems easy. You just need a > > form action which calls a wiki page (possibly the current page passing some > > parameter) and then using Velocity for example to create the JIRA issue > > using the JIRA REST API. > > > > > > > > > > > > > > > > Thanks > > > > > > > > -Vincent > > > > > > > > > > > Thanks & Regards, > > > ____________________________________________________________________ > > > [file:///Users/vmassol/Library/Containers/it.bloop.airmail.beta11/Da > > > ta/Library/Application > > > Support/Airmail/General/Local/1442819908355112192/Attachments/image0 > > > [email protected]]Abdulkadar(mailto:Support/Airmail/General/L > > > ocal/1442819908355112192/Attachments/[email protected]% > > > 5dAbdulkadar) Patel Consultant | GESBU > > > > > > > > > > > > > > > > > > > This message contains information that may be privileged or confidential and > is the property of the Capgemini Group. It is intended only for the person to > whom it is addressed. If you are not the intended recipient, you are not > authorized to read, print, retain, copy, disseminate, distribute, or use this > message or any part thereof. If you receive this message in error, please > notify the sender immediately and delete all copies of this message. > _______________________________________________ > devs mailing list > [email protected] > http://lists.xwiki.org/mailman/listinfo/devs _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs

