You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Muhammad Gelbana <m....@gmail.com> on 2012/05/20 15:21:35 UTC

[t5.3] Using a map object with BeanEditor

Has anyone tried to edit a map instance using a bean editor ? I checked
this page "http://tapestry.apache.org/beaneditform-guide.html" and now I'm
trying to add a custom property but It isn't working:

model = beanModelSource.createEditModel(Map.class, resources.getMessages());
model.add("F Var", propertyConduitSrc.create(String.class, "put"));

Exception:
An exception has occurred: *Render queue error in
BeginRender[Index:myform]: Exception generating conduit for expression
'put': Class java.lang.String does not contain a property (or public field)
named 'put'.*


How can I tell tapestry the setter method and the getter method for a map
and to make the beaneditor create the form for it ?

Thank you.

-- 
*Regards,*
*Muhammad Gelbana
Java Developer*

Re: [t5.3] Using a map object with BeanEditor

Posted by trsvax <tr...@gmail.com>.
Here is how I did it

http://tapestry.1045711.n5.nabble.com/writer-writeRaw-String-text-td5601234.html#a5601626

--
View this message in context: http://tapestry.1045711.n5.nabble.com/t5-3-Using-a-map-object-with-BeanEditor-tp5712589p5712988.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [t5.3] Using a map object with BeanEditor

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Mon, 21 May 2012 04:03:54 -0300, Muhammad Gelbana <m....@gmail.com>  
wrote:

> I understand from the link you provided is that I have 2 choices, either  
> to implement BeanModel<T> for editing or go a step back and implement a
> BeanModelSource (which according to the document "provides support to the
> model by generating validation information for individual fields.")

Nope. There's at least one more. The solution in the code is to implement  
PropertyConduit and add the properties using beanModel.add("name",  
conduit).

-- 
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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [t5.3] Using a map object with BeanEditor

Posted by Lance Java <la...@googlemail.com>.
> So the question is, what if I have those validation strings
(maxLength=5,minLength=2..etc) in an independant string ? Because I intend
to have this information in a database (label, name\id, validation rules). 

You could provide a DatabaseConstraintGenerator in a similar way to how
Tapestry provides a MessagesConstraintGenerator.
1. In your AppModule, decorate the "FieldValidatorDefaultSource" service to
push and pop any contextual information that you will need to lookup your
database config (most likely the fieldName and the pageName).
2. Implement a ValidationConstraintGenerator which uses Environment.peek()
to lookup the context and get the constraints for a field
3. Contribute your DatabaseConstraintGenerator to the
"ValidationConstraintGenerator" service.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/t5-3-Using-a-map-object-with-BeanEditor-tp5712589p5712781.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [t5.3] Using a map object with BeanEditor

Posted by Muhammad Gelbana <m....@gmail.com>.
I can say it's not simple at all but I'm trying to comprehend it, specially
that the code in the link you provided has some deprecated methods. But
while I'm trying to master this, what if I need to apply validation too ?

I understand from the link you provided is that I have 2 choices, either to
implement BeanModel<T> for editing or go a step back and implement a
BeanModelSource (which according to the document "provides support to the
model by generating validation information for individual fields.")

After looking a bit into tapestry code I found that the BeanModelSource
uses the Messages object to provide labels for the propertyes and most
probably validation rules too but I still haven't found were is that yet.So
the question is, what if I have those validation strings
(maxLength=5,minLength=2..etc) in an independant string ? Because I intend
to have this information in a database (label, name\id, validation rules).

On Sun, May 20, 2012 at 3:44 PM, Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Sun, 20 May 2012 10:21:35 -0300, Muhammad Gelbana <m....@gmail.com>
> wrote:
>
>  Has anyone tried to edit a map instance using a bean editor ?
>>
>
> Check http://tapestry.1045711.n5.**nabble.com/T5-Best-way-to-**
> alter-core-components-**tp2408801p2408802.html<http://tapestry.1045711.n5.nabble.com/T5-Best-way-to-alter-core-components-tp2408801p2408802.html>.
> Basically, you need to implement PropertyConduit instead of relyaing in
> PropertyConduitSource, which works based on the class properties (getters
> and setters).
>
> --
> 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
>



-- 
*Regards,*
*Muhammad Gelbana
Java Developer*

Re: [t5.3] Using a map object with BeanEditor

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Sun, 20 May 2012 10:21:35 -0300, Muhammad Gelbana <m....@gmail.com>  
wrote:

> Has anyone tried to edit a map instance using a bean editor ?

Check  
http://tapestry.1045711.n5.nabble.com/T5-Best-way-to-alter-core-components-tp2408801p2408802.html.  
Basically, you need to implement PropertyConduit instead of relyaing in  
PropertyConduitSource, which works based on the class properties (getters  
and setters).

-- 
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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org