Re: [xwiki-users] XWiki External Database

2009-04-29 Thread Dilipkumar Jadhav
Hello friends,
Some time back I had asked the question on connecting XWiki to an external
database. My organization had some special requirements  they wished that
the other database would be seperated from the main XWiki database.
I was able to figure out how to go about doing this. However, my solution
follows the simple JSP design pattern.
Basically, I retrieve parameters from one page and push it to another page
using html form (with the action tag) which in turn pushes the data to the
database.
It is very primitive when compared to the nature and complexity of XWiki
itself but serves the purpose.
The scripting is done in velocity and groovy. Also, the pages are secured
through XWiki's rights feature. So a normal user can only see the page,
enter data on the page but not edit it.
I request you to let me know if there is a better way of doing it. If need
be I can paste my scripting code in the mailing list.
However, I have not worked with Struts  do not know how to go about making
changes at the source level. And eventhough I have just started using
Groovy, I really like the ease of use. Is there a way that we can put in
groovy or Java class files that will hide the scripting even at the XWiki
page level.
Thank you friends...
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] XWiki External Database

2009-04-20 Thread Dilipkumar Jadhav
Hello once again everone,
Yesterday, I went through the XWiki main API reference guide at
http://platform.xwiki.org/xwiki/bin/download/DevGuide/API/xwiki-core-1.7.2-javadoc.zip/index.html
.
I was wondering if the Context class could be used to pass parameter from
one page to another (let's say input page to the page which does the actual
database insert using groovy).
There are two methods defined in the Context class:
1.put

@Programming
public void *put*(java.lang.String key,
java.lang.Object value)

Puts an object on the context using the given key. The context can be seen
as a map of (paramName, paramValue) pairs. Requires programming rights.

*Parameters:*key - The parameter name.value - The parameter value.


2. get

@Programming
public java.lang.Object *get*(java.lang.String key)

Returns the value associated with the given key in the XWiki context.
Programming rights are needed in order to call this method. The context can
be seen as a map of (paramName, paramValue) pairs. This mechanism is useful
for passing parameters between pages or from Java to Velocity. For instance
an exception caught in Java code can be put on the context and handled in a
user-friendly way in Velocity. This method is protected because sensitive
information may be placed in the internal context, which shouldn't be
publicly accessible.

*Parameters:*key - The key to look for in the context. *Returns:*The value
associated with the given key in the XWiki context, if you have programming
rights, or null otherwise.Would it be possible to use the put method to
assign a parameter and get to retrieve this parameter in the next page.

I tried my little experiment with an html form with the action set to
another page. This html form page sets the parameters using the put()
method. However, when i try to access the parameter using the get() method
on the next page, I get null values.
I've tried context.put(key1,value1) and context.put('key1','value1') and
also context.put(key1,value1). The first two give me null values whereas the
last technique gives me a script error (probably because my syntax is
incorrect).
I am pretty sure that i do have programming rights since using just
context.getDatabase() gives me the database name.
Requesting some assistance here...
Thank you in advance.



On Sat, Apr 18, 2009 at 6:16 PM, Dilipkumar Jadhav 
jadhav.dilipku...@gmail.com wrote:

 Hello Friends,
 I have been asked to connect an external database with XWiki (XWiki will be
 used as the application  MySql as the database).
 I am using XWiki Enterprise 1.7.14685 :: MySql 5.0.
 The external database (let's call it titan) is on the same mysql instance
 (port) as XWiki database itself.
 The requirement is to fetch user input (in terms of check boxes, radio
 buttons  text boxes) from XWiki page and insert it into database.
 Also, some degree of read operation from the database is required.

 I've been able to read from my external database using the following code
 directly in my XWiki page (under XWiki 1.0 syntax):

 %
 import groovy.sql.Sql

 def sql = Sql.newInstance(jdbc:mysql://localhost:3306/titan, root,
   test, com.mysql.jdbc.Driver)

 sql.eachRow(select * from user){
 println ${it.user}
 }
 %

 Hence, I am confident that an update or insert operation can be performed
 with ease too (thanks to the groovy page at
 http://groovy.codehaus.org/Database+features).

 But I am not familiar with how to retrieve session parameters from the page
 context. Could someone please guide me to a resource or a working example of
 fetching context variables/parameters. Maybe it is a very simple solution,
 but I have very little background in velocity. Any help would be much
 appreciated.

 Also, any time-frame on the page rating feature which is being discussed
 very often now?(what version we could expect to see it?). Also, would page
 rating be available for all the documents in an existing wiki (as in
 embedded in the velocity templates) or would it be available only for newly
 created pages/documents.

 Thank you everyone...

___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] XWiki External Database

2009-04-18 Thread Dilipkumar Jadhav
Hello Friends,
I have been asked to connect an external database with XWiki (XWiki will be
used as the application  MySql as the database).
I am using XWiki Enterprise 1.7.14685 :: MySql 5.0.
The external database (let's call it titan) is on the same mysql instance
(port) as XWiki database itself.
The requirement is to fetch user input (in terms of check boxes, radio
buttons  text boxes) from XWiki page and insert it into database.
Also, some degree of read operation from the database is required.

I've been able to read from my external database using the following code
directly in my XWiki page (under XWiki 1.0 syntax):

%
import groovy.sql.Sql

def sql = Sql.newInstance(jdbc:mysql://localhost:3306/titan, root,
  test, com.mysql.jdbc.Driver)

sql.eachRow(select * from user){
println ${it.user}
}
%

Hence, I am confident that an update or insert operation can be performed
with ease too (thanks to the groovy page at
http://groovy.codehaus.org/Database+features).

But I am not familiar with how to retrieve session parameters from the page
context. Could someone please guide me to a resource or a working example of
fetching context variables/parameters. Maybe it is a very simple solution,
but I have very little background in velocity. Any help would be much
appreciated.

Also, any time-frame on the page rating feature which is being discussed
very often now?(what version we could expect to see it?). Also, would page
rating be available for all the documents in an existing wiki (as in
embedded in the velocity templates) or would it be available only for newly
created pages/documents.

Thank you everyone...
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users