Hi Karel, Don`t forget about textareas :)
It would be nice if you could, when you finish the project, cotribute it as a feature of XEclipse. The REST templates service could become a part of XE as well. Thanks, Eduard On Mon, Aug 8, 2011 at 11:40 AM, Karel Gardas <[email protected]>wrote: > > Hi Eduard, > > thanks a lot for your help with this. Indeed, your JS kind of works. I've a > little bit fixed this and now I'm using: > > String js = "function > getFormData() {\n"; > js = js + "var formData = > {};\n"; > js = js + "var stringData = > '';\n"; > js = js + "var inputs = > document.getElementsByTagName(**'input');\n"; > js = js + "for (var i = 0; i > < inputs.length; ++i) {\n"; > js = js + "var input = > inputs[i];\n"; > js = js + "if (input.value > == null || input.value == '' || input.type == 'button' || input.type == > 'submit') {\n"; > js = js + "continue;\n"; > js = js + "}\n"; > //js = js + "alert('Input [' > + i + '] (' + input.type + '): ' + input.name + ' = ' + input.value)\n"; > js = js + "formData[ > input.name] = input.value;\n"; > js = js + "stringData = > stringData + '[' + input.name + ']=' + input.value;\n"; > js = js + "}\n"; > js = js + "var selects = > document.getElementsByTagName(**'select');\n"; > js = js + "for (var j = 0; j > < selects.length; ++j) {\n"; > js = js + "var input = > selects[j];\n"; > js = js + "if (input.value > == null || input.value == '' || input.type == 'button' || input.type == > 'submit') {\n"; > js = js + "continue;\n"; > js = js + "}\n"; > //js = js + "alert('Input [' > + i + '] (' + input.type + '): ' + input.name + ' = ' + input.value)\n"; > js = js + "formData[ > input.name] = input.value;\n"; > js = js + "stringData = > stringData + '[' + input.name + ']=' + input.value;\n"; > js = js + "}\n"; > //js = js + > "alert.log(formData);\n"; > //js = js + > "alert(formData);\n"; > //js = js + "return > formData.toString();\n"; > js = js + "return > stringData;\n"; > js = js + "}\n"; > //js = js + "formData;\n"; > js = js + "return > getFormData();\n"; > > > Thanks! > Karel > > > On 06/29/11 02:59 PM, Eduard Moraru wrote: > >> Hi Karel, >> >> On Tue, Jun 28, 2011 at 9:46 PM, Karel Gardas<[email protected]** >> >wrote: >> >> >>> 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/**<http://www.java2s.com/Code/**Java/SWT-JFace-Eclipse/**> >>>> QueryDOMnodevalue.htm<http://**www.java2s.com/Code/Java/SWT-** >>>> JFace-Eclipse/**QueryDOMnodevalue.htm<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.****<http://help.eclipse.org/**indigo/index.jsp?topic=%2Forg.**> >>>> eclipse.platform.doc.isv%****2Freference%2Fapi%2Forg%** >>>> 2Feclipse%2Fswt%2Fbrowser%****2FBrowser.html<http://help.** >>>> eclipse.org/indigo/index.jsp?**topic=%2Forg.eclipse.platform.** >>>> doc.isv%2Freference%2Fapi%**2Forg%2Feclipse%2Fswt%** >>>> 2Fbrowser%2FBrowser.html<http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fswt%2Fbrowser%2FBrowser.html> >>>> > >>>> >>>> >>>> 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... >>> >>> >>> >>> Well, from your template wizard and by using JavaScript, you could get >> all >> the<input...> elements with their name and value and pass them to the >> request performed by the 'Finish' button. I doubt that there will be more >> than one<form> element in the template page, but even so, the main<form> >> element's ID is 'inline'. >> >> Here's a starting point based on the above: >> >> var formData = {}; >> >> var inputs = document.getElementsByTagName(**'input'); >> for (var i = 0; i< inputs.length; ++i) { >> var input = inputs[i]; >> if (input.value == null || input.value == '' || input.type == 'button' >> || >> input.type == 'submit') { >> continue; >> } >> console.log('Input [' + i + '] (' + input.type + '): ' + input.name + ' >> = >> ' + input.value) >> formData[input.name] = input.value; >> } >> >> console.log(formData); >> >> Note: Replace 'console' with alert if you are not running this in >> Firebug's >> console. >> >> It does need some fine tuning, but it should work. >> >> >> 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... >>> >>> >> Thanks for the preview. It looks like you are using xpage=plain for plain >> HTML rendering. This should be enough for basic templates. I some >> templates >> contain javascript inside them (for input validation, autocomplete, etc) , >> I >> don`t think it will work since the JS is not included in xpage=plain. >> Don`t >> know if that`s a problem for your usecase. >> >> Good luck, >> Eduard >> >> >> 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<http://lists.xwiki.org/**mailman/listinfo/devs> >>>>> <http://**lists.xwiki.org/mailman/**listinfo/devs<http://lists.xwiki.org/mailman/listinfo/devs> >>>>> > >>>>> >>>>> ______________________________****_________________ >>>>> >>>> devs mailing list >>>> [email protected] >>>> http://lists.xwiki.org/****mailman/listinfo/devs<http://lists.xwiki.org/**mailman/listinfo/devs> >>>> <http://**lists.xwiki.org/mailman/**listinfo/devs<http://lists.xwiki.org/mailman/listinfo/devs> >>>> > >>>> >>>> >>>> >>> >> > _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs

