You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by thegreatmewel <th...@gmail.com> on 2013/11/06 11:53:48 UTC

POJO's in Forms

Hi, I'm new to Tapestry and have some problems using forms. I have the 
following simple setup:

// my entity class
@Entity
public class User {

     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     @NonVisual
     public Long id;

     @Validate("required")
     public String firstName;

}

// my controller class
public class RegisterUser {

     @Property
     private User user;

     @CommitAfter
     Object onSuccess() {
         session.persist(user);
         return index;
     }

}

// and my form
<html t:type="layout" title="Create Account"
   xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd">

<form t:type="form" t:id="registerForm" class="form-horizontal"
   role="form">

   <div class="form-group">
     <t:label for="firstName" class="col-sm-2 control-label" />
     <div class="col-sm-6">
       <input t:type="TextField" t:id="user.firstName" t:validate="required"
         class="form-control" />
     </div>
   </div>
   <input type="submit" value="Create" />
</form>

</html>

As you see i liked to use bootstrap and some extra html markup in my 
form. So the default beaneditform isn't what i wanted here (its working 
by the way).

My questions:
1. I got an error for using "user.firstName" in t:id. If I just use 
"firstName" I have to add the same property in my RegisterUser class. 
But I'd like to avoid that. It is possible to build a form just with the 
"user" variable?

2. If I use "firstName" instead of "user.firstName" and hit the submit 
button, nothing happens. The onSuccess method is not called and I don't 
get any log message in my console.

3. When is tapestry 5.4 released (a week, a month or a year). I like to 
use jquery instead of prototype. The Tapestry5-jQuery works, but it uses 
an old jquery version.

Thanks in advance, and I like the framework :).

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


Re: POJO's in Forms

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 08 Nov 2013 08:59:14 -0200, thegreatmewel  
<th...@gmail.com> wrote:

> Hi Thiago, it works now, thanks a lot. So the t:id attribute is bound to  
> the component and the value attribute is bound to the property.

Yep, but, actually, t:id isn't bound to anything: it's not a parameter,  
it's a component id, nothing more than that.

> I think thats all a little bit confusing for new tapestry users like me.  
> First of all the "value" attribute. In standard HTML the value attribute  
> of an input field defines its predefined value. This is pretty obvious,  
> the component gets its value from the "value"-attribute and you can  
> access it with getVal() in js. But using this attribute to bind it to a  
> tapestry property makes no sense to me, because thats a different  
> thing.  Why not name it t:property? This would make it a lot clearer.

In this case, my perception is the opposite: the value attribute of HTML  
form fields will be populated by the bound property when it's rendered and  
then used to populate the property when the form submission is done, so  
it's very natural to have the property binding to be named 'value'.

> Second, why do I need to define a component and a property binding? Why  
> cannot the component itself has a getValue() method? Well maybe thats a  
> design decision and I don't see the advantage. But for me its extra code  
> which confuses me.

Because then you'd need write code to copy the current value from edited  
property to component, so the field is populated with the current property  
value, and from component to edited property, so the property you editing  
gets the value the user typed, yourself. Just like you do in Struts 1, and  
it sucks big time. It also provides Tapestry the chance to automatically  
convert values (you can use a TextField to edit any kind of object,  
provided there's a Translator for it) and also apply validations  
automatically.

Actually, the way the Tapestry form fields components are written is  
avoiding code, not creating extra code. Again, your perception here is the  
opposite. And, in more than 6 years in this mailing list, you're the first  
one to say that. :P

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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


Re: POJO's in Forms

Posted by thegreatmewel <th...@gmail.com>.
Hi Thiago, it works now, thanks a lot. So the t:id attribute is bound to 
the component and the value attribute is bound to the property.

I think thats all a little bit confusing for new tapestry users like me. 
First of all the "value" attribute. In standard HTML the value attribute 
of an input field defines its predefined value. This is pretty obvious, 
the component gets its value from the "value"-attribute and you can 
access it with getVal() in js. But using this attribute to bind it to a 
tapestry property makes no sense to me, because thats a different 
thing.  Why not name it t:property? This would make it a lot clearer.

Second, why do I need to define a component and a property binding? Why 
cannot the component itself has a getValue() method? Well maybe thats a 
design decision and I don't see the advantage. But for me its extra code 
which confuses me.

Anyway, thanks Thiago for your support :).

