1 2 Previous Next 23 Replies Latest reply: Jan 18, 2013 9:32 AM by morellik Go to original post RSS
      • 15. Re: Remove JPA related entity
        gimbal2
        morellik wrote:
        I'm thinking to stop to study Java EE, seems too complicate. :-((
        My learning path was like this:

        - learn C++ and Java in school (2 years)
        - learn basic web development (HTML, CSS, Javascript, PHP) during internships (1 year)
        - learn Java web development (servlets & JSPs, JDBC) "on the job" (3 years)
        - learn Enterprise development (EJBs, JMS, JSF, JPA + Hibernate) "on the job" (2 years)

        Shocking how much time that took huh? You don't learn this stuff overnight, I would take it in steps.
        • 16. Re: Remove JPA related entity
          morellik
          >
          You are using
          Long id = printer.getId();
          In that code you are getting the id from the printer object but where did you set that value? That printer object just has a null value because the id was never set. You probably mean to get that value from the jsf page but you never passed any values to it at all.
          In ths JSF I have:
            <h:column>
                                  <f:facet name="header">
                                      <h:outputText value="Select to remove" />
                                  </f:facet>
                                  <h:selectOneRadio id="id" value="#{printerController.printer.id}" >
                                          <f:selectItem itemValue="#{pr.id}" />
                                      </h:selectOneRadio>
                                      
                              </h:column>
                          </h:dataTable>
                              <h:commandButton value="Remove"  style="margin-right:20px;" action="#{printerController.removePrinter}"/>  
                          </h:form>
          • 17. Re: Remove JPA related entity
            r035198x
            >
            In ths JSF I have:
            Ya, but that's in a table with possibly many records. When you click remove which Id would you think is removed?
            If you google "using datables in jsf" you'll get some good articles that explain how to do what you are trying to do. It really helps to read about stuff before trying it.
            • 18. Re: Remove JPA related entity
              morellik
              gimbal2 wrote:
              morellik wrote:
              I'm thinking to stop to study Java EE, seems too complicate. :-((
              My learning path was like this:

              - learn C++ and Java in school (2 years)
              - learn basic web development (HTML, CSS, Javascript, PHP) during internships (1 year)
              - learn Java web development (servlets & JSPs, JDBC) "on the job" (3 years)
              - learn Enterprise development (EJBs, JMS, JSF, JPA + Hibernate) "on the job" (2 years)

              Shocking how much time that took huh? You don't learn this stuff overnight, I would take it in steps.
              Thanks, this is a good news. I come from C, perl, PHP and Python (for standalone and web applications). And now I would go to Java EE for web applications.
              I downloaded Oracle Tutorial and Best JPA 2, I'll start to study.
              • 19. Re: Remove JPA related entity
                gimbal2
                r035198x wrote:
                >
                In ths JSF I have:
                Ya, but that's in a table with possibly many records. When you click remove which Id would you think is removed?
                If you google "using datables in jsf" you'll get some good articles that explain how to do what you are trying to do. It really helps to read about stuff before trying it.
                If you look at the code you'll see that the button is actually outside of the datatable. It looks like it is based on a single selection.
                morellik wrote:
                I downloaded Oracle Tutorial and Best JPA 2, I'll start to study.
                If that is "Pro JPA 2", you've got a really good book. I advise to add "Enterprise Javabeans 3.1" to that too for the EJB side; I haven't seen a book yet that explains it more clearly in my opinion.
                • 20. Re: Remove JPA related entity
                  r035198x
                  gimbal2 wrote:
                  If you look at the code you'll see that the button is actually outside of the datatable. It looks like it is based on a single selection.
                  The button is outside now but he is trying to bind the printer to the controller with values in the datatable. He needs to have select functionality and be able to pass the selected record from the datatable to the controller.
                  • 21. Re: Remove JPA related entity
                    morellik
                    Usually when I loop over a list of values to create a table I give to each radio-button a value. When I press the submit button I pass to the controller the value of the radio button selected. Is it correct? (I do that with Python and its templates languages). So If I check the page source I see that each radio-button has the printer.id value associated to it. I'm expecting that when I press submit the removePrinter obtains the correct value bind to printerController.printer.id.

                    I created some other forms and the concept is the same. Each input field is associated with a printerController.printer.DB_FIELD. When I press Submit the value entered in the filed will pass to the controller that elaborates each printerController.printer.DB_FIELD.

                    I don't understand why in this case this principle doesn't works.
                    • 22. Re: Remove JPA related entity
                      gimbal2
                      r035198x wrote:
                      gimbal2 wrote:
                      If you look at the code you'll see that the button is actually outside of the datatable. It looks like it is based on a single selection.
                      The button is outside now but he is trying to bind the printer to the controller with values in the datatable. He needs to have select functionality and be able to pass the selected record from the datatable to the controller.
                      I see. Yeah that or just pass the ID as a parameter to the action method, assuming its JSF 2. That's a really simple way I use always nowadays.

                      Something like:
                         <h:commandLink action="#{myBean.doSomething(item.id)}" value="Remove!"/>
                      public String doSomething(int id){
                       ...
                      }
                      Edited by: gimbal2 on Jan 19, 2013 5:09 AM - typo in the code
                      • 23. Re: Remove JPA related entity
                        morellik
                        >
                        Something like:
                        <h:commandLink action="#{myBean.doSomething(item.id}" value="Remove!"/>
                        public String doSomething(int id){
                        ...
                        }
                        Bingo!!! It works!!! Great :-)))

                        Thanks to all.
                        1 2 Previous Next