Java Reference
In-Depth Information
<h:form>
<h:panelGrid columns="2">
<h:outputLabel for="msgText" value="Enter Message
Text:"/>
<h:inputText id="msgText"
value="#{jmsMessageModel.msgText}"/>
<h:panelGroup/>
<h:commandButton value="Submit"
action="#{jmsMessageController.sendMsg()}"/>
</h:panelGrid>
</h:form>
</h:body>
</html>
The
<h:inputText>
tag binds user input to the
msgText
variable of
JMSMessageModel
via its Unified Expression Language value binding
expression (
#{jmsMessageModel.msgText}
).
As is evident from the value of its
action
attribute, the
<h:commandButton>
tag passes control to the
sendMsg()
method of
JmsMessageController
when the user clicks on the rendered button. As we discussed in the chapter,
JmsMessageController.sendMsg()
takes the value of
JmsMessageModel.msgText
and puts it in a message queue. The
JmsMessageController.sendMsg()
method
also directs the user to a simple confirmation page. The code is as follows:
<?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">
<h:head>
<title>JMS message sent</title>
</h:head>
<h:body>
JMS message sent successfully.
</h:body>
</html>
As we can see, the confirmation page for our example is very simple. It simply
displays the message
JMS message sent successfully
on the browser.
Now that we are done producing a message and placing it in a JMS queue, we will
see how to develop code that will retrieve the message from the queue.