On 11/08/13 02:25, Thiago H de Paula Figueiredo wrote:
> On Thu, 07 Nov 2013 18:17:10 -0200, thegreatmewel 
> <th...@gmail.com> wrote:
>
>> I'm not sure what do you mean with a getter for passwordRequest? I 
>> have a passwordRepeat field and a getter getPasswordRepeat(). I 
>> thought that is enough.
>
> <t:passwordfield t:id="passwordRepeat" class="form-control" />
>
> As you haven't set the 'value' parameter explicitly, you bound it to 
> the PasswordField instance yourself. You should add a @Property 
> private String password; field to the Java class, add value="password" 
> to the line and it'll work.
>
> <t:passwordfield t:id="passwordRepeat" value="password" 
> class="form-control" />
>
>>
>> On 11/07/13 20:35, Thiago H de Paula Figueiredo wrote:
>>> Aren't you missing a getter for passwordRequest?
>>>
>>> On Thu, 07 Nov 2013 17:27:52 -0200, thegreatmewel 
>>> <th...@gmail.com> wrote:
>>>
>>>> Yep, im using 5.4-alpha-24 and with bootstrap it looks a lot nicer. 
>>>> Now I have a strange problem with my password repeat field. I 
>>>> always get the error:
>>>> org.apache.tapestry5.ioc.internal.OperationException
>>>> Render queue error in BeginRender[user/Register:passwordrepeat]: 
>>>> Parameter 'translate' of component user/Register:passwordrepeat is 
>>>> bound to null. This parameter is not allowed to be null.
>>>>
>>>> [controller snippet]
>>>>      @InjectComponent
>>>>      private PasswordField passwordRepeat;
>>>>
>>>>      @Component
>>>>      private Form registerAccount;
>>>>
>>>>      public PasswordField getPasswordRepeat() {
>>>>          return passwordRepeat;
>>>>      }
>>>>
>>>>      void onValidateFromRegisterAccount() {
>>>>          if (!user.password.equals(passwordRepeat)) {
>>>>              registerAccount.recordError(passwordRepeat, "Please 
>>>> enter the same password in both password fields.");
>>>>          }
>>>>      }
>>>> [/controller snippet]
>>>>
>>>> and my tml:
>>>>
>>>> <t:form class="form-horizontal" t:id="registerAccount">
>>>>    <t:errors />
>>>>
>>>>    <t:beaneditor object="user" 
>>>> reorder="firstName,lastName,email,phoneNumber,password">
>>>>      <p:password>
>>>>        <div class="form-group">
>>>>          <t:label for="password" class="col-sm-2 control-label" />
>>>>          <div class="col-sm-6">
>>>>            <t:passwordfield t:id="password" value="user.password"
>>>>              class="form-control" />
>>>>          </div>
>>>>        </div>
>>>>      </p:password>
>>>>    </t:beaneditor>
>>>>
>>>>    <div class="form-group">
>>>>      <t:label for="passwordRepeat" class="col-sm-2 control-label" />
>>>>      <div class="col-sm-6">
>>>>        <t:passwordfield t:id="passwordRepeat" class="form-control" />
>>>>      </div>
>>>>    </div>
>>>>
>>>>    <div class="btn-toolbar">
>>>>      <div class="btn-group">
>>>>        <input class="btn btn-primary" type="submit" value="Create 
>>>> Account" />
>>>>      </div>
>>>>    </div>
>>>> </t:form>
>>>>
>>>> Well, it looks like that a 'translate' property of the password 
>>>> repeater field is missing. But I have no idea why.
>>>>
>>>> Thanks in advance
>>>> Matthias
>>>>
>>>> ps.
>>>> It's a bit confusing when using @Component or @InjectComponent, 
>>>> also its confusing when to add a "value" attribute to the t:* 
>>>> object an when not. Maybe i will figure this out in future :)
>>>>
>>>> On 11/06/13 23:00, Thiago H de Paula Figueiredo wrote:
>>>>> On Wed, 06 Nov 2013 18:21:04 -0200, thegreatmewel 
>>>>> <th...@gmail.com> wrote:
>>>>>
>>>>>> Hi Thiago, im overwhelmed, it works like a charm :). I just had 
>>>>>> to add 'class="form-horizontal"' to my form. Thanks a lot!
>>>>>
>>>>> Are you using 5.4-alpha-24? Nice to know someone is using one of 
>>>>> my rare (so far!) commits and it's working as it should. :)
>>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>>
>
>


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


Re: POJO's in Forms

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 07 Nov 2013 18:17:10 -0200, thegreatmewel  
<th...@gmail.com> wrote:

> I'm not sure what do you mean with a getter for passwordRequest? I have  
> a passwordRepeat field and a getter getPasswordRepeat(). I thought that  
> is enough.

<t:passwordfield t:id="passwordRepeat" class="form-control" />

As you haven't set the 'value' parameter explicitly, you bound it to the  
PasswordField instance yourself. You should add a @Property private String  
password; field to the Java class, add value="password" to the line and  
it'll work.

<t:passwordfield t:id="passwordRepeat" value="password"  
class="form-control" />

>
> On 11/07/13 20:35, Thiago H de Paula Figueiredo wrote:
>> Aren't you missing a getter for passwordRequest?
>>
>> On Thu, 07 Nov 2013 17:27:52 -0200, thegreatmewel  
>> <th...@gmail.com> wrote:
>>
>>> Yep, im using 5.4-alpha-24 and with bootstrap it looks a lot nicer.  
>>> Now I have a strange problem with my password repeat field. I always  
>>> get the error:
>>> org.apache.tapestry5.ioc.internal.OperationException
>>> Render queue error in BeginRender[user/Register:passwordrepeat]:  
>>> Parameter 'translate' of component user/Register:passwordrepeat is  
>>> bound to null. This parameter is not allowed to be null.
>>>
>>> [controller snippet]
>>>      @InjectComponent
>>>      private PasswordField passwordRepeat;
>>>
>>>      @Component
>>>      private Form registerAccount;
>>>
>>>      public PasswordField getPasswordRepeat() {
>>>          return passwordRepeat;
>>>      }
>>>
>>>      void onValidateFromRegisterAccount() {
>>>          if (!user.password.equals(passwordRepeat)) {
>>>              registerAccount.recordError(passwordRepeat, "Please enter  
>>> the same password in both password fields.");
>>>          }
>>>      }
>>> [/controller snippet]
>>>
>>> and my tml:
>>>
>>> <t:form class="form-horizontal" t:id="registerAccount">
>>>    <t:errors />
>>>
>>>    <t:beaneditor object="user"  
>>> reorder="firstName,lastName,email,phoneNumber,password">
>>>      <p:password>
>>>        <div class="form-group">
>>>          <t:label for="password" class="col-sm-2 control-label" />
>>>          <div class="col-sm-6">
>>>            <t:passwordfield t:id="password" value="user.password"
>>>              class="form-control" />
>>>          </div>
>>>        </div>
>>>      </p:password>
>>>    </t:beaneditor>
>>>
>>>    <div class="form-group">
>>>      <t:label for="passwordRepeat" class="col-sm-2 control-label" />
>>>      <div class="col-sm-6">
>>>        <t:passwordfield t:id="passwordRepeat" class="form-control" />
>>>      </div>
>>>    </div>
>>>
>>>    <div class="btn-toolbar">
>>>      <div class="btn-group">
>>>        <input class="btn btn-primary" type="submit" value="Create  
>>> Account" />
>>>      </div>
>>>    </div>
>>> </t:form>
>>>
>>> Well, it looks like that a 'translate' property of the password  
>>> repeater field is missing. But I have no idea why.
>>>
>>> Thanks in advance
>>> Matthias
>>>
>>> ps.
>>> It's a bit confusing when using @Component or @InjectComponent, also  
>>> its confusing when to add a "value" attribute to the t:* object an  
>>> when not. Maybe i will figure this out in future :)
>>>
>>> On 11/06/13 23:00, Thiago H de Paula Figueiredo wrote:
>>>> On Wed, 06 Nov 2013 18:21:04 -0200, thegreatmewel  
>>>> <th...@gmail.com> wrote:
>>>>
>>>>> Hi Thiago, im overwhelmed, it works like a charm :). I just had to  
>>>>> add 'class="form-horizontal"' to my form. Thanks a lot!
>>>>
>>>> Are you using 5.4-alpha-24? Nice to know someone is using one of my  
>>>> rare (so far!) commits and it's working as it should. :)
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>


