getting xforms-sql-address-book from Orbeon Form 3.8 to work

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

getting xforms-sql-address-book from Orbeon Form 3.8 to work

James Liang
Hi all,

With Orbeon Form 3.8, the xforms-sql-address-book sample app is broken.  I couldn't find any documentation or any discussion on the mailing list on how to fix it.  I've finally got it working.

I thought I share my finding on the mailing list for the next guy that runs into this problem.  

Environment:
apache-tomcat-6.0.32
mysql-5.0.1
orbeon form 3.8


1.  Create datasource-sql.xml with the following in apache-tomcat-6.0.32/webapps/orbeon/WEB-INF/resources/config

<datasource>
    <driver-class-name>com.mysql.jdbc.Driver</driver-class-name>
    <uri>jdbc:mysql://localhost:3306/test</uri>
    <username>root</username>
    <password>adminadmin</password>
</datasource>

Here, change db connectivity info to suit your environment.


2.  The example from Orbeon is probably written to work with Oracle.  Many of the original SQL queries in the example did not work with MySQL.

xforms-sql-address-book/init-database/init-address-book.xpl

Replace the <sql:connection> section with the following.  

<sql:connection>
<!-- Drop tables if they exist -->
<sql:execute>
<sql:update>drop table if exists orbeon_address_book</sql:update>
</sql:execute>
<!-- Create tables -->
<sql:execute>
<sql:update>
create table orbeon_address_book (
id      integer auto_increment primary key,
first   varchar(255) not null,
last    varchar(255) not null,
phone   varchar(255) not null
)
</sql:update>
</sql:execute>
<!-- Insert initial data -->
<sql:execute>
<sql:update>insert into orbeon_address_book (first, last, phone) values ('John', 'Smith', '555-123-4567')</sql:update>
</sql:execute>
<sql:execute>
<sql:update>insert into orbeon_address_book (first, last, phone) values ('Tom', 'Washington', '555-123-4567')</sql:update>
</sql:execute>
<dummy/>
</sql:connection>


apache-tomcat-6.0.32/webapps/orbeon/WEB-INF/resources/apps/xforms-sql-address-book/service-add.xpl

replace <sql:update> section with the following:
<sql:update>
insert into orbeon_address_book (first, last, phone) values (
<sql:param type="xs:string" select="/form/first"/>,
<sql:param type="xs:string" select="/form/last"/>,
<sql:param type="xs:string" select="/form/phone"/>
)
</sql:update>


3.  Fix "No namespace declaration found for prefix: xxforms"

apache-tomcat-6.0.32/webapps/orbeon/WEB-INF/resources/apps/xforms-sql-address-book/view.xhtml

This file has a "org.orbeon.oxf.common.OXFException: No namespace declaration found for prefix: xxforms" error.  Any data entry in view.xhtml form will trigger this error.

Add xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" to the list of xmlns declarations. 

The orbeon.log was not useful for this last error (it was great for the SQL errors).  The log showed:
2011-04-27 12:33:13,495 ERROR ProcessorService  - Exception at line 55, column 65 of oxf:/ops/xforms/xforms-server.xpl (reading processor output: name='response', id='xforms-response')
org.orbeon.oxf.common.OXFException: No namespace declaration found for prefix: xxforms

I couldn't find xforms-server.xpl inside apache-tomcat-6.0.32/webapps/orbeon/.  view.xhtml itself did not directly make use of xxforms.  I only stumbled on the fix by guessing.  

Since view.xhtml didn't make use of xxforms, perhaps the fix really needs to be some place else (e.g. wherever make use of xxform)?


At any rate, I really like Orbeon Forms.  Hopefully this will help others!  

Orbeon folks, please keep xforms-sql-address-book up to date and functional.  I'd imagine Orbeon plus MySQL is a very popular combination.


 
Happy Coding!
James




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws