Browsed by
Category: Java Server Faces

19 JSF Important Interview Questions

19 JSF Important Interview Questions

19 JSF Important Interview Questions: JSF(Java server faces) is component driven programming language which can be implemented with different faces like icefaces, acefaces, primefaces, richfaces etc. This can also be used with spring core and hibernate for ORM. Below are the few most important and repeated interview questions for JSF developers.   1. What are all the 6 phases of JSF Lifecycle ? 1. Restore view 2. Apply request values 3. Process validations 4. Update model values 5. Invoke application…

Read More Read More

584 total views, 1 views today

[solved] uioutput cannot be resolved to a type JSF

[solved] uioutput cannot be resolved to a type JSF

[solved] uioutput cannot be resolved to a type JSF: Error meaning is you did not import the UIOutput in your bean/controller. So you have to import the below UIOutput package, “import javax.faces.component.UIOutput;” to resolve the uioutput cannot be resolved to a type error/exception. If you are getting this exception in eclipse like in the below/similar line, String ajaxListValue = (String) ((UIOutput) event.getSource()).getValue(); then you need to put the cursor near UIOutput and enter the Ctrl+Space to get the auto import…

Read More Read More

596 total views, no views today

Icefaces user session expired popup

Icefaces user session expired popup

Icefaces user session expired popup: Icefaces user session expired popup issue has been resolved after adding the below entries in the deployment descriptors (web.xml), The below one will redirect you to the ERRORPAGE.jsp onclick of any button after session timeout, <context-param> <param-name>org.icefaces.sessionExpiredRedirectURI</param-name> <param-value>/ERRORPAGE.jsp</param-value> </context-param> But ensure you have added this entry too, <error-page> <exception-type>javax.faces.application.ViewExpiredException</exception-type> <location>/ERRORPAGE.jsp</location> </error-page> If you want to redirect to ERRORPAGE.jsp after the session timeout automatically, then have to add the below code to web.xml (deployment descriptor) <context-param>…

Read More Read More

616 total views, 1 views today

How to truncate td value in icefaces (jsf)

How to truncate td value in icefaces (jsf)

You can truncate the td value in jsf icefaces like this, You have to add “word-break:break-all” to your table style property. It will look like this, <ice:dataTable style=”word-break:break-all”> <ice:colomn style=”white-space:normal;”> </ice:column> </ice:dataTable> Ensure you have given the columnWidths property also to your datatable. Recommended Books: 544 total views, no views today

544 total views, no views today

Session Handling in Jsf Example

Session Handling in Jsf Example

JsfSession.java: package com.ngdeveloper.com; import javax.faces.FacesException; import javax.faces.application.Application; import javax.faces.application.ViewHandler; import javax.faces.component.UIViewRoot; import javax.faces.context.ExternalContext; import javax.faces.context.FacesContext; import javax.faces.event.PhaseEvent; import javax.faces.event.PhaseId; import javax.faces.event.PhaseListener; import javax.servlet.http.HttpSession; public class JsfSession implements PhaseListener { @Override public void afterPhase(PhaseEvent event) { //Do anything } @Override public void beforePhase(PhaseEvent event) { FacesContext context = event.getFacesContext(); ExternalContext ext = context.getExternalContext(); HttpSession session = (HttpSession) ext.getSession(false); boolean newSession = (session == null) || (session.isNew()); boolean postback = !ext.getRequestParameterMap().isEmpty(); boolean timedout = postback && newSession; if (timedout) { Application app…

Read More Read More

1,189 total views, no views today

Iceface datatable column width adjustment

Iceface datatable column width adjustment

Solution for iceface datatable column width adjustment: You may face the issue while setting the iceface datatable column width adjustments. This can be achieved by the below way,   Use style=”table-layout:fixed;” in the ice:column and ensure you have set the columnwidths already for all the columns. eg: <ice:column style=”table-layout:fixed;” columnwidths=”350px,490px”>   700 total views, no views today

700 total views, no views today

jQuery Show/Hide Example in Jsf

jQuery Show/Hide Example in Jsf

jQuery Show/Hide Example in Jsf: Program: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"> <h:head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"> </script> <script> $(document).ready(function() { $("#content").hide(); $("#show_button").click(function() { $("#content").show(); }); $("#hide_button").click(function() { $("#content").hide(); }); }); </script> </h:head> <h:body> <h:commandButton value="show" id="show_button" /> <h:commandButton value="hide" id="hide_button" /> <div id="content">Welcome to Javadomain.in</div> </h:body> </html> Output:   Recommended Books: 673 total views, no views today

673 total views, no views today

Dynamically add/remove jsf components example

Dynamically add/remove jsf components example

Program:   dynamic.xhtml: <?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:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"> <h:head> </h:head> <h:body> <h:form> <h:dataTable value="#{dynBean.dynList}" var="myListElement"> <h:column> <h:panelGrid> <h:outputText value="www.ngdeveloper.com"></h:outputText> </h:panelGrid> </h:column> </h:dataTable> <h:commandButton value="Add" action="#{dynBean.addToMyList}" /> <h:commandButton value="Remove" action="#{dynBean.removeFromMyList}" /> </h:form> </h:body> </html> DynamicBean.java: import java.io.Serializable; import java.util.ArrayList; import java.util.List; import javax.faces.bean.CustomScoped; import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; import javax.faces.bean.ViewScoped; @ManagedBean(name = "dynBean") @ViewScoped @SessionScoped public class DynamicBean implements Serializable { /** * */ private static final long serialVersionUID = 1L; private…

Read More Read More

1,562 total views, 1 views today

Ice Panel Popup Examples

Ice Panel Popup Examples

In JSF, those who are using Ice components if they need popup they can go with Ice panel Popups. Ice Panel Popup : <?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://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:ace="http://www.icefaces.org/icefaces/components" xmlns:ice="http://www.icesoft.com/icefaces/component" xmlns:ui="http://java.sun.com/jsf/facelets"> <h:head> </h:head> <h:body> <h:form> <h:commandButton value="Click to open Ice Panl Popup" actionListener="#{icePopupBean.openPopup}" /> <ice:panelPopup visible="#{icePopupBean.popupOpened}" rendered="#{icePopupBean.popupOpened}" autoCentre="true"> <f:facet name="header"> <ice:panelGroup style="text-align:right;"> <h:commandButton image="resources/images/closeB.jpg" alt="Close" title="Close" style="height: 20px; width: 20px; border: 0;" actionListener="#{icePopupBean.closePopup}" /> </ice:panelGroup> </f:facet> <f:facet name="body"> <ice:panelGroup>…

Read More Read More

974 total views, no views today

[solved] diff propagated to root but no id set html null

[solved] diff propagated to root but no id set html null

diff propagated to root but no id set html null: Error: diff propagated to root but no id set html null Solution: Use <redirect/> in the faces-config file. Try to put h:panelGroup inside body (this error may occur if we use the ice components directly inside the body) – so it can be avoided if we use the ice components inside h:panelGroup. Recommended Books: 992 total views, no views today

992 total views, no views today