As long as you really know what you're doing, there's no issue in
using primitives.
At issue is that the ApplicationStateManager only understands class
types, not names.
So, if you had something like:
@ApplicationState
String userName;
@ApplicationState
String someOtherString;
userName and someOtherString are going to wind up with the same value,
on any page where they are.
Any string marked with @ApplicationState is the same as any other
string marked with @ApplicationState.
Hence, it's /normally/ better to @ApplicationState a bean with string
properties, rather than a string.
Robert
On Mar 18, 2008, at 3/188:06 AM , Baptiste Meurant wrote:
Hi
Thanks to everybody.
I have contributed an ApplicationStateObject for String in AppModule
and it
is working well now.
code below :
public void contributeApplicationStateManager(
MappedConfiguration<Class, ApplicationStateContribution>
configuration) {
ApplicationStateCreator<String> creator = new
ApplicationStateCreator<String>() {
public String create() {
return new String();
}
};
configuration.add(String.class, new
ApplicationStateContribution("session", creator));
}
I have still few questions :
you should not use String for ApplicationsStateObjects nor other
primitive types at all -> Why ? I understand that a custom complete
bean is
more usefull in many case but it could be sometime usefull to
persist in
Application scope a Primitive type object. If we have only one
information
to share in application scope in a single bean ... I don't see why it
could'nt be possible ...
Anyway, thanks for everything.
Baptiste
kristian.marinkovic wrote:
AFAIK you should not use String for ApplicationsStateObjects nor
other
primitive types at all .. only complex types with a no arg
constructor.
if you must use a different constructor you have to contribute to the
ApplicationStateManager to tell the service how to create the
instances
properly
g,
kris
Baptiste Meurant <[EMAIL PROTECTED]>
18.03.2008 12:18
Bitte antworten an
"Tapestry users" <users@tapestry.apache.org>
An
users@tapestry.apache.org
Kopie
Thema
Re: ApplicationState annotation problem since 5.0.11
Hi
Thank you for your quick answer.
If I understand well, I have to create a custom
ApplicationStateContribution
to handle ApplicationState on String class ? Do you have some tips or
instructions to do this ?
I will try and tell you the result.
I am just surprised that this configurations was working well before
5.0.11
version ...
Thanks,
Regards,
Alec Leamas-2 wrote:
Hi!
What are you really trying to do here? For me, this looks like a
typo.
Have you contributed an ApplicationStateObject? Then you need to
refer
to this. I'm pretty sure Tapestry doen't have a String
ApplicationState
object in place...
I would expect something like
@ApplicationState
private MyClass myInstance;
Where MyClass is contributed to ApplicationStateManager in
AppModule.java.
Hope this helps..
--alec
Baptiste Meurant wrote:
Hello,
I am currently upgrading my Tapestry version from 5.0.6 to 5.0.11
and I
have
a problem with @ApplicationState annotation.
Here are my files:
Login.tml :
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns:t="http://tapestry.apache.org/schema/
tapestry_5_0_0.xsd">
<head>
<title>Login</title>
</head>
<body>
<div id="login_box">
<t:form>
<t:errors />
<table>
<tr>
<td><label
t:type="Label" for="login" class="login_label"/></td>
<td><input
t:type="TextField" t:id="login" t:value="login"
t:label="login "
class="login_input" /></td>
</tr>
<tr>
<td><label
t:type="Label" for="password"
class="login_label"/></td>
<td><input t:type="PasswordField" t:id="password"
t:value="password"
t:label="password "
class="login_input" /></td>
</tr>
<tr>
<td><input
t:id="submitform" t:type="Submit" t:value="submit"
class="login_submit"/></td>
</tr>
</table>
</t:form>
</div>
</body>
</html>
Login.java :
package tutos.web.pages;
import org.apache.tapestry.annotations.ApplicationState;
import org.apache.tapestry.beaneditor.Validate;
public class Login {
@ApplicationState
private String login;
private String password;
public String getLogin() {
return login;
}
@Validate("required")
public void setLogin(String login) {
this.login = login;
}
public String getPassword() {
return password;
}
@Validate("required")
public void setPassword(String password) {
this.password = password;
}
String onSuccess() {
//my business coder
String ret = "Home";
return ret;
}
}
I get the error - no exception in stacktrace :
Render queue error in BeginRender[Login:login]: Failure reading
parameter
'value' of component Login:login: Error invoking constructor
java.lang.String(byte[], int, int, int) (at null:-1) (for service
'ApplicationStateManager'): No service implements the interface [B.
When I delete @ApplicationState annotation, everything works.
I have made some tests on different Tapestry versions and it
seems that
@ApplicationState is correctly working until 5.0.10. I get the
exception
on
5.0.11 and 5.0.12-SNAPSHOT.
Is it a bug or @ApplicationState implementation has changed since
5.0.11
?
In this case can someone give me the correct configuration ?
Thanks, regards,
Baptiste Meurant
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
View this message in context:
http://www.nabble.com/ApplicationState-annotation-problem-since-5.0.11-tp16118051p16118858.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
View this message in context:
http://www.nabble.com/ApplicationState-annotation-problem-since-5.0.11-tp16118051p16120801.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]