You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by George Christman <gc...@cardaddy.com> on 2012/04/16 16:22:06 UTC

Bean Edit Form w/ Select Menu

Hello, I'm trying to use a beaneditform for the first time, but I'm currently
facing a problem getting a select menu to appear and work. I'm using Tap3.2
along with hibernate

Source code

.tml

    <t:beaneditform t:id="evaluatorForm" object="evaluator"
submitlabel="Create Evaluator">
        <p:applicationUser>
            <t:label for="applicationUser"/>
            <t:Select t:id="applicationUser"
value="evaluator.applicationUser" model="applicationUserModel"/>
        </p:applicationUser>
    </t:beaneditform>


.class

public class Evaluator_Test {
    
    @Property
    private Evaluator evaluator;
    
    @Property
    private SelectModel applicationUserModel;
    
    @Inject
    private SelectModelFactory selectModelFactory;
    
    @Component(id = "evaluatorForm")
    private BeanEditForm evaluatorForm;

    @Inject
    private Session session;

    void onPrepare() throws Exception {
        evaluator = new Evaluator();
        this.applicationUserModel =
selectModelFactory.create(session.createCriteria(ApplicationUser.class).list(),
"name");
    }

Entity

@Entity
public class Evaluator extends AbstractBaseEntity {
    
    @Id
    @GeneratedValue 
    @NonVisual 
    private Long evaluatorId;
    
    @ManyToOne(fetch = FetchType.EAGER, optional = false)
    @JoinColumns(@JoinColumn(name = "application_user_id")) 
    private ApplicationUser applicationUser;

getters/setters

Could someone tell me what I'm doing wrong?


--
View this message in context: http://tapestry.1045711.n5.nabble.com/Bean-Edit-Form-w-Select-Menu-tp5643951p5643951.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: Bean Edit Form w/ Select Menu

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Mon, 16 Apr 2012 12:07:17 -0300, ICE Ernesto Arteaga Zavala  
<ar...@gmail.com> wrote:

> Hehehe hi,

Hi!

>  I need the same explanation! I found that if, the entity has a user  
> Object tapestry could not make the coercion object... so in the  
> beaneditor or
> beaneditform I need to add it.

Tapestry (actually, BeanModelSource) doesn't add a form field for it  
automatically because there's no Tapestry type (which is just a String)  
assigned for it. Why? Tapestry doesn't know which options to present for  
any object which isn't an enum. You can add edition and viewing blocks by  
following the instructions in the BeanEditForm page in the documentation.

-- 
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: Bean Edit Form w/ Select Menu

Posted by ICE Ernesto Arteaga Zavala <ar...@gmail.com>.
Hehehe hi,

 I need the same explanation! I found that if, the entity has a user Object
tapestry could not make the coercion object... so in the beaneditor or
beaneditform I need to add it.

Some more clarification, please!

2012/4/16 George Christman <gc...@cardaddy.com>

> I answered my own question, looks like I just needed to add the parameter
> "add". I didn't think I'd need to add the parameter since applicationUser
> existed in my entity bean. Can some one explain the reasoning behind this>
> Thanks.
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Bean-Edit-Form-w-Select-Menu-tp5643951p5644066.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
>
>


-- 
Saludos,

-------------------------------------------------------------------
"Nada que se consiga sin pena y sin trabajo
 es verdaderamente valioso."
                                          Joseph Addison
-------------------------------------------------------------------

ICE Ernesto Arteaga Zavala
Ingeniero de Desarrollo

Re: Bean Edit Form w/ Select Menu

Posted by George Christman <gc...@cardaddy.com>.
I answered my own question, looks like I just needed to add the parameter
"add". I didn't think I'd need to add the parameter since applicationUser
existed in my entity bean. Can some one explain the reasoning behind this>
Thanks.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Bean-Edit-Form-w-Select-Menu-tp5643951p5644066.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: Bean Edit Form w/ Select Menu

Posted by Chris Mylonas <ch...@opencsta.org>.
Hi George,


Maybe needs a ValueEncoder is needed to transform from an object to a text representation for your select.
http://jumpstart.doublenegative.com.au/jumpstart/examples/select/easyobject

That's just a guess by the way.

Cheers
Chris


On 17/04/2012, at 12:22 AM, George Christman wrote:

> Hello, I'm trying to use a beaneditform for the first time, but I'm currently
> facing a problem getting a select menu to appear and work. I'm using Tap3.2
> along with hibernate
> 
> Source code
> 
> .tml
> 
>    <t:beaneditform t:id="evaluatorForm" object="evaluator"
> submitlabel="Create Evaluator">
>        <p:applicationUser>
>            <t:label for="applicationUser"/>
>            <t:Select t:id="applicationUser"
> value="evaluator.applicationUser" model="applicationUserModel"/>
>        </p:applicationUser>
>    </t:beaneditform>
> 
> 
> .class
> 
> public class Evaluator_Test {
> 
>    @Property
>    private Evaluator evaluator;
> 
>    @Property
>    private SelectModel applicationUserModel;
> 
>    @Inject
>    private SelectModelFactory selectModelFactory;
> 
>    @Component(id = "evaluatorForm")
>    private BeanEditForm evaluatorForm;
> 
>    @Inject
>    private Session session;
> 
>    void onPrepare() throws Exception {
>        evaluator = new Evaluator();
>        this.applicationUserModel =
> selectModelFactory.create(session.createCriteria(ApplicationUser.class).list(),
> "name");
>    }
> 
> Entity
> 
> @Entity
> public class Evaluator extends AbstractBaseEntity {
> 
>    @Id
>    @GeneratedValue 
>    @NonVisual 
>    private Long evaluatorId;
> 
>    @ManyToOne(fetch = FetchType.EAGER, optional = false)
>    @JoinColumns(@JoinColumn(name = "application_user_id")) 
>    private ApplicationUser applicationUser;
> 
> getters/setters
> 
> Could someone tell me what I'm doing wrong?
> 
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Bean-Edit-Form-w-Select-Menu-tp5643951p5643951.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
> 


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