I have p:panelGrid
that receives dynamic data as it is received by the onItemchanged
method mentioned in the code. However, depending on the image, the component does not render and only displays the text.
I have tried Glassfish and Jboss and the result is the same.
Page (JSF-XHTML):
<?xml version='1.0' encoding='UTF-8' ?>
<!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:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title>PollGF</title>
</h:head>
<h:body>
<h:form>
<h:commandButton value="Start" actionListener="#{comm.init()}" />
<br/>
<h:panelGrid id="grid" columns="7" style="margin-top: 20px">
<f:facet name="header">
<p:row>
<p:column colspan="7">Soybeans Quotes</p:column>
</p:row>
<p:row>
<p:column>Description</p:column>
<p:column>Last</p:column>
<p:column>Diff</p:column>
<p:column>%</p:column>
<p:column>Close</p:column>
<p:column>Ask</p:column>
<p:column>Bid</p:column>
</p:row>
</f:facet>
<p:row>
<p:column >#{comm.description}</p:column>
<p:column >#{comm.last}</p:column>
<p:column >#{comm.diff}</p:column>
<p:column >#{comm.variation}</p:column>
<p:column >#{comm.close}</p:column>
<p:column >#{comm.ask}</p:column>
<p:column >#{comm.bid}</p:column>
</p:row>
</h:panelGrid>
<p:poll interval="1" update="grid" />
</h:form>
</h:body>
</html>
Managed Bean:
import br.com.jpoint.periods.SoyNov4;
import com.pretty_tools.dde.DDEException;
import com.pretty_tools.dde.client.DDEClientConversation;
import com.pretty_tools.dde.client.DDEClientEventListener;
import java.util.concurrent.CountDownLatch;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean(name = "comm")
@SessionScoped
public class Comm {
private String description;
private String last;
private String diff;
private String variation;
private String close;
private String ask;
private String bid;
private String code;
private String value;
final CountDownLatch eventDisconnect = new CountDownLatch(1);
final DDEClientConversation conversation = new DDEClientConversation();
private static final String SERVICE = "TWSVR";
private static final String TOPIC = "CMA";
static final String[] items = {
"0030ZS*1;212", "0030ZS*1;41", "0030ZS*1;1", "0030ZS*1;6", "0030ZS*1;7", "0030ZS*1;25", "0030ZS*1;3", "0030ZS*1;4",
"0030ZS*2;212", "0030ZS*2;41", "0030ZS*2;1", "0030ZS*2;6", "0030ZS*2;7", "0030ZS*2;25", "0030ZS*2;3", "0030ZS*2;4"
// "0030ZS*3;212", "0030ZS*3;41", "0030ZS*3;1", "0030ZS*3;6", "0030ZS*3;7", "0030ZS*3;25", "0030ZS*3;3", "0030ZS*3;4",
// "0030ZS*4;212", "0030ZS*4;41", "0030ZS*4;1", "0030ZS*4;6", "0030ZS*4;7", "0030ZS*4;25", "0030ZS*4;3", "0030ZS*4;4",
// "0030ZS*5;212", "0030ZS*5;41", "0030ZS*5;1", "0030ZS*5;6", "0030ZS*5;7", "0030ZS*5;25", "0030ZS*5;3", "0030ZS*5;4",
// "0030ZS*6;212", "0030ZS*6;41", "0030ZS*6;1", "0030ZS*6;6", "0030ZS*6;7", "0030ZS*6;25", "0030ZS*6;3", "0030ZS*6;4",
// "0030ZS*7;212", "0030ZS*7;41", "0030ZS*7;1", "0030ZS*7;6", "0030ZS*7;7", "0030ZS*7;25", "0030ZS*7;3", "0030ZS*7;4",
// "0030ZS*8;212", "0030ZS*8;41", "0030ZS*8;1", "0030ZS*8;6", "0030ZS*8;7", "0030ZS*8;25", "0030ZS*8;3", "0030ZS*8;4",
// "0030ZS*9;212", "0030ZS*9;41", "0030ZS*9;1", "0030ZS*9;6", "0030ZS*9;7", "0030ZS*9;25", "0030ZS*9;3", "0030ZS*9;4",
// "0030ZS*10;212", "0030ZS*10;41", "0030ZS*10;1", "0030ZS*10;6", "0030ZS*10;7", "0030ZS*10;25", "0030ZS*10;3", "0030ZS*10;4",
// "0030ZS*11;212", "0030ZS*11;41", "0030ZS*11;1", "0030ZS*11;6", "0030ZS*11;7", "0030ZS*11;25", "0030ZS*11;3", "0030ZS*11;4",
// "0030ZS*12;212", "0030ZS*12;41", "0030ZS*12;1", "0030ZS*12;6", "0030ZS*12;7", "0030ZS*12;25", "0030ZS*12;3", "0030ZS*12;4",
// "0030ZS*13;212", "0030ZS*13;41", "0030ZS*13;1", "0030ZS*13;6", "0030ZS*13;7", "0030ZS*13;25", "0030ZS*13;3", "0030ZS*13;4"
};
public Comm() {
}
public void init() throws DDEException {
// System.loadLibrary("JavaDDE");
// System.loadLibrary("JavaDDEx64");
conversation.connect(SERVICE, TOPIC);
conversation.setEventListener(new DDEClientEventListener() {
@Override
public void onDisconnect() {
System.out.println("onDisconnect()");
eventDisconnect.countDown();
}
@Override
public void onItemChanged(String topic, String item, String data) {
System.out.println("onItemChanged(" + topic + "\t" + item + "\t" + data + ")");
code = item;
value = data;
//******************************************************
if(item.equalsIgnoreCase(SoyNov4.DESCRIPTION)){
description = data;
} else if (item.equalsIgnoreCase(SoyNov4.LAST)){
last = data;
} else if(item.equalsIgnoreCase(SoyNov4.DIFF)){
diff = data;
} else if(item.equalsIgnoreCase(SoyNov4.VARIATION)){
variation = data;
} else if(item.equalsIgnoreCase(SoyNov4.CLOSE)){
close = data;
} else if(item.equalsIgnoreCase(SoyNov4.ASK)){
ask = data;
} else if(item.equalsIgnoreCase(SoyNov4.BID)){
bid = data;
}
//******************************************************
try {
if ("stop".equalsIgnoreCase(data)) {
conversation.stopAdvice(item);
}
} catch (DDEException e) {
System.out.println("Exception: " + e);
}
}
});
//**********************************************//
for (String i : items) {
conversation.startAdvice(i);
}
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getLast() {
return last;
}
public void setLast(String last) {
this.last = last;
}
public String getDiff() {
return diff;
}
public void setDiff(String diff) {
this.diff = diff;
}
public String getVariation() {
return variation;
}
public void setVariation(String variation) {
this.variation = variation;
}
public String getClose() {
return close;
}
public void setClose(String close) {
this.close = close;
}
public String getAsk() {
return ask;
}
public void setAsk(String ask) {
this.ask = ask;
}
public String getBid() {
return bid;
}
public void setBid(String bid) {
this.bid = bid;
}
}