Note that there are some explanatory texts on larger screens.

plurals
  1. POBean 'getters' not returning a value
    primarykey
    data
    text
    <p>I'm doing a little project in Netbeans using Glassfish for a course I'm doing on Java EE. I'm having a problem where my 'getter' methods for the Bean are returning a null value and therefore nothing gets submitted to the database. The front-end to the project is a JSF page, which could be part of the problem. My suspicion it it's the bean, the JSF page or my configuration (of what? I don't know!) that is the problem</p> <p>I'm very new to this topic so please forgive my lack of jargon and naivety on the subject!</p> <p>Our course instructor has upload a project which is similar to what we need to create so we're all using that as a guide. His works perfectly whereas mine, which to me is identical, doesn't.</p> <p>I can't post any extensive code, in order to comply with our institution's regulations but I can post a few snippets. If there's something specific that needs to be posted up, I'll do my best.</p> <p>Bean: </p> <pre><code>@Named(value="secure") @SessionScoped public class Post implements Serializable { private String post; private String recipient; @EJB private PostLocal posts; //local interface public Post() { } public String getRecipient() { return recipient; } public void setRecipient(String recipient) { this.recipient= recipient; } public List&lt;Post&gt; getPosts() { return posts.getAllPosts(); } public String getPost() { return post; } public void setPost(String post) { this.post = post; } public String submit() { Post p = new Post(); byte[] encryptedMsg = p.encrypt(getPost(), "password"); //the post is encrypted, that's why it's stored as a byte array. getMessage returns null.. p.setRecipient(getRecipient()); //getRecipient returns null p.setMessage(encryptedMsg); posts.add(s); return "index"; } </code></pre> <p>JSF page:</p> <pre><code>&lt;?xml version='1.0' encoding='UTF-8' ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"&gt; &lt;h:head&gt; &lt;title&gt;Project&lt;/title&gt; &lt;/h:head&gt; &lt;h:body&gt; &lt;h:form&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt; Recipient: &lt;/td&gt; &lt;td&gt; &lt;h:inputText value="#{secure.recipient}"/&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Enter a message to post here: &lt;/td&gt; &lt;td&gt; &lt;h:inputText value="#{secure.post}"&gt;&lt;/h:inputText&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;h:commandButton action="#{secure.submit}" value="Submit" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;h:dataTable value="#{secure.posts}" var="thePosts"&gt; &lt;h:column&gt; &lt;f:facet name="header"&gt;Name&lt;/f:facet&gt; #{thePosts.recipient} &lt;/h:column&gt; &lt;h:column&gt; &lt;f:facet name="header"&gt;Comment&lt;/f:facet&gt; #{thePosts.post} &lt;/h:column&gt; &lt;/h:dataTable&gt; &lt;/h:form&gt; &lt;/h:body&gt; </code></pre> <p></p> <p>Any questions, then please by all means ask! I'm completely stuck with this (and have been for the past 24 hours) so any help is greatly appreciated!</p> <p>Many thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload