public Object get(Object instance, InstanceContext context) { return required ? environment.peekRequired(environmentalType) : environment.peek(environmentalType); }
protected final <T> void train_peek(Environment env, Class<T> type, T value) { expect(env.peek(type)).andReturn(value); }
protected void removePropertyNameFromBeanValidationContext() { if (beanValidationDisabled) { return; } BeanValidationContext beanValidationContext = environment.peek(BeanValidationContext.class); if (beanValidationContext == null) return; beanValidationContext.setCurrentProperty(null); } }
void setupRender() { FormSupport existing = environment.peek(FormSupport.class); if (existing != null) { throw new TapestryException(messages.get("core-form-nesting-not-allowed"), existing, null); } if (clientValidation == ClientValidation.BLUR) { deprecationWarning.componentParameterValue(resources, "clientValidation", clientValidation, "BLUR is no longer supported, starting in 5.4. Validation will occur as with SUBMIT."); } }
protected void putPropertyNameIntoBeanValidationContext(String parameterName) { if (beanValidationDisabled) { return; } String propertyName = ((InternalComponentResources) resources).getPropertyName(parameterName); BeanValidationContext beanValidationContext = environment.peek(BeanValidationContext.class); if (beanValidationContext == null) return; // If field is inside BeanEditForm, then property is already set if (beanValidationContext.getCurrentProperty() == null) { beanValidationContext.setCurrentProperty(propertyName); } }
final BeanValidationContext beanValidationContext = environment.peek(BeanValidationContext.class);
final BeanValidationContext beanValidationContext = environment.peek(BeanValidationContext.class);
public List<String> buildConstraints(Class propertyType, AnnotationProvider annotationProvider) { EnvironmentMessages environmentMessages = environment.peek(EnvironmentMessages.class); if (environmentMessages == null) { return null; } String key = environmentMessages.getOverrideId() + "-validate"; Messages m = environmentMessages.getMessages(); if (!m.contains(key)) { return null; } String result = m.get(key); if (InternalUtils.isBlank(result)) { return null; } return Arrays.asList(splitPattern.split(result)); } }
private void fireValidateEvent(String eventName, EventContext context, TrackableComponentEventCallback callback) { try { resources.triggerContextEvent(eventName, context, callback); } catch (RuntimeException ex) { ValidationException ve = ExceptionUtils.findCause(ex, ValidationException.class, propertyAccess); if (ve != null) { ValidationTracker tracker = environment.peek(ValidationTracker.class); tracker.recordError(ve.getMessage()); return; } throw ex; } }
@Override public void render(final MarkupWriter writer) final BeanValidationContext beanValidationContext = environment.peek(BeanValidationContext.class);
@Override public void render(final MarkupWriter writer) final BeanValidationContext beanValidationContext = environment.peek(BeanValidationContext.class);
BeanValidationContext beanValidationContext = environment.peek(BeanValidationContext.class);
void afterRender(MarkupWriter writer) { environment.peek(Heartbeat.class).end(); formSupport.executeDeferred(); String encodingType = formSupport.getEncodingType(); if (encodingType != null) { form.forceAttributes("enctype", encodingType); } writer.end(); // form div.element("input", "type", "hidden", "name", FORM_DATA, "value", actionSink.getClientData()); div.pop(); if (autofocus) { environment.pop(ValidationDecorator.class); } }
@Test public void push_and_pop() { Environment e = new EnvironmentImpl(); Runnable r1 = mockRunnable(); Runnable r2 = mockRunnable(); replay(); assertNull(e.push(Runnable.class, r1)); assertSame(r1, e.peek(Runnable.class)); assertSame(r1, e.push(Runnable.class, r2)); assertSame(r2, e.peek(Runnable.class)); assertSame(r2, e.pop(Runnable.class)); assertSame(r1, e.pop(Runnable.class)); verify(); }