Terminal commands are handled by a server side listener. "greet {text}" and "date" are sample commands.
<div class="card">
<h:form>
<p:focus for="terminal"/>
<p:terminal id="terminal" widgetVar="term" commandHandler="#{terminalBasicView.handleCommand}"
welcomeMessage="Welcome to PrimeFaces Terminal"/>
<p:commandButton type="button" value="Clear" icon="pi pi-trash" onclick="PF('term').clear()" styleClass="mt-3" />
</h:form>
</div>
@Named("terminalBasicView")
@ViewScoped
public class BasicView implements Serializable {
public String handleCommand(String command, String[] params) {
if ("greet".equals(command)) {
if (params.length > 0) {
return "Hello " + params[0];
}
else {
return "Hello Stranger";
}
}
else if ("date".equals(command)) {
return new Date().toString();
}
return command + " not found";
}
}