• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

problem JSF - datatable from DB

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I don't understand with this code doesn't work and not load data fro Db

I used Tomcat 7.0 and login application and link application with parameter work correctly so the problem is not in configuration of application


faces-config.xml


<?xml version="1.0" encoding="UTF-8"?>

<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/w...sconfig_2_0.xsd"
version="2.0">

<!-- Bean -->
<managed-bean>
<managed-bean-name>tableConfigurationBean</managed-bean-name>
<managed-bean-class>bean.TableParameterConfiguration</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>

<managed-bean>
<managed-bean-name>tableListBean</managed-bean-name>
<managed-bean-class>bean.TableListBatchLoad</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>

<managed-bean>
<managed-bean-name>handlerBatch</managed-bean-name>
<managed-bean-class>bean.HandlerBatch</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>

<managed-bean>
<managed-bean-name>loginBean</managed-bean-name>
<managed-bean-class>bean.DashboardBeanLogin</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>

<managed-bean>
<managed-bean-name>simpleLogin</managed-bean-name>
<managed-bean-class>bean.HandlerLogin</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>loginBean</property-name>
<value>#{loginBean}</value>
</managed-property>
</managed-bean>


<!-- Navigation Rules -->
<!-- INDEX -->
<navigation-rule>
<display-name>DASHBOARD</display-name>
<from-view-id>/index.jsp</from-view-id>
<navigation-case>
<from-action>#{handlerBatch.startDashboard}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>login.jsp</to-view-id>
</navigation-case>
</navigation-rule>

<!-- LOGIN -->
<navigation-rule>
<display-name>DASHBOARD</display-name>
<from-view-id>/login.jsp</from-view-id>
<navigation-case>
<from-action>#{simpleLogin.CheckValidUser}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>dataBatchList.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-action>#{simpleLogin.CheckValidUser}</from-action>
<from-outcome>fail</from-outcome>
<to-view-id>loginerror.jsp</to-view-id>
</navigation-case>
</navigation-rule>

<!-- DATABATCHLIST -->
<navigation-rule>
<display-name>DASHBOARD</display-name>
<from-view-id>/dataBatchList.jsp</from-view-id>
<!-- monitoring -->
<navigation-case>
<from-action>#{handlerBatch.monitoringDetails}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>dataBatchDetails.jsp</to-view-id>
</navigation-case>
<!-- action -->
<!-- START -->
<navigation-case>
<from-action>#{handlerBatch.startApplication}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>batchAction.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-action>#{handlerBatch.startApplication}</from-action>
<from-outcome>fail</from-outcome>
<to-view-id>batcherror.jsp</to-view-id>
</navigation-case>
<!-- STOP -->
<navigation-case>
<from-action>#{handlerBatch.stopApplication}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>batchAction.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-action>#{handlerBatch.stopApplication}</from-action>
<from-outcome>fail</from-outcome>
<to-view-id>batcherror.jsp</to-view-id>
</navigation-case>
<!-- CONFIGURE -->
<navigation-case>
<from-action>#{handlerBatch.configureBatch}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>dataBatchConfiguration.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-action>#{handlerBatch.configureBatch}</from-action>
<from-outcome>fail</from-outcome>
<to-view-id>batcherror.jsp</to-view-id>
</navigation-case>
</navigation-rule>



<!-- Data Validator -->
<validator>
<validator-id>validateLongRange</validator-id>
<validator-class>bean.ValidatorData</validator-class>
</validator>


</faces-config>


codice java

non pubblico il bean con gli attributi che mi sembra ovvio che sia corretto con attributi e relativi getter e setter

package bean;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;


@ManagedBean(name="tableListBean")
@SessionScoped
public class TableListBatchLoad
{
private List<DashboardBeanGenericBatchProperties> batchList = new ArrayList<DashboardBeanGenericBatchProperties>();


public List<DashboardBeanGenericBatchProperties> getBatchList()
{
return batchList;
}


public void setBatchList(List<DashboardBeanGenericBatchProperties> batchList)
{
this.batchList = batchList;
}


public List<DashboardBeanGenericBatchProperties> getConfigurationList()
{
int i = 0;
BatchMonitoring bm = new BatchMonitoring();
String batchName = null;
String pathFileConf = null;
String nameFileConf = null ;
String processState = null;
Date startDate = null;
Date endDate = null;

try
{
Connection conn = DbManagement.openDBConnection();
String sStmt;
PreparedStatement ps;
sStmt = "select * from batch_identification ";
ps = conn.prepareStatement(sStmt);
ResultSet rs = ps.executeQuery(sStmt);

while(rs.next())
{
// TODO Verificare come gestire eventualmente il doppio file di configurazione
batchName = rs.getString("BatchName");
pathFileConf = rs.getString("path_file_conf");
nameFileConf = rs.getString("name_file_conf");

processState = bm.readStatusBatch(pathFileConf + "\\" +nameFileConf);
startDate = bm.getStartDate(pathFileConf + "\\" +nameFileConf);
endDate = bm.getEndDate(pathFileConf + "\\" +nameFileConf);

// Creo gli oggetti da visualizzare nelle vista e li aggiungo alla lista completa
batchList.add (i,new DashboardBeanGenericBatchProperties(batchName, processState, startDate, endDate));
i++;
}

rs.close();
if (ps != null) {ps.close();}

DbManagement.closeDBConnection(true);
}
catch (Exception e)
{
System.out.println("Error Data : " + e.getMessage());
}

return batchList;
}
}


