Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何创建具有素数面的矩阵表格(3D表格)?_Java_Jsf 2_Primefaces - Fatal编程技术网

Java 如何创建具有素数面的矩阵表格(3D表格)?

Java 如何创建具有素数面的矩阵表格(3D表格)?,java,jsf-2,primefaces,Java,Jsf 2,Primefaces,我发现了同样的问题,我也试着为我的项目做同样的事情,但我无法得到结果,有人能检查我下面的代码并告诉我哪里出错了吗。 我想做的是得到一个表格,其中列是飞机,行是每架飞机的工作包,单元格是每架飞机的每个工作包中的作业。 XHTML是: <h:form id="globalreport"> <p:layout> <p:layoutUnit position="north"> <p:selectOneMenu id="model" value="#{

我发现了同样的问题,我也试着为我的项目做同样的事情,但我无法得到结果,有人能检查我下面的代码并告诉我哪里出错了吗。 我想做的是得到一个表格,其中列是飞机,行是每架飞机的工作包,单元格是每架飞机的每个工作包中的作业。 XHTML是:

<h:form id="globalreport">
  <p:layout>
   <p:layoutUnit position="north">
 <p:selectOneMenu id="model" value="#{userInterfaceMB.model}">
   <f:selectItem itemLabel="All models" itemValue="" />
   <f:selectItems value="#{userInterfaceMB.getAllAvailableModels()}" />
   <p:ajax update="aircraftTable"listener="#{userInterfaceMB.handleModelChange()}" />
 </p:selectOneMenu>
   </p:layoutUnit>

<p:layoutUnit position="center">
<p:dataTable id="aircraftTable" var="workPackageId" 
             value="# {userInterfaceMB.workPackagesIds}" rowIndexVar="rowIdx">
           <p:column headerText="" styleClass="ui-widget-header">
                <h:outputText value="#{workPackageId}" />
                 </p:column>
                <p:columns var="aircraftId" value="#  
                                               {userInterfaceMB.aircraftsIds}"
                         headerText="#{aircraftId}"   
                                                 columnIndexVar="colIdx">
        <ui:repeat value="#{userInterfaceMB.myJobs[rowIdx][colIdx]}"  
                               var="myJob">
                         <p:panel>
                <h:outputText value="#{myJob}" />
             </p:panel>
        </ui:repeat>
    </p:columns
</p:dataTable>
</p:layoutUnit> 
</p:layout>
</h:form>
</h:body>
@ManagedBean(name="userInterfaceMB")
@SessionScoped
@ComponentScan("com.")
public class UserInterfaceBean implements Serializable{

    private static final long serialVersionUID = 1L;

    //TODO Autowired is not working, get it to work
    @Autowired
    private DBDataManipulatorService dbDataManipulatorService;

    private int aircraftId;
    private String type;
    private String model;
    private List<String> workPackagesIds;
    private List<Integer> aircraftsIds;
    private ArrayList<ArrayList<ArrayList<MyJob>>> myJobs;
    private List<Aircraft> aircrafts; 


    public ArrayList<ArrayList<ArrayList<MyJob>>> getMyJobs() {
        return myJobs;
    }

    public void setMyJobs(ArrayList<ArrayList<ArrayList<MyJob>>> myJobs) {
        this.myJobs = myJobs;
    }

    public List<Integer> getAircraftsIds() {
        return aircraftsIds;
    }

    public void setAircraftsIds(List<Integer> aircraftsIDs) {
        this.aircraftsIds = aircraftsIDs;
    }

