JSF Input text placeholder

In the Tag description add the pt entry and its corresponding web address <html xmlns=”http://www.w3.org/1999/xhtml” xmlns:h=”http://java.sun.com/jsf/html” xmlns:pt=”http://xmlns.jcp.org/jsf/passthrough”> in the input text declaration <h:inputText styleClass=”form-control” pt:placeholder=”Enter Search Value” required=”true” requiredMessage=”Please enter search value” value=”#{orderController.keyword}” id=”keywordSearch”/>

JSF File Download

<h:commandLink action=”#{logController.downloadMessage}”> <h:outputText styleClass=”fa fa-fw fa-download”/> <f:setPropertyActionListener value=”#{log}” target=”#{logController.selectedLog}”/> </h:commandLink> public void downloadMessage() throws IOException { logger.info(“downloading the log file”); File file = new File(searchKeyword + “_log.txt”); FileUtils.writeStringToFile(file, selectedLog.getMessageContent(), Charset.defaultCharset()); FacesContext facesContext = FacesContext.getCurrentInstance(); HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse(); response.setHeader(“Content-Disposition”, “attachment;filename=” + file.getName()); response.setContentLength((int) file.length()); FileInputStream input = null; try { int i = 0;

JSF Primefaces Indicator

This example will show how to show a loader indicator while data is being fetch from the server. <h:panelGrid columns=”1″ id=”searchPanelGrid”> <h:panelGroup> <p:inputText id=”employeeId” placeholder=”Employee Id” required=”true” requiredMessage=”Employee Id is required” value=”#{createAdminController.employeeId}”/> <p:commandButton value=”Search in VCN” update=”ldapPanel @form” actionListener=”#{createAdminController.searchInVCN}” id=”searchButton”/> </h:panelGroup> </h:panelGrid> <p:blockUI block=”searchPanelGrid” trigger=”searchButton”> <h:graphicImage library=”images” name=”loader.gif”/> </p:blockUI>   https://www.primefaces.org/showcase/ui/misc/blockUI.xhtml http://ajaxload.info/ https://answers.axonivy.com/questions/14/how-to-create-a-loading-indicator-in-a-html-user-dialog/15

JSF Return Hostname and App name

private static HttpServletRequest request = (HttpServletRequest) FacesContext .getCurrentInstance().getExternalContext().getRequest(); static Logger logger = LoggerFactory.getLogger(JSFUtils.class); public static String getServerHost() { return “http://” + request.getServerName() + “:” + request.getServerPort(); } public static String getServerHostWithAppName(){ String url = null; try { url = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), request.getContextPath()).toString(); } catch (MalformedURLException e) { logger.error(e.toString()); } return url; }  

Enabling Fontawesome icons in Primefaces

I’ve tested this in the Primefaces 6.0 and JSF 2.2 configuration https://www.primefaces.org/showcase/ui/misc/fa.xhtml http://fontawesome.io/cheatsheet/ Before After web.xml   <context-param> <param-name>primefaces.FONT_AWESOME</param-name> <param-value>true</param-value> </context-param> <mime-mapping> <extension>woff2</extension> <mime-type>application/x-font-woff2</mime-type> </mime-mapping> jsf page   <p:column headerText=”Actions”> <p:commandButton type=”button” value=”Edit” icon=”fa fa-fw fa-edit”/> <p:commandButton type=”button” value=”Delete” icon=”fa fa-fw fa-remove”/> </p:column>  

JSF a closable div

In this sample I’ve achieved one of demanded tasks at work regarding a closable mobile app pane, when the site is visited on mobile devices This is a good example also to study how to pass and set values in the backbean. Because we know what JSF is more of action based although there are

JSF/Primefaces Multilingual calendar

At work in my current project the customer has delivered their immediate need in the Turkish translation. Our project is multilingual that support English and Turkish. I’ve conducted a research on how to implement a multiple language support on our project, first of all I’ve managed to find Primeface’s prior manual site being hosted on google,