use of org.apache.tapestry5.annotations.Id in project flowlogix by flowlogix.
the class PeriodicUpdater method afterRender.
@AfterRender
void afterRender() {
final String id = zone.getClientId();
Link link;
if (context == null) {
link = resources.createEventLink(event);
} else {
link = resources.createEventLink(event, context);
}
final JSONObject spec = new JSONObject();
spec.put("period", period);
spec.put("elementId", id);
spec.put("uri", link.toAbsoluteURI());
jsSupport.addInitializerCall("periodicUpdater", spec);
}
use of org.apache.tapestry5.annotations.Id in project tapestry-5 by apache.
the class SaxTemplateParser method element.
/**
* Processes an element through to its matching end tag.
*
* An element can be:
*
* a Tapestry component via <t:type>
*
* a Tapestry component via t:type="type" and/or t:id="id"
*
* a Tapestry component via a library namespace
*
* A parameter element via <t:parameter>
*
* A parameter element via <p:name>
*
* A <t:remove> element (in the 5.1 schema)
*
* A <t:content> element (in the 5.1 schema)
*
* A <t:block> element
*
* The body <t:body>
*
* An ordinary element
*/
void element(TemplateParserState initialState) {
TemplateParserState state = setupForElement(initialState);
String uri = tokenStream.getNamespaceURI();
String name = tokenStream.getLocalName();
Version version = NAMESPACE_URI_TO_VERSION.get(uri);
if (T_5_1.sameOrEarlier(version)) {
if (name.equalsIgnoreCase("remove")) {
removeContent();
return;
}
if (name.equalsIgnoreCase("content")) {
limitContent(state);
return;
}
if (name.equalsIgnoreCase("extension-point")) {
extensionPoint(state);
return;
}
if (name.equalsIgnoreCase("replace")) {
throw new RuntimeException("The <replace> element may only appear directly within an extend element.");
}
if (MUST_BE_ROOT.contains(name))
mustBeRoot(name);
}
if (version != null) {
if (name.equalsIgnoreCase("body")) {
body();
return;
}
if (name.equalsIgnoreCase("container")) {
mustBeRoot(name);
}
if (name.equalsIgnoreCase("block")) {
block(state);
return;
}
if (name.equalsIgnoreCase("parameter")) {
if (T_5_3.sameOrEarlier(version)) {
throw new RuntimeException(String.format("The <parameter> element has been deprecated in Tapestry 5.3 in favour of '%s' namespace.", TAPESTRY_PARAMETERS_URI));
}
classicParameter(state);
return;
}
possibleTapestryComponent(state, null, tokenStream.getLocalName().replace('.', '/'));
return;
}
if (uri != null && uri.startsWith(LIB_NAMESPACE_URI_PREFIX)) {
libraryNamespaceComponent(state);
return;
}
if (TAPESTRY_PARAMETERS_URI.equals(uri)) {
parameterElement(state);
return;
}
// Just an ordinary element ... unless it has t:id or t:type
possibleTapestryComponent(state, tokenStream.getLocalName(), null);
}
use of org.apache.tapestry5.annotations.Id in project tapestry-5 by apache.
the class SaxTemplateParser method possibleTapestryComponent.
/**
* @param elementName
* @param identifiedType
* the type of the element, usually null, but may be the
* component type derived from element
*/
private void possibleTapestryComponent(TemplateParserState state, String elementName, String identifiedType) {
String id = null;
String type = identifiedType;
String mixins = null;
int count = tokenStream.getAttributeCount();
Location location = getLocation();
List<TemplateToken> attributeTokens = CollectionFactory.newList();
for (int i = 0; i < count; i++) {
QName qname = tokenStream.getAttributeName(i);
if (isXMLSpaceAttribute(qname))
continue;
// 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);
Version version = NAMESPACE_URI_TO_VERSION.get(uri);
if (version != null) {
if (T_5_4.sameOrEarlier(version)) {
strictMixinParameters = true;
}
if (localName.equalsIgnoreCase(ID_ATTRIBUTE_NAME)) {
id = nullForBlank(value);
validateId(id, "Component id '%s' is not valid; component ids must be valid Java identifiers: start with a letter, and consist of letters, numbers and underscores.");
continue;
}
if (type == null && localName.equalsIgnoreCase(TYPE_ATTRIBUTE_NAME)) {
type = nullForBlank(value);
continue;
}
if (localName.equalsIgnoreCase(MIXINS_ATTRIBUTE_NAME)) {
mixins = nullForBlank(value);
continue;
}
// Anything else is the name of a Tapestry component parameter
// that is simply
// not part of the template's doctype for the element being
// instrumented.
}
attributeTokens.add(new AttributeToken(uri, localName, value, location));
}
boolean isComponent = (id != null || type != null);
if (mixins != null && !isComponent)
throw new TapestryException(String.format("You may not specify mixins for element <%s> because it does not represent a component (which requires either an id attribute or a type attribute).", elementName), location, null);
if (isComponent) {
tokenAccumulator.add(new StartComponentToken(elementName, id, type, mixins, location));
} else {
tokenAccumulator.add(new StartElementToken(tokenStream.getNamespaceURI(), elementName, location));
}
addDefineNamespaceTokens();
tokenAccumulator.addAll(attributeTokens);
if (id != null)
componentIds.put(id, location);
processBody(state.insideComponent(isComponent));
}
use of org.apache.tapestry5.annotations.Id in project tapestry-5 by apache.
the class ComponentDefaultProviderImplTest method no_matching_property_for_default.
@Test
public void no_matching_property_for_default() {
String parameterName = "myparam";
String id = "mycomponentid";
ComponentResources resources = mockComponentResources();
Component container = mockComponent();
PropertyAccess access = mockPropertyAccess();
ClassPropertyAdapter classPropertyAdapter = mockClassPropertyAdapter();
BindingSource bindingSource = mockBindingSource();
train_getId(resources, id);
train_getContainer(resources, container);
train_getAdapter(access, container, classPropertyAdapter);
train_getPropertyAdapter(classPropertyAdapter, id, null);
replay();
ComponentDefaultProvider source = new ComponentDefaultProviderImpl(access, bindingSource, null, null, null);
assertNull(source.defaultBinding(parameterName, resources));
verify();
}
use of org.apache.tapestry5.annotations.Id in project tapestry-5 by apache.
the class AbstractBeanModelSourceImplTest method unknown_property_id.
@Test
public void unknown_property_id() {
Messages messages = mockMessages();
stub_contains(messages, false);
replay();
BeanModel model = source.create(SimpleBean.class, true, messages);
model.addEmpty("shrub.foo()");
try {
model.getById("frobozz");
unreachable();
} catch (UnknownValueException ex) {
assertEquals(ex.getMessage(), "Bean editor model for org.apache.tapestry5.internal.services.SimpleBean does not contain a property with id \'frobozz\'.");
assertListsEquals(ex.getAvailableValues().getValues(), "age", "firstName", "lastName", "shrubfoo");
}
verify();
}
Aggregations