12 Replies Latest reply on Jun 4, 2009 5:43 AM by Nick Belaevski

    f:setPropertyActionListener not setting values to the backin

    Shivaji Byrapaneni Newbie

      Hi all,

      I had a data table in which i need to provide a button which on click should edit the current row. for doing that i had choosed f:setPropertyActionListener and used as shown

      <a4j:commandLink ajaxSingle="true" id="editlink"
       oncomplete="#{rich:component('editPanel')}.show()">
       <h:graphicImage value="/Images/edit.gif" style="border:1" />
       <f:setPropertyActionListener value="#{course}"
       target="#{manageCoursesBean.currentItem}" />
       <f:setPropertyActionListener value="#{row}"
       target="#{manageCoursesBean.currentRow}" />
       </a4j:commandLink>
      


      here 'course' is the var attribute of my datatble. i expected teh current selected row to be stored in current row. But it is storing null.

      Could anybody help me...?

      Thanks in advance

        • 1. Re: f:setPropertyActionListener not setting values to the ba
          Ilya Shaikovsky Master

          As far as I see you showing us the code from richfaces-demo almost without modifications. And it works there. Seems need more details.

          • 2. Re: f:setPropertyActionListener not setting values to the ba
            Nick Belaevski Master

            Where do you access currentRow and currentItem?

            What is not stored: row key or item?

            • 3. Re: f:setPropertyActionListener not setting values to the ba
              Shivaji Byrapaneni Newbie

              To ilya_shaikovsky::
              Im customizing the richfaces demo pages to fit my requirements. I hope it should not be a wrong thing to use the demos provided by the richfaces for building applications.
              I apologize you haven’t identified any changes. Im just a tag user other than tag developer so you might have seen the same tags.

              • 4. Re: f:setPropertyActionListener not setting values to the ba
                Shivaji Byrapaneni Newbie

                Sorry if i had confused in my question
                here is my complete page

                <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
                <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
                <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
                <!-- RichFaces tag library declaration -->
                <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
                <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
                <a4j:region>
                 <rich:dataTable value="#{manageCoursesBean.courseList}" var="course"
                 rowKeyVar="row" id="manageCoursesTable">
                 <f:facet name="header">
                 <h:outputText value="Manage Courses" />
                 </f:facet>
                 <rich:column>
                 <f:facet name="header">
                 <h:outputText value="Course Id" />
                 </f:facet>
                 <h:outputText value="#{course.courseId}" id="courseId" />
                 </rich:column>
                 <rich:column>
                 <f:facet name="header">
                 <h:outputText value="Course Name" />
                 </f:facet>
                 <h:outputText value="#{course.courseName}" id="courseName" />
                 </rich:column>
                 <rich:column>
                 <f:facet name="header">
                 <h:outputText value="No Of Seats" />
                 </f:facet>
                 <h:outputText value="#{course.noOfSeats}" id="noOfSeats" />
                 </rich:column>
                 <rich:column>
                 <f:facet name="header">
                 <h:outputText value="On Date" />
                 </f:facet>
                 <h:outputText value="#{course.onDate}" id="onDate" />
                 </rich:column>
                 <rich:column>
                 <f:facet name="header">
                 <h:outputText value="Course Time" />
                 </f:facet>
                 <h:outputText value="#{course.courseTime}" id="courseTime" />
                 </rich:column>
                 <rich:column>
                 <f:facet name="header">
                 <h:outputText value="Location" />
                 </f:facet>
                 <h:outputText value="#{course.location}" id="location" />
                 </rich:column>
                
                 <rich:column>
                 <f:facet name="header">
                 <h:outputText value="Is Course Expired" />
                 </f:facet>
                 <h:outputText value="#{course.isCourseExpired}" id="isCourseExpired" />
                 </rich:column>
                
                 <rich:column>
                 <f:facet name="header">
                 <h:outputText value="Actions" />
                 </f:facet>
                 <a4j:commandLink ajaxSingle="true" id="editlink"
                 oncomplete="#{rich:component('editPanel')}.show()">
                 <h:graphicImage value="/Images/edit.gif" style="border:1" />
                 <f:setPropertyActionListener value="#{course}"
                 target="#{manageCoursesBean.currentItem}" />
                 <f:setPropertyActionListener value="#{row}"
                 target="#{manageCoursesBean.currentRow}" />
                 </a4j:commandLink> <rich:toolTip for="editlink" value="Edit Course" />
                 <a4j:commandLink ajaxSingle="true" id="deletelink"
                 oncomplete="#{rich:component('deletePanel')}.show()">
                 <h:graphicImage value="/Images/delete.gif" style="border:0" />
                 <f:setPropertyActionListener value="#{row}"
                 target="#{manageCoursesBean.currentRow}" />
                 </a4j:commandLink>
                 <rich:toolTip for="deletelink" value="Delete Course" />
                 </rich:column>
                 <f:facet name="footer">
                 <rich:datascroller renderIfSinglePage="false" maxPages="5" />
                 </f:facet>
                 </rich:dataTable>
                </a4j:region>
                
                


                bolded part is the code im expecting to set the current selected row in the sense the row on which user clicks to edit the current row.

                Here i assumed the code to set the 'current' value to the backing bean item 'currentItem' . Which is setting the value null.

                I hope im bit clear now...



                • 5. Re: f:setPropertyActionListener not setting values to the ba
                  Ilya Shaikovsky Master

                  code from demo could be freely used for sure :) And it designed for this :)

                  As about your problem.. I still see no difference with our case except that your page is jsp page and we using facelets.. But this should not be a reason. I'll forward this to QA in order to investigate.

                  • 6. Re: f:setPropertyActionListener not setting values to the ba
                    Ilya Shaikovsky Master

                    and b.t.w. how about first Nick's question?

                    • 7. Re: f:setPropertyActionListener not setting values to the ba
                      Mikhail Vitenkov Newbie

                      Hello shivaji.byrapaneni,
                      I tried to reproduce issue, you described, it's not reproducible:
                      I have private Object currentRow;
                      and setter:

                      public void setCurrentRow(Object currentRow) {
                       if (currentRow == null)
                       System.out.println("current row is NULL");
                       else
                       System.out.println("current row:" + currentRow);
                       this.currentRow = currentRow;
                       }

                      When I click on 'editlink' following string output to console:
                      current row:5

                      My page code is similar with your, except I wraped <a4j:region> in f:view and h:form.
                      My configuration: Myfaces 1.2.5, richfaces 3.3.2-snapshot, tomcat 6.0.16
                      Thanks

                      • 9. Re: f:setPropertyActionListener not setting values to the ba
                        Shivaji Byrapaneni Newbie

                        my managed bean is also more or else having the same. Other than giving its as a object i gave it as a Entity Object.

                        here is the code

                        package com.managedbeans;
                        
                        import java.util.ArrayList;
                        
                        import javax.ejb.EJB;
                        
                        import com.constants.NominationConstants;
                        import com.entities.CourseDetailsEO;
                        import com.logger.NominationLogger;
                        import com.services.local.CoursesInformationServiceLocal;
                        
                        public class ManageCoursesBean extends NominationBaseBean {
                         private final String className = this.getClass().toString();
                         private ArrayList<CourseDetailsEO> courseList;
                         @EJB(mappedName = NominationConstants.COURSEINFOSERVICE_LOCAL)
                         private CoursesInformationServiceLocal coursesInformationService;
                         private CourseDetailsEO currentItem;
                         private CourseDetailsEO currentRow;
                        
                        
                         public CourseDetailsEO getCurrentRow() {
                         return currentRow;
                         }
                        
                         public void setCurrentRow(CourseDetailsEO currentRow) {
                         this.currentRow = currentRow;
                         }
                        
                         public CourseDetailsEO getCurrentItem() {
                         return currentItem;
                         }
                        
                         public void setCurrentItem(CourseDetailsEO currentItem) {
                         this.currentItem = currentItem;
                         }
                        
                         public ArrayList<CourseDetailsEO> getCourseList() {
                         return courseList;
                         }
                        
                         public void setCourseList(ArrayList<CourseDetailsEO> courseList) {
                         this.courseList = courseList;
                         }
                        
                         public void loadManageCourses() {
                         final String methodName = "loadManageCourses";
                         NominationLogger.logMethodEntry(className, methodName);
                         courseList = coursesInformationService.getCourseInfo();
                         NominationLogger.logMethodExit(className, methodName);
                         }
                        
                         public String updateCourseInfo() {
                         final String methodName = "updateCourseInfo";
                         NominationLogger.logMethodEntry(className, methodName);
                         NominationLogger.logMethodExit(className, methodName);
                         return null;
                         }
                        
                         public String deleteCourse() {
                         final String methodName = "deleteCourse";
                         NominationLogger.logMethodEntry(className, methodName);
                         NominationLogger.logMethodExit(className, methodName);
                         return null;
                         }
                        }
                        
                        


                        am i supposed to give the current row as Object class instance...?
                        is that mandatory..?

                        • 10. Re: f:setPropertyActionListener not setting values to the ba
                          Shivaji Byrapaneni Newbie

                          i tried changing the instance to Object. but that also didnt help

                          is there any other way to get the selected row in my backing bean....?

                          • 11. Re: f:setPropertyActionListener not setting values to the ba
                            Shivaji Byrapaneni Newbie

                            could any body help me on this please...

                            • 12. Re: f:setPropertyActionListener not setting values to the ba
                              Nick Belaevski Master

                              Watch created JIRA issue for workaround/resolution. Something will be posted after investigation.