0

このエラーを解決するにはどうすればよいですか?

Target Unreachable,return null
HTTP Status 500 - /gotit.xhtml @34,49 value="#{bean.nbrp.title}": Target Unreachable, 'nbrp' returned null



gotit.xhtml

            <h:head></h:head>
            <body>
                <rich:panel>
                    <f:facet name="header">
                    Actionlistener,Binding,Importing AnotherClasses
                    </f:facet>
                    <h3>Todo List</h3>
                    <f:view>
                        <h:messages layout="table"></h:messages>

                        <!-- This form is used to add new todo List -->
                        <h:form>
                            <h:commandLink binding="#{bean.addcommand}" action="#{bean.addnew}"
                                value="Add new Todo" accesskey="a" />
                        </h:form>

                        <!-- This form is used to open to enter new Todo list -->
                        <h:form binding="#{bean.form}" rendered="false">
                            <h:panelGrid columns="2">

                                <h:column>
                                    <h:outputText value="Title" />
                                </h:column>

                                <h:column>
                                    <h:inputText value="#{bean.nbrp.title}" />
                                </h:column>

                                <h:column>
                                    <h:outputText value="Description" />
                                </h:column>

                                <h:column>
                                    <h:inputText value="#{bean.nbrp.description}" />
                                </h:column>


                               <h:column>
                                <h:outputText value="Priority" />
                               </h:column>


                                <h:column>
                                    <h:selectOneMenu value="#{bean.nbrp.priority}" style="width:127px;color:blue;font-weight:bold;">
                                        <f:selectItem itemValue="one" itemLabel="High"/>
                                        <f:selectItem itemValue="second" itemLabel="Medium" />
                                        <f:selectItem itemValue="three" itemLabel="Low" />
                                    </h:selectOneMenu>
                                </h:column>


                                </h:panelGrid>


                                <h:commandButton value="Save" action="#{bean.save}" />


                        </h:form>
                    </f:view>
                </rich:panel>
            </body>
            </html>

BasavaProp.java

パッケージcom.basu; java.util.Calendar をインポートします。

        public class BasavaProp {


            private String id;
            private String title;
            private String description;
            private int priority;
            private Calendar duedate;


            public BasavaProp(String title,String description,int priority)
            {
               this.title=title;
               this.description=description;
               this.priority=priority;
            }

            public String getId() {
                return id;
            }
            public void setId(String id) {
                this.id = id;
            }
            public String getTitle() {
                return title;
            }
            public void setTitle(String title) {
                this.title = title;
            }
            public String getDescription() {
                return description;
            }
            public void setDescription(String description) {
                this.description = description;
            }
            public int getPriority() {
                return priority;
            }
            public void setPriority(int priority) {
                this.priority = priority;
            }
            public Calendar getDuedate() {
                return duedate;
            }
            public void setDuedate(Calendar duedate) {
                this.duedate = duedate;
            }

        }


basavacontrol.java

   package com.basu;

    import java.util.ArrayList;
    import java.util.List;
    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.RequestScoped;
    import javax.faces.component.UICommand;
    import javax.faces.component.UIForm;

    @ManagedBean(name="bean")
    @RequestScoped
    public class basavacontrol {

        private List<BasavaProp> list;
        public BasavaProp nbrp; 
        private UIForm form;
        private UIForm dataform;
        private UICommand addcommand;


        public basavacontrol() {
        list=new ArrayList<BasavaProp>();
        list.add(new BasavaProp("title1", "hi", 2));
        list.add(new BasavaProp("chapter2", "i want to learn and earn", 7));
        }

        public String addnew(){
            nbrp=new BasavaProp("", "", 0);
            form.setRendered(true);
            addcommand.setRendered(false);
            return null;
        }


        public String save()
        {
           list.add(nbrp);
           form.setRendered(false);
           addcommand.setRendered(true);
           System.out.println("i am inside save method");
           return null;
        }



        public List<BasavaProp> getList() {
            return list;
        }

        public void setList(List<BasavaProp> list) {
            this.list = list;
        }

        public BasavaProp getNbrp() {
            return nbrp;
        }

        public void setNbrp(BasavaProp nbrp) {
            this.nbrp = nbrp;
        }

        public UIForm getForm() {
            return form;
        }

        public void setForm(UIForm form) {
            this.form = form;
        }

        public UIForm getDataform() {
            return dataform;
        }

        public void setDataform(UIForm dataform) {
            this.dataform = dataform;
        }

        public UICommand getAddcommand() {
            return addcommand;
        }

        public void setAddcommand(UICommand addcommand) {
            this.addcommand = addcommand;
        }

    }   
4

1 に答える 1