How to call facade from the command - websphere-7

In IBM WebSphere Commerce How the facade can be called from the command Instead of calling it from jsp. we call it from jsp like
<wcf:getData type="com.ibm.commerce.catalog.facade.datatypes.CatalogNavigationViewType" var="catalogNavigationView"
expressionBuilder="${navigationView}" varShowVerb="showCatalogNavigationView"
maxItems="${pageSize}" recordSetStartNumber="${WCParam.beginIndex}">
<wcf:param name="searchProfile" value="${searchProfile}" />
<wcf:param name="searchTerm" value="${newSearchTerm}" />
<wcf:param name="intentSearchTerm" value="${intentSearchTerm}" />
<wcf:param name="searchType" value="${searchType}" />
<wcf:param name="searchSource" value="${WCParam.searchSource}" />
<wcf:param name="metaData" value="${WCParam.metaData}" />
<wcf:param name="orderBy" value="${WCParam.orderBy}" />
<c:forEach var="facetValue" items="${param.facet}">
<c:if test="${fn:contains(facetValue , '|')}">
<c:set var="facetValue" value="${fn:replace(facetValue,'|',',')}"/>
</c:if>
<wcf:param name="facet" value="${facetValue}" />
</c:forEach>
<wcf:param name="advancedFacetList" value="${newAdvancedFacetList}"/>
<wcf:param name="categoryId" value="${currentCategoryId}" />
<wcf:param name="filterTerm" value="${newFilterTerm}" />
<wcf:param name="filterType" value="${WCParam.filterType}" />
<wcf:param name="filterFacet" value="${removeFacet}" />
<wcf:param name="manufacturer" value="${newManufacturer}" />
<wcf:param name="minPrice" value="${WCParam.minPrice}" />
<wcf:param name="maxPrice" value="${WCParam.maxPrice}" />
<wcf:contextData name="storeId" data="${WCParam.storeId}" />
<wcf:contextData name="catalogId" data="${WCParam.catalogId}" />
</wcf:getData>
This is how we can call it from jsp but I want to call this facade from the command (from the java code)
Please give me any suggestion
Thanks
Ankit

You can do it like this :
public someMethod(){
....
CatalogFacadeClient catalogFacadeClient = new CatalogFacadeClient(getBusinessContextType(), null);
GetType getVerb = CatalogFacadeClient.createGetVerb("_wcf:XPath", getXPathExpressionString());
ShowCatalogNavigationViewDataAreaType showDataArea = catalogFacadeClient.getCatalogNavigationView(getVerb);
response = showDataArea.getCatalogNavigationView();
....
}
public String getXPathExpressionString() {
StringBuffer expression = new StringBuffer();
expression.append("{_wcf.ap='IBM_Store_CatalogEntrySearch';");
expression.append("_wcf.search.term='" + toto+ "';");
expression.append("_wcf.search.spellcheck='false';");
expression.append("_wcf.search.type='1000';");
expression.append("_wcf.search.source='Q'}");
expression.append("/CatalogNavigationView");
return expression.toString();
}
protected BusinessContextType getBusinessContextType() {
BusinessContextType businessContext = CommerceFoundationFactory.eINSTANCE.createBusinessContextType();
ContextDataType storeId = CommerceFoundationFactory.eINSTANCE.createContextDataType();
storeId.setName("storeId");
storeId.setValue(currentStoreId);
ContextDataType catalogId = CommerceFoundationFactory.eINSTANCE.createContextDataType();
catalogId.setName("catalogId");
catalogId.setValue(currentCatalogId);
ContextDataType langIdContext = CommerceFoundationFactory.eINSTANCE.createContextDataType();
langIdContext.setName("langId");
langIdContext.setValue(langId.toString());
businessContext.getContextData().add(storeId);
businessContext.getContextData().add(catalogId);
businessContext.getContextData().add(langIdContext);
return businessContext;
}

Your code works!! Thank you so much!
Some Remarks about getXPathExpressionString() method:
1.- In order to prepare the expression builder correctly please check get-data-config.xml and get the expression builder by name. Name is the expressionBuilder param in wcf:getData
expressionBuilder="${navigationView}"
<wcf:getData type="com.ibm.commerce.catalog.facade.datatypes.CatalogNavigationViewType" var="catalogNavigationView"
expressionBuilder="${navigationView}" varShowVerb="showCatalogNavigationView"
maxItems="${pageSize}" recordSetStartNumber="${WCParam.beginIndex}">
Value of ${navigationView} is = "getCatalogNavigationView"
Search this value in get-data-config.xml file and look like this:
<expression-builder>
<name>getCatalogNavigationView</name>
<data-type-name>CatalogNavigationView</data-type-name>
<expression-template>{_wcf.ap='$accessProfile$';_wcf.search.profile='$searchProfile$';_wcf.search.facet.field.limit='$facetLimit$';_wcf.search.term='$searchTerm$';_wcf.search.intent.term='$intentSearchTerm$';_wcf.search.originalterm='$originalSearchTerm$';_wcf.search.category='$categoryId$';_wcf.search.type='$searchType$';_wcf.search.exclude.term='$filterTerm$';_wcf.search.exclude.type='$filterType$';_wcf.search.manufacturer='$manufacturer$';_wcf.search.price.minimum='$minPrice$';_wcf.search.price.maximum='$maxPrice$';_wcf.search.facet='$facet$';_wcf.search.advanced.facet='$advancedFacetList$';_wcf.search.exclude.facet='$filterFacet$';_wcf.search.sort='$orderBy$';_wcf.search.meta='$metaData$';_wcf.search.source='$searchSource$';_wcf.search.store='$physicalStoreIds$'}/CatalogNavigationView</expression-template>
<param>
<name>accessProfile</name>
<value>IBM_Store_CatalogEntrySearch</value>
</param>
<param>
<name>searchType</name>
<value>0</value>
</param>
<param>
<name>searchSource</name>
<value>O</value>
</param>
<param>
<name>searchProfile</name>
<value>IBM_findCatalogEntryByNameAndShortDescription</value>
</param>
</expression-builder>
source: http://158.85.49.234/WEB-INF/config/com.ibm.commerce.catalog-fep/get-data-config.xml
So this tag : <expression-template> contains the treasure :), i.e the solr query expression.
2.- With this expression-template we could can create a correct expression:
public String getXPathExpressionString() throws JspException, AbstractBusinessObjectDocumentException {
String expressionTemplate = "{_wcf.ap='$accessProfile$';_wcf.search.profile='$searchProfile$';_wcf.search.category='$categoryId$';_wcf.search.type='$searchType$';_wcf.search.sort='$orderBy$';_wcf.search.source='$searchSource$';_wcf.search.facet='$facet$';_wcf.search.exclude.facet='$filterFacet$';_wcf.search.meta='$metaData$';_wcf.search.price.minimum='$minPrice$';_wcf.search.price.maximum='$maxPrice$'}/CatalogNavigationView";
ExpressionBuilderConfig expressionBuilderConfig = new ExpressionBuilderConfig();
expressionBuilderConfig.setName("getCatalogNavigationView");
expressionBuilderConfig.setDataTypeName("CatalogNavigationView");
expressionBuilderConfig.setExpressionLanguage("_wcf:XPath");
expressionBuilderConfig.setExpressionTemplate(expressionTemplate);
HashMap<String,String[]> parameters = new HashMap<String, String[]>();
parameters.put("accessProfile", new String[]{"IBM_Store_CatalogEntrySearch"});
parameters.put("searchProfile", new String[]{"IBM_findCatalogEntryByNameAndShortDescription"});
parameters.put("searchType", new String[]{"xyz"});
parameters.put("categoryId",new String[]{ "123"});
parameters.put("minPrice",new String[]{"0"});
ExpressionType expressionType = expressionBuilderConfig.buildExpression(parameters);
return expressionType.getValue();
}
-------------------------------*-------------------------------------
This can be used to convert websphere ecommerce in a back-end or service provider. With that we can stop using jsp, scriplets, dojo 1.5 and use whatever in front-end layer like current js frameworks.

Related

CLOB and int-jdbc:stored-proc-outbound-gateway

I'm trying to invoke a stored procedure using the following component:
int-jdbc:stored-proc-outbound-gateway
It works fine, it calls the procedure but I can't seem to be able to log the CLOB in a proper CLOB format.
I've tried the following xml:
<int-jdbc:stored-proc-outbound-gateway
id="auditGatewayProcedure" request-channel="auditGatewayInbound"
data-source="dataSource" stored-procedure-name="PKG_TEMP.PR_AUDIT"
return-value-required="false" ignore-column-meta-data="true">
<int-jdbc:sql-parameter-definition
name="IN_MSG_ID" />
<int-jdbc:sql-parameter-definition
name="IN_GUID" />
<int-jdbc:sql-parameter-definition
name="IN_CLOB" />
<int-jdbc:parameter name="IN_MSG_ID" expression="payload.msgId" />
<int-jdbc:parameter name="IN_CLOB" expression="payload.xmlPayload" />
<int-jdbc:parameter name="IN_GUID" expression="payload.guid" />
</int-jdbc:stored-proc-outbound-gateway>
With that in mind, I'm passing the following payload (with the proper getters and setters):
private long id;
private String msgId;
private Clob xmlPayload;
private String guid;
The CLOB is of type: java.sql.Clob
The procedure I'm calling is this simple stuff:
procedure PR_BRIDGE_AUDIT(in_msg_id IN varchar2,
in_guid IN varchar2,
in_clob IN Clob) is begin
insert into tb_temp_all_messages(id,msg_id,xml_payload,guid) values (TB_TEMP_ALL_MESSAGES_SEQ.NEXTVAL,in_msg_id, in_clob, in_guid);
end;
What happens is that the clob column is inserted with the following value:
org.hibernate.lob.SerializableClob#186fdd6
The second try I did was forcing the type in the spring component, like this:
<int-jdbc:sql-parameter-definition
name="IN_CLOB" type="CLOB"/>
But the following exception is thrown: java.lang.ClassCastException: org.hibernate.lob.SerializableClob cannot be cast to oracle.sql.CLOB
Am I doing something wrong?
I tried to google it but nothing of value (as far as I saw) appeared.
Thanks in advance!
UPDATE
So, after some tries and the answer from Artem, the solutions are two, it seems:
given this XML:
<int-jdbc:stored-proc-outbound-gateway
id="auditGatewayProcedure" request-channel="auditGatewayInbound"
data-source="dataSource" stored-procedure-name="PKG_TGT_BRIDGE.PR_BRIDGE_AUDIT"
return-value-required="false" ignore-column-meta-data="true">
<int-jdbc:sql-parameter-definition
name="IN_MSG_ID" />
<int-jdbc:sql-parameter-definition
name="IN_GUID" />
<int-jdbc:sql-parameter-definition
name="IN_CLOB" type="CLOB"/>
<int-jdbc:parameter name="IN_MSG_ID" expression="payload.msgId" />
<int-jdbc:parameter name="IN_CLOB" expression="payload.stringClob" />
<int-jdbc:parameter name="IN_GUID" expression="payload.guid" />
</int-jdbc:stored-proc-outbound-gateway>
In the EEM class you can either pass a string containing the Clob (stringClob).
Or create a properly oracle.sql.CLOB type with what has been said by Artem and pass into the IN_CLOB parameter the oracle.sql.CLOB created.
Hope this helped,
Thanks
The issue that you really must create oracle.sql.CLOB yourself and within the same transaction as for that <int-jdbc:stored-proc-outbound-gateway>.
The code to create a CLOB may look like:
public CLOB convertToClob(String value) {
CLOB c = CLOB.createTemporary(getNativeConnection(), false, CLOB.DURATION_SESSION);
c.setString(1L, value);
return c;
}
private Connection getNativeConnection() {
return DataSourceUtils.getConnection(this.dataSource).getMetaData().getConnection();
}

Incorrect / redundant where clause

I'm not the best a Linq and I have written the below query and it just seems my where clause is redundant and there has to be a better way?
Given the following XML structure:
<Views>
<Fulfillment>
<SecurityRoleName>ABCD</SecurityRoleName>
<SecurityRoleViews>
<RoleView name="A" />
<RoleView name="B" />
<RoleView name="C" />
<RoleView name="D" />
<RoleView name="E" />
<RoleView name="F" />
</SecurityRoleViews>
<PublicRoleViews>
<RoleView name="Z" />
<RoleView name="Y" />
<RoleView name="X" />
<RoleView name="W" />
<RoleView name="V" />
<RoleView name="U" />
</PublicRoleViews>
</Fulfillment>
</Views>
I wrote the following to get a single value (FulfillmentRoleName) and two List (SecuredViews, PublicViews) objects.
FulfillmentRoleName = configParms.Descendants("Fulfillment")
.Where(node => (string)node.Element("SecurityRoleName") == "SecurityRoleName")
.Select(node => node.Value.ToString())
.First();
SecuredViews = configParms.Descendants("SecurityRoleViews")
.Where(node => (string)node.Element("RoleView") == "RoleView")
.Select(node => node.Attribute("name").Value.ToString())
.ToList();
PublicViews = configParms.Descendants("PublicRoleViews")
.Where(node => (string)node.Element("RoleView") == "RoleView")
.Select(node => node.Attribute("name").Value.ToString())
.ToList();
I would want the following values:
FulfillmentRoleName = ABCD
SecuredViews = List of names A,B,C...
PublicViews = List of names Z,Y,X....
It is the where clause that I am unsure of:
.Where(node => (string)node.Element("RoleView") == "RoleView")
Seems there has to be a more elegant way to locate that node?
Thank you for taking the time to help
As per Ahmad Mageed recommendation I am using the more elegant Element("") approach. However I am getting an instantiation error...as if the element collection is not built yet??
However if I use configParms.Root.Value I get my SecurityRoleName value???
I would have thought that views would be the root....or is it the first node that has a value???
You can use the Elements method and provide the name to match. This would allow you to replace the where query with Elements("RoleView").
Some other observations:
You can simplify the first query by grabbing the "Fulfillment" element directly by using the Element method, instead of Descendants.
The Value property returns a string. The ToString() calls are redundant.
Here's an updated version of your queries:
// if configParms is an XDocument use configParms.Root
var securityRoleName = configParms.Element("Fulfillment")
.Element("SecurityRoleName").Value;
var securedViews = configParms.Descendants("SecurityRoleViews")
.Elements("RoleView")
.Select(node => node.Attribute("name").Value)
.ToList();
var publicViews = configParms.Descendants("PublicRoleViews")
.Elements("RoleView")
.Select(node => node.Attribute("name").Value)
.ToList();

Issue with f:setPropertyActionListener and h:dataTable