    public UserInterfaceBean(){
        //Because the Autowire is not working
        WebApplicationContext ctx =  
                FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance());
        dbDataManipulatorService = ctx.getBean(DBDataManipulatorService.class);

    }

    @PostConstruct
    public void Init() {

        aircrafts = new ArrayList<Aircraft>();
        aircrafts = dbDataManipulatorService.findAllAircrafts();

    }

    public List<Aircraft> getAircrafts() {
        if(aircrafts==null){
            aircrafts = dbDataManipulatorService.findAllAircrafts();
        }

        return aircrafts;
    }

    public void setAircrafts(List<Aircraft> aircrafts) {
        this.aircrafts = aircrafts;
    }

    public DBDataManipulatorService getDBDataManipulatorService() {

        return dbDataManipulatorService;
    }

    public void setDBDataManipulatorService(DBDataManipulatorService   
                                                dbDataManipulatorService) {

    }

    public int getAircraftId() {
        return aircraftId;
    }

    public String getType() {
        return type;
    }

    public String getModel() {
        return model;
    }


    public List<String> getWorkPackagesIds() {
        return workPackagesIds;
    }



    public void setAircraftId(int aircraftId) {
        this.aircraftId = aircraftId;
    }


    public void setType(String type) {
        this.type = type;
    }


    public void setModel(String model) {
        this.model = model;
    }


    public void setWorkPackagesIds(List<String> workPackageIds) {
        this.workPackagesIds = workPackageIds;
    }

    public List<String> getAllAvailableModels(){

        return  dbDataManipulatorService.findAllAvailableAircraftsModels();
    }

    public void handleModelChange(){

        List<Aircraft> aircrafts =   
                               dbDataManipulatorService.findAllAircraftsByModel(model);

        setAircrafts(aircrafts); 
        List<Integer> aircraftsIds = new ArrayList<Integer>(); 

        for(Aircraft aircraft:aircrafts){

            int aircraftId = aircraft.getAircraftId();
            aircraftsIds.add(aircraftId);               
        }
        setAircraftsIds(aircraftsIds);
        getDistinctWorkPackageId(model);
        updateMyJobs();
    }

    public List<WorkPackage> getAllAvailableWorkPackesByAircraftModel(String model){

        List<WorkPackage> workpackages = new ArrayList<WorkPackage>();

        workpackages = dbDataManipulatorService.getWorkPackagesByAircraftModel(model);

        return workpackages;
    }

    public void getDistinctWorkPackageId(String model){

        List<String> workPackagesIds = new ArrayList<String>();
        List<WorkPackage> workPackages = 
                                  getAllAvailableWorkPackesByAircraftModel(model);

        for(WorkPackage workPackage: workPackages){

            String workPackageId = workPackage.getWorkPackageId();

            if (!workPackagesIds.contains(workPackageId)){

                workPackagesIds.add(workPackageId);
            }       
        }
        setWorkPackagesIds(workPackagesIds);
    }

    public void updateMyJobs(){
        ArrayList<ArrayList<ArrayList<MyJob>>> myJobs = 
                                                 new ArrayList<ArrayList<ArrayList<MyJob>>>();

                Map<Integer, Aircraft> aircraftsMap = getAircraftsMap();

        int aircraftId = 0;
        String workPackageId = null;

        for (int i = 0; i < aircraftsIds.size(); i++) {

            aircraftId = aircraftsIds.get(i);

            if (aircraftsMap.containsKey(aircraftId)){

                Aircraft aircraft = aircraftsMap.get(aircraftId);

                Map<String, WorkPackage> workPackagesMap = 
                                                         aircraft.getWorkPackagesMap();

                for(int j=0; j<workPackagesIds.size();j++){

                    workPackageId = workPackagesIds.get(j);

                    if(workPackagesMap.containsKey(workPackageId)){

                        WorkPackage workPackage = 
                                                          workPackagesMap.get(workPackageId);

                        List<MyJob> jobsMap = 
                                               (List<MyJob>)workPackage.getJobsMap().values();                      

                        for(MyJob myJob:jobsMap){

                            myJobs.get(i).get(j).add(myJob);
                        }
                    }
                }

            }
        }

        setMyJobs(myJobs);
    }


    private  Map<Integer, Aircraft> getAircraftsMap(){

        Map<Integer, Aircraft> aircraftsMap = new HashMap<Integer, Aircraft>();

        for(Aircraft aircraft: aircrafts){

            aircraftsMap.put(aircraft.getAircraftId(), aircraft);
        }

        return aircraftsMap;

    }

}
+--------------+--------------------------+--------------------------+-------------+------
|              |  Aircraft1               |  Aircraft2               |  ...... ....
+--------------+--------------------------+--------------------------+-------------+------
|              | +-------+----------+     | +-------+----------+     |
|              | |jobId1 |jobstatus |     | |jobId1 |jobstatus |     |  
|              | +-------+----------+     | +-------+----------+     |
| Workpackage1 | |jobId2 |jobstatus |     | |jobId2 |jobstatus |     |
|              | +-------+----------+     | +-------+----------+     |
|              | |jobId3 |jobstatus |     |                          |
|              | +-------+----------+     |                          |
+--------------+--------------------------+--------------------------+-------------------
|              | +-------+----------+     | +-------+----------+     |
|              | |jobId1 |jobstatus |     | |jobId1 |jobstatus |     |  
|              | +-------+----------+     | +-------+----------+     |
| Workpackage2 |                          | |jobId2 |jobstatus |     |
|              | +-------+----------+     | +-------+----------+     |
|              | |jobId3 |jobstatus |     |                          |
|              | +-------+----------+     |                          |
+--------------+--------------------------+--------------------------+-------------------
  ....