/* $$ Clover has instrumented this file $$ */// Copyright 2004 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package org.apache.tapestry.callback;
import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.tapestry.IComponent;
import org.apache.tapestry.IDirect;
import org.apache.tapestry.IPage;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.Tapestry;
/**
* Simple callback for re-invoking a {@link IDirect} component trigger..
*
* @author Howard Lewis Ship
* @since 0.2.9
*
**/
public class DirectCallback implements ICallback
{public static com.cortexeb.tools.clover.d __CLOVER_56_0 = com.cortexeb.tools.clover.aq.getRecorder(new char[] {67,58,92,119,111,114,107,115,112,97,99,101,92,106,97,107,97,114,116,97,45,116,97,112,101,115,116,114,121,92,102,114,97,109,101,119,111,114,107,92,116,97,114,103,101,116,92,99,108,111,118,101,114,45,100,98},1096998272901L);
/**
* @since 2.0.4
*
**/
private static final long serialVersionUID = -8888847655917503471L;
private String _pageName;
private String _componentIdPath;
private Object[] _parameters;
public String toString()
{try { __CLOVER_56_0.M[344]++;
__CLOVER_56_0.S[1397]++;StringBuffer buffer = new StringBuffer("DirectCallback[");
__CLOVER_56_0.S[1398]++;buffer.append(_pageName);
__CLOVER_56_0.S[1399]++;buffer.append('/');
__CLOVER_56_0.S[1400]++;buffer.append(_componentIdPath);
__CLOVER_56_0.S[1401]++;if ((((_parameters != null) && (++__CLOVER_56_0.CT[270] != 0)) || (++__CLOVER_56_0.CF[270] == 0))){
{
__CLOVER_56_0.S[1402]++;String sep = " ";
__CLOVER_56_0.S[1403]++;for (int i = 0; (((i < _parameters.length) && (++__CLOVER_56_0.CT[271] != 0)) || (++__CLOVER_56_0.CF[271] == 0)); i++){
{
__CLOVER_56_0.S[1404]++;buffer.append(sep);
__CLOVER_56_0.S[1405]++;buffer.append(_parameters[i]);
__CLOVER_56_0.S[1406]++;sep = ", ";
}}
}}
__CLOVER_56_0.S[1407]++;buffer.append(']');
__CLOVER_56_0.S[1408]++;return buffer.toString();
} finally { }}
/**
* Creates a new DirectCallback for the component. The parameters
* (which may be null) is retained, not copied.
*
**/
public DirectCallback(IDirect component, Object[] parameters)
{try { __CLOVER_56_0.M[345]++;
__CLOVER_56_0.S[1409]++;_pageName = component.getPage().getPageName();
__CLOVER_56_0.S[1410]++;_componentIdPath = component.getIdPath();
__CLOVER_56_0.S[1411]++;_parameters = parameters;
} finally { }}
/**
* Locates the {@link IDirect} component that was previously identified
* (and whose page and id path were stored).
* Invokes {@link IRequestCycle#setServiceParameters(Object[])} to
* restore the service parameters, then
* invokes {@link IDirect#trigger(IRequestCycle)} on the component.
*
**/
public void performCallback(IRequestCycle cycle)
{try { __CLOVER_56_0.M[346]++;
__CLOVER_56_0.S[1412]++;IPage page = cycle.getPage(_pageName);
__CLOVER_56_0.S[1413]++;IComponent component = page.getNestedComponent(_componentIdPath);
__CLOVER_56_0.S[1414]++;IDirect direct = null;
__CLOVER_56_0.S[1415]++;try
{
__CLOVER_56_0.S[1416]++;direct = (IDirect) component;
}
catch (ClassCastException ex)
{
__CLOVER_56_0.S[1417]++;throw new ApplicationRuntimeException(
Tapestry.format("DirectCallback.wrong-type", component.getExtendedId()),
component,
null,
ex);
}
__CLOVER_56_0.S[1418]++;cycle.setServiceParameters(_parameters);
__CLOVER_56_0.S[1419]++;direct.trigger(cycle);
} finally { }}
}