0

I'm trying to move some spreadsheets online, so I created a Java EE application, and I've been trying to play with <h:datatable> to post my tables onto the webpage. When this all is published to the server (JBoss EAP 6.4), I get the following output:

Title Header 
Name  Current Milestone  #{Change.currentMilestone} 

Below are my entity, bean, and xhtml page, in order.

public class Change {

   private String id;
   private String currentMilestone;

   public Change(){
   }

   public Change(String id, String currentMilestone) {
      super();
      this.id = id;
      this.currentMilestone = currentMilestone;
   }

   public String getId() {
      return id;
   } 

   public void setId(String id) {
      this.id = id;
   }


   public String getCurrentMilestone() {
      return currentMilestone;
   }

   public void setCurrentMilestone(String currentMilestone) {
      this.currentMilestone = currentMilestone;
   }
}

And now the bean

import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.inject.Named;

@ManagedBean(name = "changesBean")
@RequestScoped
public class ChangesBean {

   private List<Change> changes;

   @PostConstruct
   public void init() {

     changes = new ArrayList<Change>();
     changes.add(new Change("HDT 1243", "P&A"));
     changes.add(new Change("CR 2324", "Dev"));
     changes.add(new Change("ECP 6658", "Testing"));
   }

   public List<Change> getChanges(){
      return changes;
   }
}

And now the webpage.

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:h="http://java.sun.com/jsf/html">
<h:body>     
<ui:composition template="/templates/common.xhtml">
    <h:dataTable value="#{changesBean.changes}" var="change">
        <h:column>
            <f:facet name="header">Name</f:facet>
            <h:link value = "#{change.id}" outcome="change"></h:link>
        </h:column>
        <h:column>
            <f:facet name="header">Current Milestone</f:facet>
            #{Change.currentMilestone}
        </h:column>
    </h:dataTable>
</ui:composition>
</h:body>
</html>

Any help I could get with this problem would be greatly appreciated.

Patrick
  • 53
  • 1
  • 9
  • doesn't your ManagedBean tag need to also have the name? so ManagedBean (name="changesBean") with the @ symbol at the start, but obviously that will try to tag a user here – WearyWanderer Jan 07 '16 at 15:53
  • Thanks for the quick response, however I tried that, and it didn't make a difference. – Patrick Jan 07 '16 at 15:59
  • I'm not sure about the format for dataTables, will have a look and edit my answer accordingly shortly – WearyWanderer Jan 07 '16 at 16:01

0 Answers0