Bean bean = (Bean) pageContext.getAttribute("bean", PageContext.REQUEST_SCOPE); if (bean == null) { bean = new Bean(); pageContext.setAttribute("bean", bean, PageContext.REQUEST_SCOPE); } // Use bean ...
Bean bean = new Bean(); StringProperty nameProperty() = new JavaBeanStringPropertyBuilder() .bean(bean) .name("name") .build(); nameProperty().addListener((obs, oldName, newName) -> System.out.println("name changed from "+oldName+" to "+newName)); bean.setName("James"); System.out.println(nameProperty().get());
public boolean isCollection() { BeanRuntimeInfo.Classification classification = creator.getBeanRuntimeInfo().getClassification(); return (classification == Classification.COLLECTION_COLLECTION || classification == Classification.ARRAY_COLLECTION); }
private Object decodeDataString(String dataString, ExecutionContext executionContext) throws DataDecodeException { if((dataString == null || dataString.length() == 0) && defaultValue != null) { if(defaultValue.equals("null")) { return null; } dataString = defaultValue; } try { return getDecoder(executionContext).decode(dataString); } catch(DataDecodeException e) { throw new DataDecodeException("Failed to decode the value '" + dataString + "' for the bean id '" + beanIdName +"'.", e); } }
/** * Set the binding value data type. * @param type The data type. * * @return <code>this</code> Value configuration instance. */ public Value setType(Class<?> type) { this.decoder = DataDecoder.Factory.create(type); return this; }
/** * Create a binding configuration to bind the data, selected from the message by the * dataSelector, to the target Collection/array Bean beanclass instance. * * @param dataSelector The data selector for the data value to be bound. * @return <code>this</code> Bean configuration instance. */ public Bean bindTo(String dataSelector) { return bindTo(dataSelector, (DataDecoder) null); }
public Class<?> getBeanClass() { return creator.getBeanRuntimeInfo().getPopulateType(); }
private void decodeAndSetPropertyValue(String mapPropertyName, Object dataObject, ExecutionContext executionContext, Fragment source) { if(dataObject instanceof String) { setPropertyValue(mapPropertyName, decodeDataString((String) dataObject, executionContext), executionContext, source); } else { setPropertyValue(mapPropertyName, dataObject, executionContext, source); } }
private BeanRuntimeInfo getWiredBeanRuntimeInfo() { if(wiredBeanRuntimeInfo == null) { // Don't need to synchronize this. Worse thing that can happen is we initialize it // more than once... no biggie... wiredBeanRuntimeInfo = BeanRuntimeInfo.getBeanRuntimeInfo(wireBeanIdName, appContext); } return wiredBeanRuntimeInfo; }
private Object decodeDataString(String dataString, ExecutionContext executionContext) throws DataDecodeException { if((dataString == null || dataString.length() == 0) && defaultValue != null) { if(defaultValue.equals("null")) { return null; } dataString = defaultValue; } try { return getDecoder(executionContext).decode(dataString); } catch(DataDecodeException e) { throw new DataDecodeException("Failed to decode the value '" + dataString + "' for the bean id '" + beanIdName +"'.", e); } }
if (bean == null) { bean = new Bean(); getServletContext().setAttribute("bean", bean); }
public boolean isCollection() { BeanRuntimeInfo.Classification classification = creator.getBeanRuntimeInfo().getClassification(); return (classification == Classification.COLLECTION_COLLECTION || classification == Classification.ARRAY_COLLECTION); }
public Class<?> getBeanClass() { return creator.getBeanRuntimeInfo().getPopulateType(); }
private Object decodeDataString(String dataString, ExecutionContext executionContext) throws DataDecodeException { if((dataString == null || dataString.length() == 0) && defaultValue != null) { if(defaultValue.equals("null")) { return null; } dataString = defaultValue; } try { return getDecoder(executionContext).decode(dataString); } catch(DataDecodeException e) { throw new DataDecodeException("Failed to decode the value '" + dataString + "' for the bean id '" + beanIdName +"'.", e); } }
request.setAttribute("bean", new Bean()); request.getRequestDispatcher("page.jsp").forward(request, response);
public boolean isCollection() { BeanRuntimeInfo.Classification classification = creator.getBeanRuntimeInfo().getClassification(); return (classification == Classification.COLLECTION_COLLECTION || classification == Classification.ARRAY_COLLECTION); }
HttpSession session = request.getSession(false); session == null ? null : session.setAttribute("<keyname>", new Bean());
ServletRequest request = ... // get the reference to the servlet request object request.setAttribute("<keyname>", new Bean());
@Produces(MediaType.APPLICATION_JSON) @JacksonFeatures(serializationEnable = { SerializationFeature.INDENT_OUTPUT }) public Bean resource() { return new Bean() }
/** * Create a Bean binding configuration. * * @param beanClass The bean runtime class. * @param beanId The bean ID. * @param createOnElement The element selector used to create the bean instance. * @param createOnElementNS The namespace for the element selector used to create the bean instance. */ public static Bean newBean(Class<?> beanClass, String beanId, String createOnElement, String createOnElementNS) { return new Bean(beanClass, beanId, createOnElement, createOnElementNS); }