How to get IP for SessionScoped Bean?
Hi,
I have a user bean that looks like this (simplified).
Code:
@Named
@SessionScoped
public class User implements Serializable {
final String IP_ADDR = "1.2.3.4";
}
Now I'm stuck and don't know how to initialize the field. Of course, ID_ADDR doesn't have to be a string. Is there any standard-way for doing this in JSF-servlets? Any help is greatly appreciated!
Re: How to get IP for SessionScoped Bean?
What i find weird is you made it a "constant" final, which can only be initialised at bean loading instance.
Of the initializing, you could write the field into the backing beans faces-config.xml declaration tag with its data type and value.
If you didn't make it final you could set it with a public void set bean method.