You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Michael Schmidt <cs...@googlemail.com> on 2012/05/21 11:07:55 UTC
Beaneditform looses data of non visual fields.
Hi all,
I'm trying to use the BeanEditForm for editing the data of a object and
persist it using hibernate.
Here are some code snippets:
Page Class:
public class AdministrationGroupsEdit
{
@Inject
Session session;
@InjectPage
AdministrationGroups redirectPage;
private Integer groupId;
@Property
private Group group;
void onActivate(Integer personId)
{
this.groupId = personId;
}
void setupRender()
{
this.group = (Group) this.session.createQuery("from Group where
id= :p_id")
.setInteger("p_id", this.groupId)
.uniqueResult();
}
@CommitAfter
void onValidateFromGroupForm()
{
this.session.merge(this.group);
}
AdministrationGroups onSuccess()
{
return this.redirectPage;
}
}
My Page itself looks like this:
...
<t:beaneditform t:id="groupForm" object="group"
submitLabel="Save">
[BeanEditForm here]
</t:beaneditform>
...
And here is my mode:
@Entity
@Table(name = "group", schema = "public")
public class Group implements java.io.Serializable
{
private int id;
private String guid;
private String name;
public Group()
{
}
@Id
@NonVisual
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public int getId()
{
return this.id;
}
public void setId(int groupId)
{
this.id = groupId;
}
@Column(name = "name")
public String getName()
{
return this.name;
}
public void setName(String name)
{
this.name = name;
}
@Column(name = "guid")
@NonVisual
public String getGuid()
{
return this.guid;
}
public void setGuid(String guid)
{
this.guid = guid;
}
...
}
So you can see i marked the guid and id property as @NonVisual which
seems not to work. The property is not displayed in the beaneditform but
also the value is lost when onSuccess() or onValidateFromGroupForm() is
called. I expected non visual properties to be stored in hidden fields
or something like this!? This seems to be not the default behavoir
because the documentation says: @NonVisual could be used for id
fields... but in my application the values are lost...
Am I missing something?
Btw: Is there a better way than using the @NonVisual annotation cause i
dont't want to put this in my property.
Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Beaneditform looses data of non visual fields.
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Mon, 21 May 2012 06:07:55 -0300, Michael Schmidt
<cs...@googlemail.com> wrote:
> Hi all,
Hi!
> I'm trying to use the BeanEditForm for editing the data of a object and
> persist it using hibernate.
You either @Persist the object or use BeanEditor (which is the base of
BeanEditForm) and use the Hidden component for the non-editable ones.
> I expected non visual properties to be stored in hidden fields or
> something like this!?
Nope, they're ignored.
> Btw: Is there a better way than using the @NonVisual annotation cause i
> dont't want to put this in my property.
Use the exclude parameter of BeanEditForm or BeanEditor.
--
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