Search in sources :

Example 36 with TapestryException

use of org.apache.tapestry5.commons.internal.util.TapestryException in project tapestry-5 by apache.

the class ComponentWorker method addMixinClasses.

private void addMixinClasses(PlasticField field, MutableEmbeddedComponentModel model) {
    MixinClasses annotation = field.getAnnotation(MixinClasses.class);
    if (annotation == null)
        return;
    boolean orderEmpty = annotation.order().length == 0;
    if (!orderEmpty && annotation.order().length != annotation.value().length)
        throw new TapestryException(String.format("%d mixins defined via @MixinClasses on field '%s', but %d ordering constraints \\\n" + " specified (expected 0 or %1$d).", annotation.value().length, field.getName(), annotation.order().length), model, null);
    for (int i = 0; i < annotation.value().length; i++) {
        String[] constraints = orderEmpty ? CommonsUtils.EMPTY_STRING_ARRAY : TapestryInternalUtils.splitMixinConstraints(annotation.order()[i]);
        model.addMixin(annotation.value()[i].getName(), constraints);
    }
}
Also used : MixinClasses(org.apache.tapestry5.annotations.MixinClasses) TapestryException(org.apache.tapestry5.commons.internal.util.TapestryException)

Example 37 with TapestryException

use of org.apache.tapestry5.commons.internal.util.TapestryException in project tapestry-5 by apache.

the class ComponentPageElementImpl method addEmbeddedElement.

void addEmbeddedElement(ComponentPageElement child) {
    if (children == null)
        children = CollectionFactory.newList();
    String childId = child.getId();
    for (ComponentPageElement existing : children) {
        if (existing.getId().equalsIgnoreCase(childId))
            throw new TapestryException(StructureMessages.duplicateChildComponent(this, childId), child, new TapestryException(StructureMessages.originalChildComponent(this, childId, existing.getLocation()), existing, null));
    }
    children.add(child);
}
Also used : TapestryException(org.apache.tapestry5.commons.internal.util.TapestryException)

Aggregations

TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)37 Location (org.apache.tapestry5.commons.Location)12 Test (org.testng.annotations.Test)12 ComponentResources (org.apache.tapestry5.ComponentResources)11 Binding (org.apache.tapestry5.Binding)7 BindingFactory (org.apache.tapestry5.services.BindingFactory)4 IOException (java.io.IOException)3 InternalComponentResources (org.apache.tapestry5.internal.InternalComponentResources)3 Component (org.apache.tapestry5.runtime.Component)3 PropertyOverrides (org.apache.tapestry5.PropertyOverrides)2 TrackableComponentEventCallback (org.apache.tapestry5.TrackableComponentEventCallback)2 PropertyModel (org.apache.tapestry5.beanmodel.PropertyModel)2 Messages (org.apache.tapestry5.commons.Messages)2 Link (org.apache.tapestry5.http.Link)2 Instantiator (org.apache.tapestry5.internal.services.Instantiator)2 ComponentPageElement (org.apache.tapestry5.internal.structure.ComponentPageElement)2 Page (org.apache.tapestry5.internal.structure.Page)2 OperationException (org.apache.tapestry5.ioc.internal.OperationException)2 JSONObject (org.apache.tapestry5.json.JSONObject)2 BindingSource (org.apache.tapestry5.services.BindingSource)2