I am trying to pass two parameters i.e. (nomComposantARejouer, typeFileARejouer) to an action method (gestionnaireMessagesController.rejouerMessage) using the setPropertyActionListener (we use jsf 1.2).
Here is the relevant jsp code:
<h:column>
<h:columnHeaderFacet>
<h:columnHeader value="#{msgs['pilotage.coordinateur.libelle.rejouer']}" />
</h:columnHeaderFacet>
<h:commandLink id="rejouer"
value="#{msgs['pilotage.coordinateur.libelle.rejouer']}"
action="#{gestionnaireMessagesController.rejouerMessage}">
<f:setPropertyActionListener
target="#{gestionnaireMessagesController.nomComposantARejouer}"
value="#{gestionnaireMessagesController.nomComposant}" />
<f:setPropertyActionListener
target="#{gestionnaireMessagesController.typeFileARejouer}"
value="#{gestionnaireMessagesController.typeFile}" />
</h:commandLink>
</h:column>
However, I always get a NPE because both parameters are null when used in the action method:
public String rejouerMessage() {
log.debug("-->"+nomComposantARejouer);//null
ParamResultatMessagesDTO message= (ParamResultatMessagesDTO) messagesTableau.getRowData();
log.debug("MessageId: " + message.getMessageId());
try {
Pager p = Pager.getInstance();
ParamRejouerMessageDTO prm = new ParamRejouerMessageDTO();
prm.setMessageId(message.getMessageId());
prm.setFileGet(nomsFilesMap.get(nomComposantARejouer).get(typeFileARejouer));
prm.setFilePut(nomsFilesMap.get(nomComposantARejouer).get("TASKQ"));
RejouerMessageService serv = (RejouerMessageService) this.getService(ServiceCst.REJOUER_MESSAGE_SERVICE);
serv.rejouerMessage(prm);
} catch (BusinessException e) {
this.addMessage(e);
} catch (ServiceException e) {
this.addMessage(e);
}
return chargerPage(); // TODO Navigation case.
}
I am not sure what I am getting wrong. Can anyone please help?
FYI, the variables nomComposant and typeFile can be displayed without problem and are not null.
Also ignore the h:columnHeaderFacet tags. They are inhouse tags that I've renamed.
You're basically doing:
gestionnaireMessagesController.setNomComposantARejouer(gestionnaireMessagesController.getNomComposant());
gestionnaireMessagesController.setTypeFileARejouer(gestionnaireMessagesController.getTypeFile());
during the invoke action phase of the form submit. Both properties are in the same bean instance and copied shortly before action method is invoked. This makes no sense. You seem to be expecting that the value is evaluated during the request of displaying the form. You seem to be thinking that <f:setPropertyActionListener> sets a request parameter. This is not true. The <f:param> is the only which does that.
So, this should do,
<f:param
name="nomComposantARejouer"
value="#{gestionnaireMessagesController.nomComposant}" />
<f:param
name="typeFileARejouer"
value="#{gestionnaireMessagesController.typeFile}" />
in combination with the following on <managed-bean> of gestionnaireMessagesController in faces-conig.xml:
<managed-property>
<property-name>nomComposantARejouer</property-name>
<value>#{param.nomComposantARejouer}</value>
</managed-property>
<managed-property>
<property-name>typeFileARejouer</property-name>
<value>#{param.typeFileARejouer}</value>
</managed-property>
(you can if necessary remove ARejouer so that it reuses the same property)
I have often encountered this problem , it occours when there are two f:setPropertyActionListener.
You try in this way:
<h:commandLink id="rejouer"
value="#{msgs['pilotage.coordinateur.libelle.rejouer']}"
action="#{gestionnaireMessagesController.rejouerMessage}"> <f:param
name="nomComposant"
value="#{gestionnaireMessagesController.nomComposant}" />
<f:param name="typeFile"
value="#{gestionnaireMessagesController.typeFile}" />
</h:commandLink>
Read this link: http://www.coderanch.com/t/211274/JSF/java/Passing-param-commandLink

How can I log to Special Folders with log4net?

