spsarolkar wrote:
public void prepare(){
if(emailId==null){
this.user=new User();
}
else{
this.user=userService.findByEmail(emailId);
}
}
So if emailId is null you construct a new one, but if it is not null and
findByEmail() fails, it is still null.
java.lang.IllegalArgumentException: attempt to create create event with null
entity
When i tried to debug it I am getting user object in prepare() function i.e.
user is not null but when i check the same value in update method it comes
out to be null
<s:hidden name="emailId" />
<s:if test="email==null">
<s:submit value="Register" />
</s:if>
This generates <input type="hidden" name="emailId" value=""/>, right?
So it'll submit a parameter &emailId=, which will result in emailId not
being null, but rather being the empty string. The prepare lookup
fails, so user is still null.
Try these two fixes:
> <s:if test="%{email == null}">
> <s:submit value="Register" />
> </s:if>
> <s:else>
> <s:hidden name="emailId" />
> <s:submit value="Update" />
> </s:else>
> public void prepare() {
> if (emailId != null) {
> this.user=userService.findByEmail(emailId);
> }
> if (this.user == null) {
> this.user = new User();
> }
> }
-Dale
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org