Skip to content

Commit

Permalink
clean jsf-websocket.
Browse files Browse the repository at this point in the history
  • Loading branch information
hantsy committed Oct 3, 2017
1 parent a80e0ba commit 3154ebc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,27 @@ public class AjaxBean implements Serializable {
private List<String> messages = new ArrayList<>();

public void ajaxPushed(AjaxBehaviorEvent e) throws AbortProcessingException{
LOG.log(Level.INFO, "ajax pushed: " + e.toString());

LOG.log(Level.INFO, "ajax pushed: " + e.toString());
messages.add("ajaxListenerEvent is sent at: " + LocalDateTime.now());

ajaxListenerChannel.send("ajaxListenerEvent");
}

public void commandScriptExecuted() {
LOG.log(Level.INFO, "commandScriptExecuted pushed.");

messages.add("commandScriptExecuted message is sent at: " + LocalDateTime.now());

commandScriptChannel.send("onCommandScript");
}

public void sendMessage() {
// LOG.log(Level.INFO, "ajax pushed by button: " + e.toString());

messages.add("ajaxEvent is sent at: " + LocalDateTime.now());

public void pushToAjaxChannel() {
messages.add("ajaxEvent is sent at: " + LocalDateTime.now());
ajaxChannel.send("ajaxEvent");
}

public void pushToAjaxListenerChannel(){
ajaxListenerChannel.send("ajaxListenerEvent");
}

public void pushToCommandScriptChannel() {
commandScriptChannel.send("onCommandScript");
}

public List<String> getMessages() {
return messages;
Expand Down
18 changes: 15 additions & 3 deletions jsf-websocket/src/main/webapp/ajax.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,21 @@

<h:form id="form">
<h:commandButton
id="sendMessage"
action="#{ajaxBean.sendMessage()}"
value="Send Ajax Message">
id="pushToAjaxChannel"
action="#{ajaxBean.pushToAjaxChannel()}"
value="pushToAjaxChannel">
<f:ajax/>
</h:commandButton>
<h:commandButton
id="pushToAjaxListenerChannel"
action="#{ajaxBean.pushToAjaxListenerChannel()}"
value="pushToAjaxListenerChannel">
<f:ajax/>
</h:commandButton>
<h:commandButton
id="pushToCommandScriptChannel"
action="#{ajaxBean.pushToCommandScriptChannel()}"
value="pushToCommandScriptChannel">
<f:ajax/>
</h:commandButton>
</h:form>
Expand Down

0 comments on commit 3154ebc

Please sign in to comment.