Hi,

Since two people have asked me for copies, I thought I would just post
the relevant bits of code for my Xtile 4.0 adaptation here. I make no
claims to be a Tapestry expert, so there may well be better ways of
doing this. In fact, there are a couple of lines I don't really
understand, but they seem to work, so I left them in :>) Anyway, for
what it is worth, here is what I did (Java 1.5, obviously):

In the XTileService:

        public void service(IRequestCycle cycle) throws IOException {
                WebRequest request =
cycle.getEngine().getInfrastructure().getRequest();
                String componentPageName =
request.getParameterValue(ServiceConstants.PAGE);
                String componentId =
request.getParameterValue(ServiceConstants.COMPONENT);
                IPage componentPage = cycle.getPage(componentPageName);
                IComponent component =
componentPage.getNestedComponent(componentId);
                if (!(component instanceof IXTile))
                        throw new ApplicationRuntimeException("Incorrect
component type: was " + component.getClass()
                                        + " but must be " +
IXTile.class, component, null, null);
                IXTile searcher = (IXTile) component;
                /* do not squeeze on input */
        
cycle.setListenerParameters(request.getParameterValues(ServiceConstants.
PARAMETER));
                searcher.trigger(cycle);
                /* do not squeeze on output either */
                Object[] args = cycle.getListenerParameters();
                String strArgs = generateOutputString(args);
                OutputStream out =
cycle.getEngine().getInfrastructure().getResponse().getOutputStream(
                                new ContentType("text/xml"));
                out.write(strArgs.getBytes("utf-8"));
        }

In Xtile:

        public Map<String, String> getScriptSymbols() {
                WebRequest request =
getPage().getEngine().getInfrastructure().getRequest();
                Map<String, String> symbols = new HashMap<String,
String>();
                symbols.put("sendFunctionName", getSendName());
                symbols.put("receiveFunctionName", getReceiveName());
                symbols.put("receiveFunctionName", getReceiveName());
                symbols.put("errorFunctionName", getErrorName());
                symbols.put("disableCaching", getDisableCaching() ?
"true" : null);
                Map<String, String> parameters = new HashMap<String,
String>();
                parameters.put(ServiceConstants.SERVICE,
XTileService.SERVICE_NAME);
                parameters.put(ServiceConstants.PAGE,
getPage().getPageName());
                parameters.put(ServiceConstants.COMPONENT,
this.getId());
                ILink link = new
EngineServiceLink(getPage().getRequestCycle(), request.getRequestURI(),
"UTF-8",
                                new URLCodec(), request, parameters,
true);
                symbols.put("url", link.getURL());
                return symbols;
        }

The rest of the code stays the same.

I had some problems with the script symbols - internally, Tapestry seems
to be creating nested maps from the symbols, so the ognl functions were
returning null. I hacked this in the Tapestry source by adding searches
for baseSymbols.sendFunctionName etc if sendFunctionName returned null.
I'm not sure if this is a bug in Tapestry 4.0 - I haven't had time to
track it down properly. If the function names in the generated
JavaScript are empty (as they were when I tried to use the current
version of Xtile with 4.0), then maybe it is a Tapestry bug, and I'll
gladly post details of my hack, in case that helps track it down.

Best wishes

John

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to