use of org.apache.tapestry5.commons.util.AvailableValues in project tapestry-5 by apache.
the class PageLoaderImpl method addParameterBindingAction.
private void addParameterBindingAction(AssemblerContext context, final EmbeddedComponentAssembler embeddedAssembler, final String parameterName, final String parameterValue, final String metaDefaultBindingPrefix, final Location location, final boolean ignoreUnmatchedFormal) {
if (embeddedAssembler.isBound(parameterName))
return;
embeddedAssembler.setBound(parameterName);
if (parameterValue.startsWith(InternalConstants.INHERIT_BINDING_PREFIX)) {
String containerParameterName = parameterValue.substring(InternalConstants.INHERIT_BINDING_PREFIX.length());
addInheritedBindingAction(context, parameterName, containerParameterName);
return;
}
context.add(new PageAssemblyAction() {
public void execute(PageAssembly pageAssembly) {
// Because of published parameters, we have to wait until page assembly time to throw out
// informal parameters bound to components that don't support informal parameters ...
// otherwise we'd throw out (sometimes!) published parameters.
final ParameterBinder binder = embeddedAssembler.createParameterBinder(parameterName);
if (binder == null) {
if (ignoreUnmatchedFormal) {
return;
}
throw new UnknownValueException(String.format("Component %s does not include a formal parameter '%s' (and does not support informal parameters).", pageAssembly.createdElement.peek().getCompleteId(), parameterName), null, null, new AvailableValues("Formal parameters", embeddedAssembler.getFormalParameterNames()));
}
final String defaultBindingPrefix = binder.getDefaultBindingPrefix(metaDefaultBindingPrefix);
InternalComponentResources containerResources = pageAssembly.activeElement.peek().getComponentResources();
ComponentPageElement embeddedElement = pageAssembly.createdElement.peek();
InternalComponentResources embeddedResources = embeddedElement.getComponentResources();
Binding binding = elementFactory.newBinding(parameterName, containerResources, embeddedResources, defaultBindingPrefix, parameterValue, location);
binder.bind(embeddedElement, binding);
}
});
}
use of org.apache.tapestry5.commons.util.AvailableValues in project tapestry-5 by apache.
the class PageLoaderImpl method parameter.
private void parameter(AssemblerContext context) {
final ParameterToken token = context.next(ParameterToken.class);
context.add(new PageAssemblyAction() {
public void execute(PageAssembly pageAssembly) {
String parameterName = token.name;
ComponentPageElement element = pageAssembly.createdElement.peek();
Location location = token.getLocation();
BlockImpl block = new BlockImpl(location, interner.format("Parameter %s of %s", parameterName, element.getCompleteId()));
Binding binding = new LiteralBinding(location, "block parameter " + parameterName, block);
EmbeddedComponentAssembler embeddedAssembler = pageAssembly.embeddedAssembler.peek();
ParameterBinder binder = embeddedAssembler.createParameterBinder(parameterName);
if (binder == null) {
throw new UnknownValueException(String.format("Component %s does not include a formal parameter '%s' (and does not support informal parameters).", element.getCompleteId(), parameterName), location, null, new AvailableValues("Formal parameters", embeddedAssembler.getFormalParameterNames()));
}
binder.bind(pageAssembly.createdElement.peek(), binding);
pageAssembly.bodyElement.push(block);
}
});
consumeToEndElementAndPopBodyElement(context);
}
use of org.apache.tapestry5.commons.util.AvailableValues in project tapestry-5 by apache.
the class ComponentClassResolverImpl method resolveComponentTypeToClassName.
public String resolveComponentTypeToClassName(final String componentType) {
Data data = getData();
String result = locate(componentType, data.componentToClassName);
if (result == null) {
throw new UnknownValueException(String.format("Unable to resolve '%s' to a component class name.", componentType), new AvailableValues("Component types", presentableNames(data.componentToClassName)));
}
return result;
}
use of org.apache.tapestry5.commons.util.AvailableValues in project tapestry-5 by apache.
the class ComponentClassResolverImpl method canonicalizePageName.
public String canonicalizePageName(final String pageName) {
Data data = getData();
String result = locate(pageName, data.pageNameToCanonicalPageName);
if (result == null) {
throw new UnknownValueException(String.format("Unable to resolve '%s' to a known page name.", pageName), new AvailableValues("Page names", presentableNames(data.pageNameToCanonicalPageName)));
}
return result;
}
use of org.apache.tapestry5.commons.util.AvailableValues in project tapestry-5 by apache.
the class ComponentClassResolverImpl method resolveMixinTypeToClassName.
public String resolveMixinTypeToClassName(final String mixinType) {
Data data = getData();
String result = locate(mixinType, data.mixinToClassName);
if (result == null) {
throw new UnknownValueException(String.format("Unable to resolve '%s' to a mixin class name.", mixinType), new AvailableValues("Mixin types", presentableNames(data.mixinToClassName)));
}
return result;
}
Aggregations