How can I log to special folders (e.g. %APPDATA%) using the app.config file?
I can do it programmatically, but I need to be able to use the app.config file for configuration. I have seen a post of using %envFolderPath.It is not available in the latest released version, but only in their latest code.
Below is the code that I setting the log to special folders programmatically.
public void ExampleLog
{
XmlConfigurator.Configure();
var fileName = GetFileName();
var appender = new log4net.Appender.RollingFileAppender
{
Layout = new log4net.Layout.PatternLayout("%d - %m%n"),
File = fileName,
MaxSizeRollBackups = 10,
MaximumFileSize = "100MB",
AppendToFile = true,
Threshold = Level.Debug
};
appender.ActivateOptions();
BasicConfigurator.Configure(appender);
}
private static string GetFileName()
{
const string subPath = "MySubFolder";
var path = String.Format(#"{0}\{1}", Environment.GetFolderPath (Environment.SpecialFolder.CommonApplicationData), subPath);
const string logName = "Log.txt";
return Path.Combine(path, logName);
}
Pretty sure the syntax for this is available in the current release.
<file type="log4net.Util.PatternString" value="%env{APPDATA}\\MyApp\\Log.txt" />
If you need something more, you can look into option of subclassing the PatternString class, as described here: Log4Net can’t find %username property when I name the file in my appender
Check out the RollingFileAppender configuration sample on the log4net docs (for all the other parameters).
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="log.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="100KB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.SimpleLayout" />
</layout>
</appender>
I've referenced environment variables (including special folders) with the basic log4net variable format ${NAME}. And the file tag doesn't need to have the PatternLayout specified, it's implied.
<file value="${APPDATA}\log.txt" />

How to display my application's errors in JSF?

In my JSF/Facelets app, here's a simplified version of part of my form:
<h:form id="myform">
<h:inputSecret value="#{createNewPassword.newPassword1}" id="newPassword1" />
<h:message class="error" for="newPassword1" />
<h:inputSecret value="#{createNewPassword.newPassword2}" id="newPassword2" />
<h:message class="error" for="newPassword2" />
<h:commandButton value="Continue" action="#{createNewPassword.continueButton}" />
</h:form>
I'd like to be able to assign an error to a specific h:message tag based on something happening in the continueButton() method. Different errors need to be displayed for newPassword and newPassword2. A validator won't really work, because the method that will deliver results (from the DB) is run in the continueButton() method, and is too expensive to run twice.
I can't use the h:messages tag because the page has multiple places that I need to display different error messages. When I tried this, the page displayed duplicates of every message.
I tried this as a best guess, but no luck:
public Navigation continueButton() {
...
expensiveMethod();
if(...) {
FacesContext.getCurrentInstance().addMessage("newPassword", new FacesMessage("Error: Your password is NOT strong enough."));
}
}
What am I missing? Any help would be appreciated!
FacesContext.addMessage(String, FacesMessage) requires the component's clientId, not it's id. If you're wondering why, think about having a control as a child of a dataTable, stamping out different values with the same control for each row - it would be possible to have a different message printed for each row. The id is always the same; the clientId is unique per row.
So "myform:mybutton" is the correct value, but hard-coding this is ill-advised. A lookup would create less coupling between the view and the business logic and would be an approach that works in more restrictive environments like portlets.
<f:view>
<h:form>
<h:commandButton id="mybutton" value="click"
binding="#{showMessageAction.mybutton}"
action="#{showMessageAction.validatePassword}" />
<h:message for="mybutton" />
</h:form>
</f:view>
Managed bean logic:
/** Must be request scope for binding */
public class ShowMessageAction {
private UIComponent mybutton;
private boolean isOK = false;
public String validatePassword() {
if (isOK) {
return "ok";
}
else {
// invalid
FacesMessage message = new FacesMessage("Invalid password length");
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(mybutton.getClientId(context), message);
}
return null;
}
public void setMybutton(UIComponent mybutton) {
this.mybutton = mybutton;
}
public UIComponent getMybutton() {
return mybutton;
}
}
In case anyone was curious, I was able to figure this out based on all of your responses combined!
This is in the Facelet:
<h:form id="myform">
<h:inputSecret value="#{createNewPassword.newPassword1}" id="newPassword1" />
<h:message class="error" for="newPassword1" id="newPassword1Error" />
<h:inputSecret value="#{createNewPassword.newPassword2}" id="newPassword2" />
<h:message class="error" for="newPassword2" id="newPassword2Error" />
<h:commandButton value="Continue" action="#{createNewPassword.continueButton}" />
</h:form>
This is in the continueButton() method:
FacesContext.getCurrentInstance().addMessage("myForm:newPassword1", new FacesMessage(PASSWORDS_DONT_MATCH, PASSWORDS_DONT_MATCH));
And it works! Thanks for the help!
You also have to include the FormID in your call to addMessage().
FacesContext.getCurrentInstance().addMessage("myform:newPassword1", new FacesMessage("Error: Your password is NOT strong enough."));
This should do the trick.
Regards.
Remember that:
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage( null, new FacesMessage( "The message to display in client" ));
is also valid, because when null is specified as first parameter, it is applied to the whole form.
More info: coreservlets.com //Outdated
JSF is a beast. I may be missing something, but I used to solve similar problems by saving the desired message to a property of the bean, and then displaying the property via an outputText:
<h:outputText
value="#{CreateNewPasswordBean.errorMessage}"
render="#{CreateNewPasswordBean.errorMessage != null}" />
Found this while Googling. The second post makes a point about the different phases of JSF, which might be causing your error message to become lost. Also, try null in place of "newPassword" because you do not have any object with the id newPassword.
I tried this as a best guess, but no luck:
It looks right to me. Have you tried setting a message severity explicitly? Also I believe the ID needs to be the same as that of a component (i.e., you'd need to use newPassword1 or newPassword2, if those are your IDs, and not newPassword as you had in the example).
FacesContext.getCurrentInstance().addMessage("newPassword1",
new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error Message"));
Then use <h:message for="newPassword1" /> to display the error message on the JSF page.
Simple answer, if you don't need to bind it to a specific component...
Java:
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Authentication failed", null);
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, message);
XHTML:
<h:messages></h:messages>

Resources