use of org.apache.tapestry5.commons.Location in project tapestry-5 by apache.
the class PropBindingFactoryTest method unknown_property.
@Test
public void unknown_property() {
TargetBean bean = new TargetBean();
ComponentResources resources = mockComponentResources();
Location l = mockLocation();
train_getComponent(resources, bean);
replay();
try {
factory.newBinding("test binding", resources, null, "missingProperty", l);
unreachable();
} catch (RuntimeException ex) {
assertMessageContains(ex, "Class org.apache.tapestry5.internal.bindings.TargetBean does not contain a property", "\'missingProperty\'");
}
verify();
}
use of org.apache.tapestry5.commons.Location in project tapestry-5 by apache.
the class PropBindingFactoryTest method method_not_found_in_preamble.
@Test
public void method_not_found_in_preamble() {
TargetBean bean = new TargetBean();
ComponentResources resources = mockComponentResources();
Location l = mockLocation();
train_getComponent(resources, bean);
replay();
try {
factory.newBinding("test binding", resources, null, "isThatRealBlood().value", l);
unreachable();
} catch (RuntimeException ex) {
assertMessageContains(ex, "Class org.apache.tapestry5.internal.bindings.TargetBean does not contain a public method named 'isThatRealBlood()'");
}
verify();
}
use of org.apache.tapestry5.commons.Location in project tapestry-5 by apache.
the class PlasticProxyFactoryImpl method getMemberLocation.
public Location getMemberLocation(Member member, String methodName, String memberTypeDesc, ObjectCreator<String> textDescriptionCreator) {
String className = member.getDeclaringClass().getName();
String key = className + ":" + methodName + ":" + memberTypeDesc;
Location location = memberToLocation.get(key);
if (location == null) {
location = constructMemberLocation(member, methodName, memberTypeDesc, textDescriptionCreator.createObject());
memberToLocation.put(key, location);
}
return location;
}
use of org.apache.tapestry5.commons.Location in project tapestry-5 by apache.
the class BindingSourceImpl method newBinding.
public Binding newBinding(String description, ComponentResources container, ComponentResources component, String defaultPrefix, String expression, Location location) {
assert InternalUtils.isNonBlank(description);
assert container != null;
assert InternalUtils.isNonBlank(defaultPrefix);
assert component != null;
// TAP5-845: The expression may be the empty string. This is ok, if it's compatible with
// the default prefix (the empty string is not a valid property expression, but is valid
// as a literal string, perhaps as an informal parameter).
// Location might be null
String subexpression = expression;
int colonx = expression.indexOf(':');
BindingFactory factory = null;
if (colonx > 0) {
String prefix = expression.substring(0, colonx);
factory = factories.get(prefix);
if (factory != null)
subexpression = expression.substring(colonx + 1);
}
if (factory == null)
factory = factories.get(defaultPrefix);
try {
return factory.newBinding(interner.intern(description), container, component, subexpression, location);
} catch (Exception ex) {
throw new TapestryException(String.format("Could not convert '%s' into a component parameter binding: %s", expression, ExceptionUtils.toMessage(ex)), location, ex);
}
}
use of org.apache.tapestry5.commons.Location in project tapestry-5 by apache.
the class DynamicTemplateSaxParser method element.
private DynamicTemplateElement element() {
String elementURI = tokenStream.getNamespaceURI();
String elementName = tokenStream.getLocalName();
String blockId = null;
int count = tokenStream.getAttributeCount();
List<DynamicTemplateAttribute> attributes = CollectionFactory.newList();
Location location = getLocation();
for (int i = 0; i < count; i++) {
QName qname = tokenStream.getAttributeName(i);
// The name will be blank for an xmlns: attribute
String localName = qname.getLocalPart();
if (InternalUtils.isBlank(localName))
continue;
String uri = qname.getNamespaceURI();
String value = tokenStream.getAttributeValue(i);
if (localName.equals("id")) {
Matcher matcher = PARAM_ID_PATTERN.matcher(value);
if (matcher.matches()) {
blockId = matcher.group(1);
continue;
}
}
Mapper<DynamicDelegate, String> attributeValueExtractor = createCompositeExtractorFromText(value, location);
attributes.add(new DynamicTemplateAttribute(uri, localName, attributeValueExtractor));
}
if (blockId != null)
return block(blockId);
List<DynamicTemplateElement> body = CollectionFactory.newList();
boolean atEnd = false;
while (!atEnd) {
switch(tokenStream.next()) {
case START_ELEMENT:
// Recurse into this new element
body.add(element());
break;
case END_ELEMENT:
body.add(END);
atEnd = true;
break;
default:
addTextContent(body);
}
}
return createElementWriterElement(elementURI, elementName, attributes, body);
}
Aggregations