codice jsf


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Batch Monitoring</title>
</head>
<body>
<f:view>
<center>
<!-- TEST LINK START -->
<h:form>
<h:commandLink value="Details"
action="#{handlerBatch.monitoringDetails}">
<h:outputText style="" value="TEST Details"></h:outputText>
</h:commandLink>
</h:form>
<br>
<h:form>
<h:commandLink value="Configure"
action="#{handlerBatch.configureBatch}">
<h:outputText style="" value="TEST Configure OK"></h:outputText>
<f:param name="batchID" value="IF8" />
<f:param name="statusBatch" value="OK" />
</h:commandLink>
</h:form>
<br>
<h:form>
<h:commandLink value="Configure"
action="#{handlerBatch.configureBatch}">
<h:outputText style="" value="TEST Configure in progress"></h:outputText>
<f:param name="batchID" value="IF8" />
<f:param name="statusBatch" value="KO" />
</h:commandLink>
</h:form>
<br>
<h:form>
<h:commandLink value="Start"
action="#{handlerBatch.startApplication}">
<h:outputText style="" value="TEST Start"></h:outputText>
<f:param name="batchID" value="IF8" />
<f:param name="statusBatch" value="OK" />
</h:commandLink>
</h:form>
<br>
<h:form>
<h:commandLink value="Start"
action="#{handlerBatch.startApplication}">
<h:outputText style="" value="TEST Start KO"></h:outputText>
<f:param name="batchID" value="IF8" />
<f:param name="statusBatch" value="KO" />
</h:commandLink>
</h:form>
<br>
<h:form>
<h:commandLink value="Stop"
action="#{handlerBatch.stopApplication}">
<h:outputText style="" value="TEST Stop"></h:outputText>
<f:param name="batchID" value="IF8" />
<f:param name="statusBatch" value="OK" />
</h:commandLink>
</h:form>
<br>
<h:form>
<h:commandLink value="Start"
action="#{handlerBatch.stopApplication}">
<h:outputText style="" value="TEST Stop KO"></h:outputText>
<f:param name="batchID" value="IF8" />
<f:param name="statusBatch" value="KO" />
</h:commandLink>
</h:form>
<!-- TEST LINK END -->

<br>
<h:form>
<h:dataTable id="dt1" value="#{tableListBean.configurationList}" var="item"
bgcolor="#F1F1F1" border="10" cellpadding="5" cellspacing="3"
rows="4" width="50%" frame="hsides" rules="all"
summary="List of batch monitoring by dashboard">

<f:facet name="header">
<h:outputText value="Configure Batch" />
</f:facet>

<h:column>
<f:facet name="header">
<h:outputText value="Process" />
</f:facet>
<h:outputText style="" title="process name" value="#{item.processName}" />
</h:column>

<h:column>
<f:facet name="header">
<h:outputText value="Status" />
</f:facet>
<h:outputText value="#{item.processState}" />
</h:column>

<h:column>
<f:facet name="header">
<h:outputText value="Last Start Date" />
</f:facet>
<h:outputText value="#{item.startDate}" />
</h:column>

<h:column>
<f:facet name="header">
<h:outputText value="Last End Date" />
</f:facet>
<h:outputText value="#{item.endDate}" />
</h:column>

<h:column>
<f:facet name="header">
<h:outputText value="Start Batch" />
</f:facet>
<h:commandLink value="Start"
action="#{handlerBatch.startApplication}">
<h:outputText>Start Batch</h:outputText>
<f:param name="batchID" value="#{item.processName}" />
<f:param name="statusBatch" value="#{item.processState}" />
</h:commandLink>
</h:column>

<h:column>
<f:facet name="header">
<h:outputText value="Stop Batch" />
</f:facet>
<h:commandLink value="Stop"
action="#{handlerBatch.stopApplication}">
<h:outputText>Stop Batch</h:outputText>
<f:param name="batchID" value="#{item.processName}" />
<f:param name="statusBatch" value="#{item.processState}" />
</h:commandLink>
</h:column>

<h:column>
<f:facet name="header">
<h:outputText value="Configure Batch" />
</f:facet>
<h:commandLink value="Configure"
action="#{handlerBatch.configureBatch}">
<h:outputText>Configure Parameter Properties</h:outputText>
<f:param name="batchID" value="#{item.processName}" />
<f:param name="statusBatch" value="#{item.processState}" />
</h:commandLink>
</h:column>

<h:column>
<f:facet name="header">
<h:outputText value="Batch Details" />
</f:facet>
<h:commandLink value="Details"
action="#{handlerBatch.monitoringDetails}">
<f:param name="batchID" value="#{item.processName}" />
</h:commandLink>
</h:column>
<f:facet name="footer">
<h:outputText value="End Batch List" />
</f:facet>
</h:dataTable>
</h:form>
<br>
</center>
</f:view>
</body>
</html>
 
You will always be treated with dignity. Now, strip naked, get on the probulator and hold this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic