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; }  

Spring Task Example

pom.xml [code] <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.tugrulaslan</groupId> <artifactId>SpringScheduledTaskExample</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <name>SpringScheduledTaskExample</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <spring.version>3.1.2.RELEASE</spring.version> </properties> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> </project> [/code] batch.xml in src>java>resources [code] <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/task