Bb DevCon 2017 Starter B2 Hands on Session Part 3 Adding Group Titles

Blog Post created by ahulme on Mar 17, 2017

Now we have a working Building Block lets add some more information to the course tool as a form.




//Create a LIST filled with Group Objects using the Course ID.


  private static List<Group> GroupObjects(String course_id) throws PersistenceException{
        GroupDbLoader groupDbLoader = GroupDbLoader.Default.getInstance();
        List<Group> groups = groupDbLoader.loadAvailableByCourseId((Id.generateId(new DataType(blackboard.data.course.Course.class), course_id)));

        List<Group> G1 = new LinkedList<>();

            for (Group group : groups){
                //Get group titles. Add to Linked list g1.
                System.out.println("Group Size"+group.getGroupMemberships().size());
            return G1;



Now we need to add some Getter's and Setter's for the List we will pass to the JSP page.



private List<Group> groupTitles; 
public List<Group> getGroupTitles() {return groupTitles; }
public void setGroupTitles(List<Group> groupTitles) { this.groupTitles = groupTitles; }



In our Default Handler   @DefaultHandler   public Resolution displayPage() we can populate this list


groupTitles = GroupObjects(course_id);


To display this in the JSP we use the actionBean.groupTitles List and then can call out the getTitle and getGroupMemberships().size() from the Group Object in the List


<bbNG:form action="coursetool" method="post">


            <bbNG:step title="Groups">


                        <bbNG:inventoryList description="Group Names"  className="Group" collection="${actionBean.groupTitles}" objectVar="title" emptyMsg="No data to display">

                        <bbNG:listElement  name="Group" label="Group" isRowHeader="true">${title.getTitle()}</bbNG:listElement>

                        <bbNG:listElement  name="Group Enrollments" label="Group Enrollments"  isRowHeader="false">${title.getGroupMemberships().size()}</bbNG:listElement>

                        <bbNG:listCheckboxElement  title="Title" name="${title.getTitle()}" id="ID" value="Y"></bbNG:listCheckboxElement>



                        <input type="hidden" name="course_id" value="${actionBean.course_id}" />




            <bbNG:stepInstructions text="    ${message}  <BR>

               Course Title =  ${actionBean.course_title} <BR>

               Course Pk1 =  ${actionBean.course_id}  <BR>

               User Name  = ${actionBean.username}



        <bbNG:stepSubmit  cancelUrl="Cancle" />