You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by Stefan Kolb <st...@web.de> on 2010/02/27 12:04:38 UTC

JSP with Tuscany

Hi,

im trying to use JSP Pages with my application now. I got this running with the taglib for components with one service with no problems yet.
Though im wondering how i can do this if a component offers two or more services.

Consider this scenario:
- a base composite which includes a component that offers 2 services:

<composite name="Solution"> 
<component name="ShopComposite">
...
</component>

ShopComposite exposes 2 services:

<service name="CatalogService" promote="CatalogComponent/CatalogService"/>
<service name="ShoppingCartService" promote="ShoppingCartComponent/ShoppingCartService"/>

Now take a look at the JSP-File:

<sca:reference name="ShopComposite/ShoppingCartService" type="shop.cart.ShoopingCartService"/>
<html>
<head>
	<title>SCA Shop</title>
</head>
<body>
<img src="header.png" alt="Shop Header">
<!-- Liste zum auswählen, Button Zahlungsart, Button pay, ergebis mit verfügbarkeit -->
<%= ???.invokeSomething() %> // How can i use the reference here???
</body>
</html>

If i reference the service correctly it has to be ShopComposite/ShoppingCartService.
But how can i use this reference name then?
ShopComposite/ShoppingCartService.xxx() should probably not work as this isnt allowed as var name in jsp?!
If it just had one service ShoppingCartService i could have just referenced the Component ShopComposite
and invoke some Method through ShopComposite.xxx() as i did successfully.
Any suggestions?

Regards

Stefan
___________________________________________________________
WEB.DE DSL: Internet, Telefon und Entertainment für nur 19,99 EUR/mtl.!
http://produkte.web.de/go/02/

Re: JSP with Tuscany

Posted by Simon Laws <si...@googlemail.com>.
Hi Stefan

I think that the JSP tag libraries are intended to be used in
conjunction with an implementation.web component implementation type,
for example,

Composite
=========

<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
           xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
           targetNamespace="http://samples"
           name="Helloworld">

    <component name="foo">
        <implementation.web web-uri=""/>
        <reference name="service" target="HelloworldComponent"/>
    </component>

    <component name="HelloworldComponent">
        <implementation.java class="sample.HelloworldServiceImpl"/>
    </component>

</composite>


JSP
===

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://www.osoa.org/sca/sca_jsp.tld" prefix="sca" %>

<sca:reference name="service" type="sample.HelloworldService" />

<html>
  <body >

    <h2>Apache Tuscany Helloworld JSP Sample</h2>

    Calling HelloworldService sayHello("world") returns:

    <p>

    <%= service.sayHello("world") %>

  </body>
</html>

Here the <sca:reference name="service"  refers to the reference of the
"foo" component which then goes on to specific the name of the target
component/service. So the target name can include a "/" without
affecting the name of the reference.

I believe Ant bought up support for this in our Tomcat integration.

Regards

Simon