001 /*
002 * Copyright 2004 Chris Nelson
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
007 * Unless required by applicable law or agreed to in writing,
008 * software distributed under the License is distributed on an "AS IS" BASIS,
009 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
010 * See the License for the specific language governing permissions and limitations under the License.
011 */
012 package org.trails.component;
013
014 import org.apache.tapestry.IActionListener;
015 import org.apache.tapestry.IRequestCycle;
016 import org.trails.descriptor.IMethodDescriptor;
017 import org.trails.exception.TrailsRuntimeException;
018
019
020 public abstract class InvokeMethod extends TrailsComponent
021 {
022 public abstract IMethodDescriptor getMethodDescriptor();
023
024 public abstract void setMethodDescriptor(IMethodDescriptor MethodDescriptor);
025
026 public abstract IActionListener getListener();
027
028 public abstract void setListener(IActionListener Listener);
029
030 public abstract Object getModel();
031
032 public abstract void setModel(Object Model);
033
034 public void click(IRequestCycle cycle)
035 {
036 try
037 {
038 getMethodDescriptor().getMethod().invoke(getModel());
039 } catch (Exception e)
040 {
041 throw new TrailsRuntimeException(e, getModel().getClass());
042 }
043
044 if (getListener() != null)
045 {
046 getListener().actionTriggered(this, cycle);
047 }
048 }
049 }