1 15 package org.apache.tapestry.callback; 16 17 import org.apache.hivemind.ApplicationRuntimeException; 18 import org.apache.hivemind.util.Defense; 19 import org.apache.tapestry.IExternalPage; 20 import org.apache.tapestry.IRequestCycle; 21 22 108 109 public class ExternalCallback implements ICallback 110 { 111 private static final long serialVersionUID = -6783421589702643930L; 112 113 private String _pageName; 114 115 private Object [] _parameters; 116 117 121 122 public ExternalCallback(String pageName, Object [] parameters) 123 { 124 Defense.notNull(pageName, "pageName"); 125 126 _pageName = pageName; 127 _parameters = parameters; 128 } 129 130 134 135 public ExternalCallback(IExternalPage page, Object [] parameters) 136 { 137 Defense.notNull(page, "page"); 138 139 _pageName = page.getPageName(); 140 _parameters = parameters; 141 } 142 143 148 149 public void performCallback(IRequestCycle cycle) 150 { 151 Defense.notNull(cycle, "cycle"); 152 153 try 154 { 155 IExternalPage page = (IExternalPage) cycle.getPage(_pageName); 156 157 cycle.activate(page); 158 159 page.activateExternalPage(_parameters, cycle); 160 } 161 catch (ClassCastException ex) 162 { 163 throw new ApplicationRuntimeException(CallbackMessages.pageNotExternal(_pageName), ex); 164 } 165 } 166 167 public String toString() 168 { 169 StringBuffer buffer = new StringBuffer ("ExternalCallback["); 170 171 buffer.append(_pageName); 172 173 if (_parameters != null) 174 { 175 for (int i = 0; i < _parameters.length; i++) 176 { 177 if (i == 0) 178 buffer.append('/'); 179 else 180 buffer.append(", "); 181 182 buffer.append(_parameters[i]); 183 } 184 } 185 186 buffer.append(']'); 187 188 return buffer.toString(); 189 } 190 } | Popular Tags |