-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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


Re: POJO's in Forms

Posted by thegreatmewel <th...@gmail.com>.
I'm not sure what do you mean with a getter for passwordRequest? I have 
a passwordRepeat field and a getter getPasswordRepeat(). I thought that 
is enough.

On 11/07/13 20:35, Thiago H de Paula Figueiredo wrote:
> Aren't you missing a getter for passwordRequest?
>
> On Thu, 07 Nov 2013 17:27:52 -0200, thegreatmewel 
> <th...@gmail.com> wrote:
>
>> Yep, im using 5.4-alpha-24 and with bootstrap it looks a lot nicer. 
>> Now I have a strange problem with my password repeat field. I always 
>> get the error:
>> org.apache.tapestry5.ioc.internal.OperationException
>> Render queue error in BeginRender[user/Register:passwordrepeat]: 
>> Parameter 'translate' of component user/Register:passwordrepeat is 
>> bound to null. This parameter is not allowed to be null.
>>
>> [controller snippet]
>>      @InjectComponent
>>      private PasswordField passwordRepeat;
>>
>>      @Component
>>      private Form registerAccount;
>>
>>      public PasswordField getPasswordRepeat() {
>>          return passwordRepeat;
>>      }
>>
>>      void onValidateFromRegisterAccount() {
>>          if (!user.password.equals(passwordRepeat)) {
>>              registerAccount.recordError(passwordRepeat, "Please 
>> enter the same password in both password fields.");
>>          }
>>      }
>> [/controller snippet]
>>
>> and my tml:
>>
>> <t:form class="form-horizontal" t:id="registerAccount">
>>    <t:errors />
>>
>>    <t:beaneditor object="user" 
>> reorder="firstName,lastName,email,phoneNumber,password">
>>      <p:password>
>>        <div class="form-group">
>>          <t:label for="password" class="col-sm-2 control-label" />
>>          <div class="col-sm-6">
>>            <t:passwordfield t:id="password" value="user.password"
>>              class="form-control" />
>>          </div>
>>        </div>
>>      </p:password>
>>    </t:beaneditor>
>>
>>    <div class="form-group">
>>      <t:label for="passwordRepeat" class="col-sm-2 control-label" />
>>      <div class="col-sm-6">
>>        <t:passwordfield t:id="passwordRepeat" class="form-control" />
>>      </div>
>>    </div>
>>
>>    <div class="btn-toolbar">
>>      <div class="btn-group">
>>        <input class="btn btn-primary" type="submit" value="Create 
>> Account" />
>>      </div>
>>    </div>
>> </t:form>
>>
>> Well, it looks like that a 'translate' property of the password 
>> repeater field is missing. But I have no idea why.
>>
>> Thanks in advance
>> Matthias
>>
>> ps.
>> It's a bit confusing when using @Component or @InjectComponent, also 
>> its confusing when to add a "value" attribute to the t:* object an 
>> when not. Maybe i will figure this out in future :)
>>
>> On 11/06/13 23:00, Thiago H de Paula Figueiredo wrote:
>>> On Wed, 06 Nov 2013 18:21:04 -0200, thegreatmewel 
>>> <th...@gmail.com> wrote:
>>>
>>>> Hi Thiago, im overwhelmed, it works like a charm :). I just had to 
>>>> add 'class="form-horizontal"' to my form. Thanks a lot!
>>>
>>> Are you using 5.4-alpha-24? Nice to know someone is using one of my 
>>> rare (so far!) commits and it's working as it should. :)
>>>
>>
>>
>> ---------------------------------------------------------------------
>> 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


