You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Rahman USTA <ra...@gmail.com> on 2012/01/04 10:44:58 UTC

It is not a good idea to reference the Session instance in models directly as it may lead to serialization problems.

Hi, i have a MySession.

form.add(new TextField("name",new PropertyModel(((MySession)getSession()),"
user.name")));

I have a User user; in MySession, then initialized in constructor.

my Goal is to save name and surname user's own session. i did it above, but
warning ide me so that ;

*WARN  - AbstractPropertyModel      - It is not a good idea to reference
the Session instance in models directly as it may lead to serialization
problems. If you need to access a property of the session via the model use
the page instance as the model object and 'session.attribute' as the path.*

How can i handle this normally.




-- 
Rahman USTA
Computer & Control Education Technologist
0-(531)-922-28-05
www.kodcu.com

Re: It is not a good idea to reference the Session instance in models directly as it may lead to serialization problems.

Posted by Sven Meier <sv...@meiers.net>.
Just translate the warning into code:

   form.add(new TextField("name",new PropertyModel(this, "session.user.name")));

Sven


Am 04.01.2012 10:44, schrieb Rahman USTA:
> Hi, i have a MySession.
>
> form.add(new TextField("name",new PropertyModel(((MySession)getSession()),"
> user.name")));
>
> I have a User user; in MySession, then initialized in constructor.
>
> my Goal is to save name and surname user's own session. i did it above, but
> warning ide me so that ;
>
> *WARN  - AbstractPropertyModel      - It is not a good idea to reference
> the Session instance in models directly as it may lead to serialization
> problems. If you need to access a property of the session via the model use
> the page instance as the model object and 'session.attribute' as the path.*
>
> How can i handle this normally.
>
>
>
>


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


Re: It is not a good idea to reference the Session instance in models directly as it may lead to serialization problems.

Posted by Rahman USTA <ra...@gmail.com>.
Sorry not second, first.

2012/1/4 Rahman USTA <ra...@gmail.com>

> Second answer is ok, very thanks.
>
>
> 2012/1/4 Wilhelmsen Tor Iver <To...@arrive.no>
>
>> // Indirection for PropertyModel object
>> public class MySessionModel extends AbstractReadOnlyModel<MySession> {
>>
>>        public MySession getObject() {
>>                return (MySession) Session.get();
>>        }
>> }
>>
>> - Tor Iver
>>
>> -----Original Message-----
>> From: Rahman USTA [mailto:rahman.usta.88@gmail.com]
>> Sent: 4. januar 2012 10:45
>> To: users@wicket.apache.org
>> Subject: It is not a good idea to reference the Session instance in
>> models directly as it may lead to serialization problems.
>>
>> Hi, i have a MySession.
>>
>> form.add(new TextField("name",new
>> PropertyModel(((MySession)getSession()),"
>> user.name")));
>>
>> I have a User user; in MySession, then initialized in constructor.
>>
>> my Goal is to save name and surname user's own session. i did it above,
>> but
>> warning ide me so that ;
>>
>> *WARN  - AbstractPropertyModel      - It is not a good idea to reference
>> the Session instance in models directly as it may lead to serialization
>> problems. If you need to access a property of the session via the model
>> use
>> the page instance as the model object and 'session.attribute' as the
>> path.*
>>
>> How can i handle this normally.
>>
>>
>>
>>
>> --
>> Rahman USTA
>> Computer & Control Education Technologist
>> 0-(531)-922-28-05
>> www.kodcu.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
> --
> Rahman USTA
> Computer & Control Education Technologist
> 0-(531)-922-28-05
> www.kodcu.com
>
>


-- 
Rahman USTA
Computer & Control Education Technologist
0-(531)-922-28-05
www.kodcu.com

Re: It is not a good idea to reference the Session instance in models directly as it may lead to serialization problems.

Posted by Rahman USTA <ra...@gmail.com>.
Second answer is ok, very thanks.

2012/1/4 Wilhelmsen Tor Iver <To...@arrive.no>

> // Indirection for PropertyModel object
> public class MySessionModel extends AbstractReadOnlyModel<MySession> {
>
>        public MySession getObject() {
>                return (MySession) Session.get();
>        }
> }
>
> - Tor Iver
>
> -----Original Message-----
> From: Rahman USTA [mailto:rahman.usta.88@gmail.com]
> Sent: 4. januar 2012 10:45
> To: users@wicket.apache.org
> Subject: It is not a good idea to reference the Session instance in models
> directly as it may lead to serialization problems.
>
> Hi, i have a MySession.
>
> form.add(new TextField("name",new PropertyModel(((MySession)getSession()),"
> user.name")));
>
> I have a User user; in MySession, then initialized in constructor.
>
> my Goal is to save name and surname user's own session. i did it above, but
> warning ide me so that ;
>
> *WARN  - AbstractPropertyModel      - It is not a good idea to reference
> the Session instance in models directly as it may lead to serialization
> problems. If you need to access a property of the session via the model use
> the page instance as the model object and 'session.attribute' as the path.*
>
> How can i handle this normally.
>
>
>
>
> --
> Rahman USTA
> Computer & Control Education Technologist
> 0-(531)-922-28-05
> www.kodcu.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Rahman USTA
Computer & Control Education Technologist
0-(531)-922-28-05
www.kodcu.com

RE: It is not a good idea to reference the Session instance in models directly as it may lead to serialization problems.

Posted by Wilhelmsen Tor Iver <To...@arrive.no>.
// Indirection for PropertyModel object
public class MySessionModel extends AbstractReadOnlyModel<MySession> {

	public MySession getObject() {
		return (MySession) Session.get();
	}
}

- Tor Iver

-----Original Message-----
From: Rahman USTA [mailto:rahman.usta.88@gmail.com] 
Sent: 4. januar 2012 10:45
To: users@wicket.apache.org
Subject: It is not a good idea to reference the Session instance in models directly as it may lead to serialization problems.

Hi, i have a MySession.

form.add(new TextField("name",new PropertyModel(((MySession)getSession()),"
user.name")));

I have a User user; in MySession, then initialized in constructor.

my Goal is to save name and surname user's own session. i did it above, but
warning ide me so that ;

*WARN  - AbstractPropertyModel      - It is not a good idea to reference
the Session instance in models directly as it may lead to serialization
problems. If you need to access a property of the session via the model use
the page instance as the model object and 'session.attribute' as the path.*

How can i handle this normally.




-- 
Rahman USTA
Computer & Control Education Technologist
0-(531)-922-28-05
www.kodcu.com

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