Re: Adding properties to BeanModels dynamically
Yes, all trhough the API http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/beaneditor/BeanModel.html#add(org.apache.tapestry5.beaneditor.RelativePosition, java.lang.String, java.lang.String, org.apache.tapestry5.PropertyConduit) beanModel.add(null, "foo", "bar", conduit).dataType("string") On Sun, Feb 27, 2011 at 12:49 AM, Stephan Windmüller wrote: > On 24.02.2011 18:20, Thiago H. de Paula Figueiredo wrote: > >> That's strange. Your PropertyConduit implementation and use looks >> correct to me. > > As far as I can see, the constructor > > PropertyModelImpl(BeanModel, String, PropertyConduit, Messages) > > which is called by BeadModel.add(String, PropertyConduit) does not set > the datatype at all. I fixed it by setting the datatype manually to > "number", but is this the right way to go? > > - Stephan > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > -- Howard M. Lewis Ship Creator of Apache Tapestry The source for Tapestry training, mentoring and support. Contact me to learn how I can get you up and productive in Tapestry fast! (971) 678-5210 http://howardlewisship.com - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Adding properties to BeanModels dynamically
On 24.02.2011 18:20, Thiago H. de Paula Figueiredo wrote: > That's strange. Your PropertyConduit implementation and use looks > correct to me. As far as I can see, the constructor PropertyModelImpl(BeanModel, String, PropertyConduit, Messages) which is called by BeadModel.add(String, PropertyConduit) does not set the datatype at all. I fixed it by setting the datatype manually to "number", but is this the right way to go? - Stephan - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Adding properties to BeanModels dynamically
On Thu, 24. Feb 2011, Thiago H. de Paula Figueiredo wrote: > That's strange. Your PropertyConduit implementation and use looks correct > to me. Could you post the full stack trace please? Of course: org.apache.tapestry5.ioc.internal.util.TapestryException: The data type for property 'myValue' of null: null is null. [at classpath:org/apache/tapestry5/corelib/components/BeanEditor.tml, line 5] at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase.invoke(ComponentPageElementImpl.java:194) at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$BeginRenderPhase.render(ComponentPageElementImpl.java:246) at org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72) at org.apache.tapestry5.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:127) at $PageRenderQueue_12e58b89fbf.render($PageRenderQueue_12e58b89fbf.java) at $PageRenderQueue_12e58b89fb7.render($PageRenderQueue_12e58b89fb7.java) at org.apache.tapestry5.internal.services.MarkupRendererTerminator.renderMarkup(MarkupRendererTerminator.java:37) at org.apache.tapestry5.services.TapestryModule$29.renderMarkup(TapestryModule.java:2089) at $MarkupRenderer_12e58b89fc1.renderMarkup($MarkupRenderer_12e58b89fc1.java) at org.apache.tapestry5.services.TapestryModule$28.renderMarkup(TapestryModule.java:2073) at $MarkupRenderer_12e58b89fc1.renderMarkup($MarkupRenderer_12e58b89fc1.java) at org.apache.tapestry5.services.TapestryModule$27.renderMarkup(TapestryModule.java:2055) at $MarkupRenderer_12e58b89fc1.renderMarkup($MarkupRenderer_12e58b89fc1.java) at org.apache.tapestry5.services.TapestryModule$26.renderMarkup(TapestryModule.java:2040) at $MarkupRenderer_12e58b89fc1.renderMarkup($MarkupRenderer_12e58b89fc1.java) at org.apache.tapestry5.services.TapestryModule$25.renderMarkup(TapestryModule.java:2026) at $MarkupRenderer_12e58b89fc1.renderMarkup($MarkupRenderer_12e58b89fc1.java) at org.apache.tapestry5.services.TapestryModule$24.renderMarkup(TapestryModule.java:2008) at $MarkupRenderer_12e58b89fc1.renderMarkup($MarkupRenderer_12e58b89fc1.java) at org.apache.tapestry5.services.TapestryModule$23.renderMarkup(TapestryModule.java:1989) at $MarkupRenderer_12e58b89fc1.renderMarkup($MarkupRenderer_12e58b89fc1.java) at $MarkupRenderer_12e58b89fbe.renderMarkup($MarkupRenderer_12e58b89fbe.java) at org.apache.tapestry5.internal.services.PageMarkupRendererImpl.renderPageMarkup(PageMarkupRendererImpl.java:47) at $PageMarkupRenderer_12e58b89fbc.renderPageMarkup($PageMarkupRenderer_12e58b89fbc.java) at org.apache.tapestry5.internal.services.PageResponseRendererImpl.renderPageResponse(PageResponseRendererImpl.java:67) at $PageResponseRenderer_12e58b89f5e.renderPageResponse($PageResponseRenderer_12e58b89f5e.java) at org.apache.tapestry5.internal.services.PageRenderRequestHandlerImpl.handle(PageRenderRequestHandlerImpl.java:64) at org.apache.tapestry5.services.TapestryModule$36.handle(TapestryModule.java:2326) at $PageRenderRequestHandler_12e58b89f60.handle($PageRenderRequestHandler_12e58b89f60.java) at $PageRenderRequestHandler_12e58b89f5a.handle($PageRenderRequestHandler_12e58b89f5a.java) at org.apache.tapestry5.internal.services.ComponentRequestHandlerTerminator.handlePageRender(ComponentRequestHandlerTerminator.java:48) at org.apache.tapestry5.services.InitializeActivePageName.handlePageRender(InitializeActivePageName.java:47) at $ComponentRequestHandler_12e58b89f5b.handlePageRender($ComponentRequestHandler_12e58b89f5b.java) at $ComponentRequestHandler_12e58b89f3f.handlePageRender($ComponentRequestHandler_12e58b89f3f.java) at org.apache.tapestry5.internal.services.PageRenderDispatcher.dispatch(PageRenderDispatcher.java:45) at $Dispatcher_12e58b89f41.dispatch($Dispatcher_12e58b89f41.java) at $Dispatcher_12e58b89f3c.dispatch($Dispatcher_12e58b89f3c.java) at org.apache.tapestry5.services.TapestryModule$RequestHandlerTerminator.service(TapestryModule.java:321) at org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26) at $RequestHandler_12e58b89f3d.service($RequestHandler_12e58b89f3d.java) at org.apache.tapestry5.services.TapestryModule$4.service(TapestryModule.java:984) at $RequestHandler_12e58b89f3d.service($RequestHandler_12e58b89f3d.java) at org.apache.tapestry5.services.TapestryModule$3.service(TapestryModule.java:974) at $RequestHandler_12e58b89f3d.service($RequestHandler_12e58b89f3d.java) at org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:90) at $RequestHandler_12e58b89f3d.service($RequestHandler_12e58b89f3d.java
Re: Adding properties to BeanModels dynamically
That's strange. Your PropertyConduit implementation and use looks correct to me. Could you post the full stack trace please? The datatype is defined by the DataTypeAnalyzer service, and its configuration provided by Tapestry alread maps BigDecimal to the "number" datatype. On Thu, 24 Feb 2011 14:02:14 -0300, Stephan Windmüller wrote: On Thu, 24. Feb 2011, Thiago H. de Paula Figueiredo wrote: The resulting model contains properties with a null datatype. That surely looks like something you shouldn't do. How can the component know how edit an value which hasn't a data type? In this case, you either define a custom datatype and provide edition and viewing blocks for them or you don't add this property to the bean model. It's a simple number. Okay, not simple, but BigDecimal. However, I did not set/change the datatype myself, as you can see in the posted code. If you need more information like how I build the PropertyConduit, please let me know. Please post it. private void addPropertyConduitsToBeanModel(BeanModel model) { for (final ValueType valueTypes : dao.getValueTypes()) { PropertyConduit propertyConduit = new PropertyConduit() { public Object get(Object instance) { MyObject myObject = (MyObject) instance; return model.getValue(valueType); } public void set(Object instance, Object value) { MyObject myObject = (MyObject) instance; BigDecimal myValue = (BigDecimal) value; myObject.setValue(valueType, value); } public Class getPropertyType() { return BigDecimal.class; } public T getAnnotation(Class annotationClass) { return null; } }; String propertyName = valueType.getName(); model.add(propertyName, propertyConduit); } } - Stephan -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. Consultor, desenvolvedor e instrutor em Java, Tapestry e Hibernate Coordenador e professor da Especialização em Engenharia de Software com Ênfase em Java da Faculdade Pitágoras http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Adding properties to BeanModels dynamically
On Thu, 24. Feb 2011, Thiago H. de Paula Figueiredo wrote: >> The resulting model contains properties with a null datatype. > That surely looks like something you shouldn't do. How can the component > know how edit an value which hasn't a data type? In this case, you either > define a custom datatype and provide edition and viewing blocks for them > or you don't add this property to the bean model. It's a simple number. Okay, not simple, but BigDecimal. However, I did not set/change the datatype myself, as you can see in the posted code. >> If you need more information like how I build the PropertyConduit, >> please let me know. > Please post it. private void addPropertyConduitsToBeanModel(BeanModel model) { for (final ValueType valueTypes : dao.getValueTypes()) { PropertyConduit propertyConduit = new PropertyConduit() { public Object get(Object instance) { MyObject myObject = (MyObject) instance; return model.getValue(valueType); } public void set(Object instance, Object value) { MyObject myObject = (MyObject) instance; BigDecimal myValue = (BigDecimal) value; myObject.setValue(valueType, value); } public Class getPropertyType() { return BigDecimal.class; } public T getAnnotation(Class annotationClass) { return null; } }; String propertyName = valueType.getName(); model.add(propertyName, propertyConduit); } } - Stephan signature.asc Description: Digital signature
Re: Adding properties to BeanModels dynamically
On Thu, 24 Feb 2011 13:33:44 -0300, Stephan Windmüller wrote: List valueTypes = dao.getValueTypes(); BeanModel model = beanModelSource.createEditModel(MyObject.class, messages); for (String type : valueTypes) { PropertyConduit propertyConduit = new PropertyConduit() { ... }; model.add(type, propertyConduit); } This looks correct. The resulting model contains properties with a null datatype. That surely looks like something you shouldn't do. How can the component know how edit an value which hasn't a data type? In this case, you either define a custom datatype and provide edition and viewing blocks for them or you don't add this property to the bean model. If you need more information like how I build the PropertyConduit, please let me know. Please post it. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Adding properties to BeanModels dynamically
On Thu, 24. Feb 2011, Thiago H. de Paula Figueiredo wrote: >> I tried to create one with BeanModelSource.createEditModel using my own >> propertyConduits. But when the BeanEditForm loads, the datatype of the >> property is null and I am getting this error: >> "The data type for property 'name' of null: null is null." > Please post your code. The datatype of a property can never be null. In short, it is reduced to this: - List valueTypes = dao.getValueTypes(); BeanModel model = beanModelSource.createEditModel(MyObject.class, messages); for (String type : valueTypes) { PropertyConduit propertyConduit = new PropertyConduit() { ... }; model.add(type, propertyConduit); } - The resulting model contains properties with a null datatype. If you need more information like how I build the PropertyConduit, please let me know. Regards Stephan signature.asc Description: Digital signature
Re: Adding properties to BeanModels dynamically
On Thu, 24 Feb 2011 12:35:50 -0300, Stephan Windmüller wrote: Hello! Hi! Is it possible to extend the BeanModel of an object dynamically for a BeanEditForm? Yes! I tried to create one with BeanModelSource.createEditModel using my own propertyConduits. But when the BeanEditForm loads, the datatype of the property is null and I am getting this error: "The data type for property 'name' of null: null is null." Please post your code. The datatype of a property can never be null. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Adding properties to BeanModels dynamically
Hello! Is it possible to extend the BeanModel of an object dynamically for a BeanEditForm? I tried to create one with BeanModelSource.createEditModel using my own propertyConduits. But when the BeanEditForm loads, the datatype of the property is null and I am getting this error: "The data type for property 'name' of null: null is null." Is this the wrong way to extend the model? Regards Stephan - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org