/** * Creates a new ComponentAddress object that carries the identification information of the * given component (the page name and the ID path). * * @param component * the component to get the address of */ public ComponentAddress(IComponent component) { this(component.getPage().getPageName(), component.getIdPath()); }
/** * Creates a new ComponentAddress object that carries the identification information of the * given component (the page name and the ID path). * * @param component * the component to get the address of */ public ComponentAddress(IComponent component) { this(component.getPage().getPageName(), component.getIdPath()); }
public ILink getLink(boolean post, Object parameter) { Defense.isAssignable(parameter, IComponent.class, "parameter"); IComponent component = (IComponent) parameter; Map parameters = new HashMap(); parameters.put(ServiceConstants.PAGE, component.getPage().getPageName()); parameters.put(ServiceConstants.COMPONENT, component.getIdPath()); return _linkFactory.constructLink(this, false, parameters, true); }
public Messages getMessages(IComponent component) { return new ComponentMessages(component.getPage().getLocale(), getLocalizedProperties(component)); }
public Messages getMessages(IComponent component) { return new ComponentMessages(component.getPage().getLocale(), getLocalizedProperties(component)); }
/** * Constructor used when the action id is found, but the target id path did * not match the actual id path. */ public StaleLinkException(IComponent component, String targetActionId, String targetIdPath) { super(Tapestry.format("StaleLinkException.action-mismatch", new String[] { targetActionId, component.getIdPath(), targetIdPath }), component, null, null); _page = component.getPage(); _pageName = _page.getPageName(); _targetActionId = targetActionId; _targetIdPath = targetIdPath; }
/** * Constructor used when the action id is found, but the target id path did * not match the actual id path. */ public StaleLinkException(IComponent component, String targetActionId, String targetIdPath) { super(Tapestry.format("StaleLinkException.action-mismatch", new String[] { targetActionId, component.getIdPath(), targetIdPath }), component, null, null); _page = component.getPage(); _pageName = _page.getPageName(); _targetActionId = targetActionId; _targetIdPath = targetIdPath; }
/** * Method used by pages and components to send notifications about property changes. * * @param component * the component containing the property * @param propertyName * the name of the property which changed * @param newValue * the new value for the property * @since 3.0 */ public static void fireObservedChange(IComponent component, String propertyName, Object newValue) { ChangeObserver observer = component.getPage().getChangeObserver(); if (observer == null) return; ObservedChangeEvent event = new ObservedChangeEvent(component, propertyName, newValue); observer.observeChange(event); } }
/** * Method used by pages and components to send notifications about property changes. * * @param component * the component containing the property * @param propertyName * the name of the property which changed * @param newValue * the new value for the property * @since 3.0 */ public static void fireObservedChange(IComponent component, String propertyName, Object newValue) { ChangeObserver observer = component.getPage().getChangeObserver(); if (observer == null) return; ObservedChangeEvent event = new ObservedChangeEvent(component, propertyName, newValue); observer.observeChange(event); } }
/** * Returns an instance of {@link Properties} containing the properly * localized messages for the component, in the {@link Locale} identified by * the component's containing page. * * @param component * The component to get properties for. * * @return A new {@link Properties} instance representing the localized properties for * the specified component. */ protected Properties getLocalizedProperties(IComponent component) { Defense.notNull(component, "component"); Resource specificationLocation = component.getSpecification().getSpecificationLocation(); Locale locale = component.getPage().getLocale(); Map propertiesMap = findPropertiesMapForResource(specificationLocation); Properties result = (Properties) propertiesMap.get(locale); if (result == null) { // Not found, create it now. result = assembleComponentProperties(component, specificationLocation, propertiesMap, locale); propertiesMap.put(locale, result); } return result; }
void invokeComponentListeners(IComponent component, IRequestCycle cycle, BrowserEvent event) { String idPath = component.getExtendedId(); List listeners = getEventListeners(idPath); if (listeners == null) return; IPage page = component.getPage(); for (int i = 0; i < listeners.size(); i++) { IComponentSpecification listener = (IComponentSpecification)listeners.get(i); ComponentEventProperty props = listener.getComponentEvents(idPath); if (props == null) continue; List clisteners = props.getEventListeners(event.getName()); for (int e=0; e < clisteners.size(); e++) { EventBoundListener eventListener = (EventBoundListener)clisteners.get(e); IComponent target = page.getNestedComponent(eventListener.getComponentIdPath()); _invoker.invokeListener(target.getListeners().getListener(eventListener.getMethodName()), target, cycle); } } }
public BeanProvider(IComponent component) { _component = component; Infrastructure infrastructure = component.getPage().getRequestCycle().getInfrastructure(); _resolver = infrastructure.getClassResolver(); INamespace namespace = component.getNamespace(); _packageList = namespace.getPropertyValue("org.apache.tapestry.bean-class-packages"); _classFinder = infrastructure.getClassFinder(); }
void invokeComponentListeners(IComponent component, IRequestCycle cycle, BrowserEvent event) { String idPath = component.getExtendedId(); List listeners = getEventListeners(idPath); if (listeners == null) return; IPage page = component.getPage(); for (int i = 0; i < listeners.size(); i++) { IComponentSpecification listener = (IComponentSpecification)listeners.get(i); ComponentEventProperty props = listener.getComponentEvents(idPath); if (props == null) continue; List clisteners = props.getEventListeners(event.getName()); for (int e=0; e < clisteners.size(); e++) { EventBoundListener eventListener = (EventBoundListener)clisteners.get(e); IComponent target = page.getNestedComponent(eventListener.getComponentIdPath()); _invoker.invokeListener(target.getListeners().getListener(eventListener.getMethodName()), target, cycle); } } }
public BeanProvider(IComponent component) { _component = component; Infrastructure infrastructure = component.getPage().getRequestCycle().getInfrastructure(); _resolver = infrastructure.getClassResolver(); INamespace namespace = component.getNamespace(); _packageList = namespace.getPropertyValue("org.apache.tapestry.bean-class-packages"); _classFinder = infrastructure.getClassFinder(); }
void wireElementFormEvents(EventBoundListener listener, IComponent component, IComponentSpecification spec) { if (listener.getFormId() == null) return; if (_forms.size() < 1) discoverPageForms(component.getPage()); IForm form = null; for (int i=0; i < _forms.size(); i++) { IForm f = (IForm) _forms.get(i); if (listener.getFormId().equals(f.getExtendedId()) || listener.getFormId().equals(f.getId())) { form = f; break; } } // couldn't find the form they specified if (form == null) throw new ApplicationRuntimeException(PageloadMessages.componentNotFound(listener.getFormId()), component, component.getLocation(), null); String idPath = form.getExtendedId(); listener.setFormId(idPath); _invoker.addFormEventListener(idPath, spec); }
void wireElementFormEvents(EventBoundListener listener, IComponent component, IComponentSpecification spec) { if (listener.getFormId() == null) return; if (_forms.size() < 1) discoverPageForms(component.getPage()); IForm form = null; for (int i=0; i < _forms.size(); i++) { IForm f = (IForm) _forms.get(i); if (listener.getFormId().equals(f.getExtendedId()) || listener.getFormId().equals(f.getId())) { form = f; break; } } // couldn't find the form they specified if (form == null) throw new ApplicationRuntimeException(PageloadMessages.componentNotFound(listener.getFormId()), component, component.getLocation(), null); String idPath = form.getExtendedId(); listener.setFormId(idPath); _invoker.addFormEventListener(idPath, spec); }
/** * Reads the template for the component. */ public ComponentTemplate getTemplate(IRequestCycle cycle, IComponent component) { IComponentSpecification specification = component.getSpecification(); Resource resource = specification.getSpecificationLocation(); Locale locale = component.getPage().getLocale(); Object key = new MultiKey(new Object[] { resource, locale }, false); ComponentTemplate result = searchCache(key); if (result != null) return result; result = findTemplate(cycle, resource, component, locale); if (result == null) { result = _delegate.findTemplate(cycle, component, locale); if (result != null) return result; String message = component.getSpecification().isPageSpecification() ? ImplMessages .noTemplateForPage(component.getExtendedId(), locale) : ImplMessages .noTemplateForComponent(component.getExtendedId(), locale); throw new ApplicationRuntimeException(message, component, component.getLocation(), null); } saveToCache(key, result); return result; }
/** * Reads the template for the component. */ public ComponentTemplate getTemplate(IRequestCycle cycle, IComponent component) { IComponentSpecification specification = component.getSpecification(); Resource resource = specification.getSpecificationLocation(); Locale locale = component.getPage().getLocale(); Object key = new MultiKey(new Object[] { resource, locale }, false); ComponentTemplate result = searchCache(key); if (result != null) return result; result = findTemplate(cycle, resource, component, locale); if (result == null) { result = _delegate.findTemplate(cycle, component, locale); if (result != null) return result; String message = component.getSpecification().isPageSpecification() ? ImplMessages .noTemplateForPage(component.getExtendedId(), locale) : ImplMessages .noTemplateForComponent(component.getExtendedId(), locale); throw new ApplicationRuntimeException(message, component, component.getLocation(), null); } saveToCache(key, result); return result; }