vulturistic vulturistic - 1 year ago 66
Java Question

my program doesnt read one of my static method

this is just a basic question and I'm just wondering why my program doesnt read one of my static method. I'm sorry I'm just a newbie here. Here's my code.

public class SMSDataBean implements Serializable {

private static final long serialVersionUID = 1L;
static File smsLogFile;
static String smsLogFilePath;
static PrintWriter printWriter;
static final String newLine = System.getProperty("line.separator");

private static final SMSLog[] smslog = new SMSLog[] {
new SMSLog("123", "test1", "31235", "jan 3", "4122", "test", "dsdaae")

public SMSLog[] getSmslog() {
return smslog;

public static class SMSLog {

String msisdn;
String message;
String from;
String date;
String resCod;
String resDesc;
String resMsg;

public SMSLog(String msisdn, String message, String from, String date,
String resCod, String resDesc, String resMsg) {
this.msisdn = msisdn;
this.message = message;
this.from = from; = date;
this.resCod = resCod;
this.resDesc = resDesc;
this.resMsg = resMsg;


public String getMsisdn() {
return msisdn;

public void setMsisdn(String msisdn) {
this.msisdn = msisdn;

public String getMessage() {
return message;

public void setMessage(String message) {
this.message = message;

public String getFrom() {
return from;

public void setFrom(String from) {
this.from = from;

public String getDate() {
return date;

public void setDate(String date) { = date;

public String getResCod() {
return resCod;

public void setResCod(String resCod) {
this.resCod = resCod;

public String getResDesc() {
return resDesc;

public void setResDesc(String resDesc) {
this.resDesc = resDesc;

public String getResMsg() {
return resMsg;

public void setResMsg(String resMsg) {
this.resMsg = resMsg;

public static void printSMSRequest(String msisdn, String message,
String fromNo, String responseCode, String responseDescription,
String responseMsg) {
String msg;
try {
if (smsLogFile == null) {
smsLogFile = new File(smsLogFilePath);
if (!smsLogFile.exists())
printWriter = new PrintWriter(
new FileOutputStream(smsLogFile, true));
msg = "s:{'msdn':'" + msisdn + "','msg':'" + message + "','from':'"
+ fromNo + "','date':'" + new Date().toLocaleString()
+ "','resCode':'" + responseCode + "','resDesc':'"
+ responseDescription + "','resMsg':'" + responseMsg + "'}";
printWriter.write(newLine + msg);
} catch (IOException ioex) {
} finally {
if (printWriter != null) {
msg = null;

public static String getSmsLogFilePath() {
System.out.println("pathhhhhhh: "+smsLogFilePath);
return smsLogFilePath;

public static void setSmsLogFilePath(String smsLogFilePath) {
SMSDataBean.smsLogFilePath = smsLogFilePath;


here's my faces-config.xml

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



and here is my default.xhtml file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns=""
<!-- <h:outputStylesheet library="css" name="styles.css" /> -->
<h2>DataTable Example</h2>
<h:dataTable value="#{sms.smslog}" var="smslog"
<f:facet name="header">msisdn</f:facet>
<f:facet name="header">message</f:facet>
<f:facet name="header">from</f:facet>
<f:facet name="header">date</f:facet>

my program doesnt read the printSMSRequest method. Do I need to instantiate it? But as I read you don't need to instantiate the static method. Help please. Thanks. Sorry for my noob question.

Answer Source

check your <h:dataTable value="#{sms.printSMSRequest}" var="print" styleClass="employeeTable" headerClass="employeeTableHeader" rowClasses="employeeTableOddRow,employeeTableEvenRow"> if it's working or not. I think it has the problem.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download