Re: POJO's in Forms

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
Aren't you missing a getter for passwordRequest?

On Thu, 07 Nov 2013 17:27:52 -0200, thegreatmewel  
<th...@gmail.com> wrote:

> Yep, im using 5.4-alpha-24 and with bootstrap it looks a lot nicer. Now  
> I have a strange problem with my password repeat field. I always get the  
> error:
> org.apache.tapestry5.ioc.internal.OperationException
> Render queue error in BeginRender[user/Register:passwordrepeat]:  
> Parameter 'translate' of component user/Register:passwordrepeat is bound  
> to null. This parameter is not allowed to be null.
>
> [controller snippet]
>      @InjectComponent
>      private PasswordField passwordRepeat;
>
>      @Component
>      private Form registerAccount;
>
>      public PasswordField getPasswordRepeat() {
>          return passwordRepeat;
>      }
>
>      void onValidateFromRegisterAccount() {
>          if (!user.password.equals(passwordRepeat)) {
>              registerAccount.recordError(passwordRepeat, "Please enter  
> the same password in both password fields.");
>          }
>      }
> [/controller snippet]
>
> and my tml:
>
> <t:form class="form-horizontal" t:id="registerAccount">
>    <t:errors />
>
>    <t:beaneditor object="user"  
> reorder="firstName,lastName,email,phoneNumber,password">
>      <p:password>
>        <div class="form-group">
>          <t:label for="password" class="col-sm-2 control-label" />
>          <div class="col-sm-6">
>            <t:passwordfield t:id="password" value="user.password"
>              class="form-control" />
>          </div>
>        </div>
>      </p:password>
>    </t:beaneditor>
>
>    <div class="form-group">
>      <t:label for="passwordRepeat" class="col-sm-2 control-label" />
>      <div class="col-sm-6">
>        <t:passwordfield t:id="passwordRepeat" class="form-control" />
>      </div>
>    </div>
>
>    <div class="btn-toolbar">
>      <div class="btn-group">
>        <input class="btn btn-primary" type="submit" value="Create  
> Account" />
>      </div>
>    </div>
> </t:form>
>
> Well, it looks like that a 'translate' property of the password repeater  
> field is missing. But I have no idea why.
>
> Thanks in advance
> Matthias
>
> ps.
> It's a bit confusing when using @Component or @InjectComponent, also its  
> confusing when to add a "value" attribute to the t:* object an when not.  
> Maybe i will figure this out in future :)
>
> On 11/06/13 23:00, Thiago H de Paula Figueiredo wrote:
>> On Wed, 06 Nov 2013 18:21:04 -0200, thegreatmewel  
>> <th...@gmail.com> wrote:
>>
>>> Hi Thiago, im overwhelmed, it works like a charm :). I just had to add  
>>> 'class="form-horizontal"' to my form. Thanks a lot!
>>
>> Are you using 5.4-alpha-24? Nice to know someone is using one of my  
>> rare (so far!) commits and it's working as it should. :)
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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


Re: POJO's in Forms

Posted by thegreatmewel <th...@gmail.com>.
Yep, im using 5.4-alpha-24 and with bootstrap it looks a lot nicer. Now 
I have a strange problem with my password repeat field. I always get the 
error:
org.apache.tapestry5.ioc.internal.OperationException
Render queue error in BeginRender[user/Register:passwordrepeat]: 
Parameter 'translate' of component user/Register:passwordrepeat is bound 
to null. This parameter is not allowed to be null.

[controller snippet]
     @InjectComponent
     private PasswordField passwordRepeat;

     @Component
     private Form registerAccount;

     public PasswordField getPasswordRepeat() {
         return passwordRepeat;
     }

     void onValidateFromRegisterAccount() {
         if (!user.password.equals(passwordRepeat)) {
             registerAccount.recordError(passwordRepeat, "Please enter 
the same password in both password fields.");
         }
     }
[/controller snippet]

and my tml:

<t:form class="form-horizontal" t:id="registerAccount">
   <t:errors />

   <t:beaneditor object="user" 
reorder="firstName,lastName,email,phoneNumber,password">
     <p:password>
       <div class="form-group">
         <t:label for="password" class="col-sm-2 control-label" />
         <div class="col-sm-6">
           <t:passwordfield t:id="password" value="user.password"
             class="form-control" />
         </div>
       </div>
     </p:password>
   </t:beaneditor>

   <div class="form-group">
     <t:label for="passwordRepeat" class="col-sm-2 control-label" />
     <div class="col-sm-6">
       <t:passwordfield t:id="passwordRepeat" class="form-control" />
     </div>
   </div>

   <div class="btn-toolbar">
     <div class="btn-group">
       <input class="btn btn-primary" type="submit" value="Create 
Account" />
     </div>
   </div>
</t:form>

Well, it looks like that a 'translate' property of the password repeater 
field is missing. But I have no idea why.

Thanks in advance
Matthias

ps.
It's a bit confusing when using @Component or @InjectComponent, also its 
confusing when to add a "value" attribute to the t:* object an when not. 
Maybe i will figure this out in future :)

On 11/06/13 23:00, Thiago H de Paula Figueiredo wrote:
> On Wed, 06 Nov 2013 18:21:04 -0200, thegreatmewel 
> <th...@gmail.com> wrote:
>
>> Hi Thiago, im overwhelmed, it works like a charm :). I just had to 
>> add 'class="form-horizontal"' to my form. Thanks a lot!
>
> Are you using 5.4-alpha-24? Nice to know someone is using one of my 
> rare (so far!) commits and it's working as it should. :)
>


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


Re: POJO's in Forms

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 06 Nov 2013 18:21:04 -0200, thegreatmewel  
<th...@gmail.com> wrote:

> Hi Thiago, im overwhelmed, it works like a charm :). I just had to add  
> 'class="form-horizontal"' to my form. Thanks a lot!

Are you using 5.4-alpha-24? Nice to know someone is using one of my rare  
(so far!) commits and it's working as it should. :)

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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


Re: POJO's in Forms

Posted by thegreatmewel <th...@gmail.com>.
Hi Thiago, im overwhelmed, it works like a charm :). I just had to add 
'class="form-horizontal"' to my form. Thanks a lot!

On 11/06/13 13:26, Thiago H de Paula Figueiredo wrote:
> On Wed, 06 Nov 2013 09:36:58 -0200, Thiago H de Paula Figueiredo 
> <th...@gmail.com> wrote:
>
>> Since 5.4-alpha-24 you can actually have BeanEditForm and BeanEditor 
>> generate the HTML you want through setting some configuration 
>> symbols. I just didn't documented it yet. Later today I'll post an 
>> example. 5.4-alpha-24 also uses Bootstrap 3.0.1 by default.
>
> Using your own desired generated HTML as example and Tapestry 
> 5.4-alpha-24, here it goes:
>
> In your AppModule:
>
> public static void 
> contributeApplicationDefaults(MappedConfiguration<String, String> 
> configuration) {
>     configuration.add(SymbolConstants.FORM_GROUP_LABEL_CSS_CLASS, 
> "col-sm-2 control-label");
>     configuration.add(SymbolConstants.FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_NAME, 
> "div");
>     configuration.add(SymbolConstants.FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_CSS_CLASS, 
> "col-sm-6",
> }
>
> In your example, SymbolConstants.FORM_GROUP_WRAPPER_CSS_CLASS and 
> SymbolConstants.FORM_FIELD_CSS_CLASS do not need to be set because 
> their defaults match what you want.
>
> Now you can just use BeanEditForm and BeanEditor with your POJO and 
> have the fields and labels and divs generated exactly the way you 
> want. ;)
>


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


Re: POJO's in Forms

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 06 Nov 2013 09:36:58 -0200, Thiago H de Paula Figueiredo  
<th...@gmail.com> wrote:

> Since 5.4-alpha-24 you can actually have BeanEditForm and BeanEditor  
> generate the HTML you want through setting some configuration symbols. I  
> just didn't documented it yet. Later today I'll post an example.  
> 5.4-alpha-24 also uses Bootstrap 3.0.1 by default.

Using your own desired generated HTML as example and Tapestry  
5.4-alpha-24, here it goes:

In your AppModule:

public static void  
contributeApplicationDefaults(MappedConfiguration<String, String>  
configuration) {
	configuration.add(SymbolConstants.FORM_GROUP_LABEL_CSS_CLASS, "col-sm-2  
control-label");
	configuration.add(SymbolConstants.FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_NAME,  
"div");
	configuration.add(SymbolConstants.FORM_GROUP_FORM_FIELD_WRAPPER_ELEMENT_CSS_CLASS,  
"col-sm-6",
}

In your example, SymbolConstants.FORM_GROUP_WRAPPER_CSS_CLASS and  
SymbolConstants.FORM_FIELD_CSS_CLASS do not need to be set because their  
defaults match what you want.

Now you can just use BeanEditForm and BeanEditor with your POJO and have  
the fields and labels and divs generated exactly the way you want. ;)

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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


Re: POJO's in Forms

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
Hi, The Greate Mewel! :)

On Wed, 06 Nov 2013 08:53:48 -0200, thegreatmewel  
<th...@gmail.com> wrote:

> // and my form
> <html t:type="layout" title="Create Account"
>    xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd">
>
> <form t:type="form" t:id="registerForm" class="form-horizontal"
>    role="form">
>
>    <div class="form-group">
>      <t:label for="firstName" class="col-sm-2 control-label" />
>      <div class="col-sm-6">
>        <input t:type="TextField" t:id="user.firstName"  
> t:validate="required"
>          class="form-control" />
>      </div>
>    </div>
>    <input type="submit" value="Create" />
> </form>
>
> </html>
>
> As you see i liked to use bootstrap and some extra html markup in my  
> form. So the default beaneditform isn't what i wanted here (its working  
> by the way).

Since 5.4-alpha-24 you can actually have BeanEditForm and BeanEditor  
generate the HTML you want through setting some configuration symbols. I  
just didn't documented it yet. Later today I'll post an example.  
5.4-alpha-24 also uses Bootstrap 3.0.1 by default.

> My questions:
> 1. I got an error for using "user.firstName" in t:id.

'value' is the parameter you want to pass user.firstName. 't:id' is the  
component id. So it should be
<input t:type="TextField" t:id="firstName" value="user.firstName"  
t:validate="required" class="form-control" />

> 2. If I use "firstName" instead of "user.firstName" and hit the submit  
> button, nothing happens. The onSuccess method is not called and I don't  
> get any log message in my console.

onSuccess() isn't called when validation fails. Use the Errors component  
inside the form to show the errors.

> 3. When is tapestry 5.4 released (a week, a month or a year). I like to  
> use jquery instead of prototype. The Tapestry5-jQuery works, but it uses  
> an old jquery version.

You can use 5.4-alpha-24 now, which already packs jQuery, and a newer  
version of it, so you don't need to use tapestry5-jquery. It's an alpha,  
ok, but it works very, very well.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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