You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by felipexz <fe...@gmail.com> on 2012/01/02 21:11:52 UTC
Beaneditor bug null property error
Hi people, good evening. I'm trying to develop an application using
Beaneditor like the Tapestry tutorial but when I try to persist is in my
create java page my entity that I @Inject is comming null.
I tryed at first with eclipselink and now with hibernate using Session I got
same problem. Would it be a bug in the Beaneditor ? I didn't tryed in early
versions.. Im in 5.3.1
Tapestry 5.3 does support Hibernate 4.0 ?
Thank you
Best regards
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Beaneditor-bug-null-property-error-tp5115312p5115312.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: Beaneditor bug null property error
Posted by felipexz <fe...@gmail.com>.
I'm sorry but my questions are not cleary ?
Best regards
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Beaneditor-sending-null-object-tp5115312p5117279.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: Beaneditor bug null property error
Posted by felipexz <fe...@gmail.com>.
Yes of course I agree. But when you have Annotated fields, it can be
instatiated in other classes, can't be ?
How I would know that it's not already been instatiated ? That's an
annotated field.
I'm justing asking.. as I said I'm a newbie.
Best regards
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Beaneditor-sending-null-object-tp5115312p5117630.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: Beaneditor bug null property error
Posted by Sven Homburg <ho...@googlemail.com>.
The prefered convention in java : instantiate an class before work with it.
the documentation advise you only, where it make sense to do this job ;-)
with regards
Sven Homburg
Founder of the Chenille Kit Project
http://chenillekit.codehaus.org
2012/1/3 felipexz <fe...@gmail.com>:
> Hi Sven.. I read it but the method on"Something" is a convention ?
> Sorry but I'm new on Tapestry so I don't know.
>
> I only found about the "onPrepare" in the wiki
> http://wiki.apache.org/tapestry/Tapestry5HowToUseForms
>
> So I think if its a convention ok, right. But if not I think it should be in
> the documentation.
>
> Best regards
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Beaneditor-sending-null-object-tp5115312p5117551.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
Re: Beaneditor bug null property error
Posted by felipexz <fe...@gmail.com>.
Hi Sven.. I read it but the method on"Something" is a convention ?
Sorry but I'm new on Tapestry so I don't know.
I only found about the "onPrepare" in the wiki
http://wiki.apache.org/tapestry/Tapestry5HowToUseForms
So I think if its a convention ok, right. But if not I think it should be in
the documentation.
Best regards
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Beaneditor-sending-null-object-tp5115312p5117551.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: Beaneditor bug null property error
Posted by Sven Homburg <ho...@googlemail.com>.
have a look at this page
http://tapestry.apache.org/forms-and-validation.html
""When rendering, the Form component emits two notifications: first,
"prepareForRender", then "prepare". These allow the Form's container
to setup any fields or properties that will be referenced in the form.
For example, this is a good place to create a temporary entity object
to be rendered, or to load an entity from a database to be edited.""
with regards
Sven Homburg
Founder of the Chenille Kit Project
http://chenillekit.codehaus.org
2012/1/3 felipexz <fe...@gmail.com>:
> Hi, now its working but I think you should add this "hint" in the
> documentantion and at the Tutorial.
> I know we need to initialize the class but where was my problem.
>
> The working code is:
>
> public class CreateMunicipio
> {
>
> @Property
> @Persist
> private Municipio municipio;
>
> @Inject
> private Session session;
>
> void onPrepare() throws Exception {
> municipio = new Municipio();
> }
>
> @CommitAfter
> Object onSuccess()
> {
> session.merge(municipio);
> return "";
> }
>
> }
>
> Now it works. Could you add this onPrepare() in the Tutorial please ? Maybe
> more people can have the same question.
>
> Best regards
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Beaneditor-sending-null-object-tp5115312p5117493.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
Re: Beaneditor bug null property error
Posted by felipexz <fe...@gmail.com>.
Hi, now its working but I think you should add this "hint" in the
documentantion and at the Tutorial.
I know we need to initialize the class but where was my problem.
The working code is:
public class CreateMunicipio
{
@Property
@Persist
private Municipio municipio;
@Inject
private Session session;
void onPrepare() throws Exception {
municipio = new Municipio();
}
@CommitAfter
Object onSuccess()
{
session.merge(municipio);
return "";
}
}
Now it works. Could you add this onPrepare() in the Tutorial please ? Maybe
more people can have the same question.
Best regards
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Beaneditor-sending-null-object-tp5115312p5117493.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: Beaneditor bug null property error
Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
I Don't see you initializing the municipio variable anywhere in your code. You need something like setupRender and initialize it via new if it is null.
On Jan 3, 2012, at 12:14 PM, felipexz <fe...@gmail.com> wrote:
> I'm using Tomcat 7 and java 1.7.. its a problem ?
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Beaneditor-sending-null-object-tp5115312p5117434.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
Re: Beaneditor bug null property error
Posted by felipexz <fe...@gmail.com>.
I'm using Tomcat 7 and java 1.7.. its a problem ?
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Beaneditor-sending-null-object-tp5115312p5117434.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: Beaneditor bug null property error
Posted by felipexz <fe...@gmail.com>.
Hi, I think the problem is not about Persistence... the problem is municipio
is coming null.
Anyway I tryed with session.merge.. anyway it says idMunicipio cannot be
null.
Best regards
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Beaneditor-sending-null-object-tp5115312p5117425.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: Beaneditor bug null property error
Posted by felipexz <fe...@gmail.com>.
I tryed.. after the beaneditor submit it should persist my object.. but it
comes null.
And I get this error:
Caused by: org.hibernate.PersistentObjectException: detached entity passed
to persist: com.icms.feam.entities.Municipio
Best regards
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Beaneditor-sending-null-object-tp5115312p5117350.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: Beaneditor bug null property error
Posted by felipexz <fe...@gmail.com>.
Hi, thank you Thiago.. the code is this:
public class CreateMunicipio
{
@Property
private Municipio municipio;
@Inject
private Session session;
@CommitAfter
Object onSuccess()
{
session.persist(municipio);
return "";
}
}
This is the CreateMunicipio.tml
<html t:type="login" title="ICMSPrev Index"
t:sidebarTitle="Framework Version"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd">
<t:beaneditform object="municipio"/>
</html>
This is my entity:
@Entity
public class Municipio {
//private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int idMunicipio;
private String bairro;
private String cep;
private String cnpj;
private String complemento;
private String email;
@Temporal( TemporalType.DATE)
private Date mandatoAte;
private String nomePref;
private String numero;
private String rua;
private String senha;
public int getIdMunicipio() {
return this.idMunicipio;
}
public void setIdMunicipio(int idMunicipio) {
this.idMunicipio = idMunicipio;
}
public String getBairro() {
return this.bairro;
}
public void setBairro(String bairro) {
this.bairro = bairro;
}
public String getCep() {
return this.cep;
}
public void setCep(String cep) {
this.cep = cep;
}
public String getCnpj() {
return this.cnpj;
}
public void setCnpj(String cnpj) {
this.cnpj = cnpj;
}
public String getComplemento() {
return this.complemento;
}
public void setComplemento(String complemento) {
this.complemento = complemento;
}
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
public Date getMandatoAte() {
return this.mandatoAte;
}
public void setMandatoAte(Date mandatoAte) {
this.mandatoAte = mandatoAte;
}
public String getNomePref() {
return this.nomePref;
}
public void setNomePref(String nomePref) {
this.nomePref = nomePref;
}
public String getNumero() {
return this.numero;
}
public void setNumero(String numero) {
this.numero = numero;
}
public String getRua() {
return this.rua;
}
public void setRua(String rua) {
this.rua = rua;
}
public String getSenha() {
return this.senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
}
When I try to run it.. my object municipio is null in CreateMunicipio.class
why ? I'm filling it in my beaneditor page.
Best regards
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Beaneditor-sending-null-object-tp5115312p5117326.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: Beaneditor bug null property error
Posted by Howard Lewis Ship <hl...@gmail.com>.
http://catb.org/esr/faqs/smart-questions.html
On Mon, Jan 2, 2012 at 12:11 PM, felipexz <fe...@gmail.com> wrote:
> Hi people, good evening. I'm trying to develop an application using
> Beaneditor like the Tapestry tutorial but when I try to persist is in my
> create java page my entity that I @Inject is comming null.
>
> I tryed at first with eclipselink and now with hibernate using Session I got
> same problem. Would it be a bug in the Beaneditor ? I didn't tryed in early
> versions.. Im in 5.3.1
>
> Tapestry 5.3 does support Hibernate 4.0 ?
>
> Thank you
> Best regards
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Beaneditor-bug-null-property-error-tp5115312p5115312.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
>
--
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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org