use of org.apache.tapestry5.model.ComponentModel in project tapestry-5 by apache.
the class BindParameterWorker method getEmbeddedComponentResourcesForPublishedParameter.
/**
* Returns the {@link InternalComponentResources} of an embeddedComponent that contains the published parameter
* publishedParameterName. This is basically a recursive search for published parameters.
*/
private InternalComponentResources getEmbeddedComponentResourcesForPublishedParameter(InternalComponentResources containerResources, String publishedParameterName) {
List<InternalComponentResources> embeddedComponentResourcesList = CollectionFactory.newList();
embeddedComponentResourcesList.add(containerResources);
while (!embeddedComponentResourcesList.isEmpty()) {
InternalComponentResources resources = embeddedComponentResourcesList.remove(0);
ComponentModel containerComponentModel = resources.getComponentModel();
for (String embeddedComponentId : containerComponentModel.getEmbeddedComponentIds()) {
EmbeddedComponentModel embeddedComponentModel = containerComponentModel.getEmbeddedComponentModel(embeddedComponentId);
InternalComponentResources embeddedComponentResources = (InternalComponentResources) resources.getEmbeddedComponent(embeddedComponentId).getComponentResources();
/**
* If the parameter is not a formal parameter, then the parameter must be a published parameter
* of an embeddedComponent of the component we are currently examining.
*/
if (embeddedComponentModel.getPublishedParameters().contains(publishedParameterName) && embeddedComponentResources.getComponentModel().isFormalParameter(publishedParameterName)) {
return embeddedComponentResources;
}
embeddedComponentResourcesList.add(embeddedComponentResources);
}
}
return null;
}
use of org.apache.tapestry5.model.ComponentModel in project tapestry-5 by apache.
the class DefaultOpenApiDescriptionGenerator method processPageClass.
private void processPageClass(Page page, JSONObject paths, JSONArray tags) throws NoSuchMethodException {
final Class<?> pageClass = page.getRootComponent().getClass();
final String tagName = addPageTag(tags, pageClass);
ComponentModel model = page.getRootComponent().getComponentResources().getComponentModel();
JSONArray methodsAsJson = getMethodsAsJson(model);
List<Method> methods = toMethods(methodsAsJson, pageClass);
for (Method method : methods) {
processMethod(method, pageClass, paths, tagName);
}
}
use of org.apache.tapestry5.model.ComponentModel in project tapestry-5 by apache.
the class InternalComponentResourcesImplTest method add_page_lifecycle_listener.
@Test
public void add_page_lifecycle_listener() {
Component component = mockComponent();
Instantiator ins = mockInstantiator(component);
ComponentModel model = mockComponentModel();
ComponentPageElement element = mockComponentPageElement();
Page page = mockPage();
PageLifecycleListener listener = newMock(PageLifecycleListener.class);
train_getModel(ins, model);
page.addLifecycleListener(listener);
replay();
InternalComponentResources resources = new InternalComponentResourcesImpl(page, element, null, null, null, null, ins, false);
resources.addPageLifecycleListener(listener);
verify();
}
use of org.apache.tapestry5.model.ComponentModel in project tapestry-5 by apache.
the class InternalComponentResourcesImplTest method post_render_cleanup_removes_all_variables.
@Test
public void post_render_cleanup_removes_all_variables() {
Component component = mockComponent();
Instantiator ins = mockInstantiator(component);
ComponentModel model = mockComponentModel();
train_getModel(ins, model);
replay();
InternalComponentResources resources = new InternalComponentResourcesImpl(null, null, null, elementResources, "Foo.bar", null, ins, false);
resources.storeRenderVariable("fred", "FRED");
resources.storeRenderVariable("barney", "BARNEY");
resources.postRenderCleanup();
try {
resources.getRenderVariable("fred");
unreachable();
} catch (IllegalArgumentException ex) {
assertEquals(ex.getMessage(), "Component Foo.bar does not contain a stored render variable with name 'fred'. Stored render variables: (none).");
}
verify();
}
use of org.apache.tapestry5.model.ComponentModel in project tapestry-5 by apache.
the class InternalComponentResourcesImplTest method get_property_name.
@Test
public void get_property_name() {
Component component = mockComponent();
Instantiator ins = mockInstantiator(component);
ComponentModel model = mockComponentModel();
ComponentPageElement element = mockComponentPageElement();
Page page = mockPage();
Binding binding = mockBinding();
train_getModel(ins, model);
replay();
InternalComponentResources resources = new InternalComponentResourcesImpl(page, element, null, null, null, null, ins, false);
resources.bindParameter("bar", binding);
assertNull(resources.getPropertyName("bar"));
verify();
}
Aggregations