FAQ Database Discussion Community


JSF Controller, Service and DAO

jsf,java-ee,jpa,ejb,dao
I'm trying to get used to how JSF works with regards to accessing data (coming from a spring background) I'm creating a simple example that maintains a list of users, I have something like <h:dataTable value="#{userListController.userList}" var="u"> <h:column>#{u.userId}</h:column> <h:column>#{u.userName}</h:column> </h:dataTable> Then the "controller" has something like @Named(value = "userListController") @SessionScoped...

How to prevent JSF from initializing automatically?

jsf,tomcat,mojarra
When I create a web application from scratch and add jsf-api-2.2.11.jar and jsf-impl-2.2.11.jar to pom.xml (add them to apps classpath) and deploy it to Tomcat 7, JSf is initializing automatically: INFO [j.e.r.w.j.config] - Mojarra 2.2.11 ( 20150505-0732 https:[email protected]) ..... initialized. In older versions I used to start it declarativly by...

java.util.ServiceConfigurationError when running tests using arquillian+omnifaces

java,jsf,jboss-arquillian,omnifaces
I am getting the following error "java.util.ServiceConfigurationError: javax.servlet.ServletContainerInitializer: Provider org.omnifaces.ApplicationInitializer not found" when running Arquillian tests. I have put the most basic test case I could here: https://www.dropbox.com/s/kou5v8kqs5g4g4m/test.zip?dl=0...

Ajax update of datatable from a modal after filtering

ajax,jsf,primefaces,datatable
My question is very similar to this: Ajax update doesn't work, when using filter on datatable (JSF, Primefaces). I have a dataTable with an "Open" button (a commandButton) for each entry/row in the table, on click of which, a dialog will open. I have a form in the dialog that...

message always shown in the same language instead of configuring the browser not to

jsf,localization,faces-config
I am trying to show a welcoming message in a JSF page in different languages (English or Spanish) depending on the user's browser configuration. These are the steps I follow: 1-In Netbeans I create a WAR project 2-In the folder Source Packages I create a package named locale, and inside...

Embed JSF code in a xhtml

jsf,primefaces
I need to complete a xhtml page with some JSF code (with p:panel and p:datatables, etc.) from a managed bean, but I'm not sure that is possible. My attemps: 1º <h:outputText escape="true" value="#{controller.jsfString}"/> It's not be able to understand "p:" components, only simple html. 2º <ui:include src="#{controller.jsfString}"> It expects a...

Show image as byte[] from database as graphic image in JSF page

image,jsf,bytearray
I have image content as byte[] from database. private byte[] image; How can I show that byte array as a real graphic image in JSF page?...

Use JSF, JPA, JTA, JAAS, CDI, Bean Validation with Tomcat? [closed]

jsf,tomcat,jpa,cdi,jta
Is it possible to use the following APIs with tomcat (as a lightweight server): JSF, JPA, JTA, JAAS, CDI, Bean Validation. ...

Navigating to another page JSF

jsf,jsf-2
I wrote a jsf application, this app inserts the data into mysql database and shows some of the inserted details in another page. I am successful in inserting the values into database, but unable to redirect to the other page even after writing the navigation rule. My action code <div...

How to open an arbitrary URL in new window using a PrimeFaces button

jsf,primefaces
I have the below output link which does its job: <h:outputLink value="#{verDocumentoController.url()}" target="_blank"> show document </h:outputLink> It opens an URL obtained as a bean property in a new window. However, I'd like to turn the link into a button in PrimeFaces look'n'feel. I tried as below: <p:commandButton value="show document" action="#{verDocumentoController.url()}"...

Component rendering problems with primefaces in eclipse for JSF [duplicate]

jsf,jsf-2,primefaces
This question already has an answer here: JSF returns blank/unparsed page with plain/raw XHTML/XML/EL source instead of rendered HTML output 1 answer I'm trying to work on primefaces. when i am trying to run a xhtml page individually in my eclipse IDE, All the primeface elements included in my...

Change Label during AJAX call

jsf
I want to change the Label of a h:commandLink during AJAX call. <h:commandLink id="submitlink" class="link" value="submit" action="#{mailhandler.testValues}" > <f:ajax render="@form" execute="@form" onevent="handleDisableButton"/> </h:commandLink> JavaScript: function handleDisableButton(data) { document.getElementById("form:submitlink").disabled = (data.status != "success"); } I found examples how to do this using Button but in this case I don't know how...

h:selectmanyListbox make “choose” option unselectable when at least one option is selected

jsf,jsf-2,selectmanylistbox
Is it possible to have in <h:selectManyListbox> a default option like "--choose--" which can be selected when no option is selected. When the some value is chosen, then it must be unselectable. <h:selectManyListbox value="#{bean.value}" class="form-control"> <f:selectItems value="#{bean.dropdownValues}" var="value" itemLabel="#{value}" itemValue="#{value}"/> </h:selectManyListbox> ...

commandButton action method not invoked in Liferay

jsf,liferay,portlet
I've the below portlet view.xhtml: <?xml version="1.0"?> <f:view xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui"> <h:body> <h:form> <h:commandButton value="TESTButton" action="#{navigationViewBean.submit}" /> <h:outputText value="TESTGetter: #{navigationViewBean.testField}" /> </h:form>...

Using ui:repeat to iterate over columns

jsf,jsf-2
I'm in Mojarra 2.1.29. I tried to iterate over the collection to produce amount of rows equals to the size of the collection. Here what I've tried: <rich:dataTable id="table" var="partner" rows="10" value="#{testBean.k}"> <ui:repeat var="name" value="#{testBean.cols}"> <rich:column> <f:facet name="header"> <h:outputText value="#{name}"/> </f:facet> <h:outputText value="#{m.get(partner)}"/> <f:facet name="footer"> <h:outputText value="#{name}}"/> </f:facet> </rich:column>...

CommandButton execution while rendering

jsf,primefaces
Question: How can I prevent the execution of a while the website is rendering? Thats where my Button sits: <p:dialog widgetVar="newComment" height="200" width="500"> <h:form> <h:panelGrid> <h:outputText value="#{commentDialog.username}" /> <h:inputTextarea id="in_text" value="#{commentDialog.text}" /> <p:message for="in_text" /> </h:panelGrid> <p:commandButton validateClient="true" value="Abschicken" ajax="true" actionListener="#{popupRequestView.update}"...

RichFaces 4 ExtendedDataTable - Selecting rows programmatically

javascript,jsf,richfaces
Good evening. I've been asked to update a web app that was implemented in RichFaces. The application has a rich:extendedDataTable inside of a composite component that displays some searchable data. The update I've been asked to implement is to have the first row in the table automatically selected when a...

Double dispatching in jsf

jsf,jsf-2
Is it possible in Mojarra-2.1. If I do dispatching to another view from the action method by clicking action buttons: <h:commandButton value="dispatch" action="#{myBean.action()}" /> The bean: @ManagedBean @RequestScoped public class MyBean{ public String action(){ //do some return "view"; } } my browser then recieve the content of the view view....

Primefaces datatable duplicate “No records found” while doing column freeze for empty records

jsf,jsf-2,primefaces,datatable
I am using primefaces <p:datatable> to freeze some of my columns.Everything is fine but when there are no records in then it gives two "No records found" message.This is weird situation.Do anyone have come across this problem? Suggestions are welcome.I want only one "No records found " message. <p:dataTable var="car"...

Setting f:setPropertyActionListener value with a f:param value

jsf,jsf-2,param,setpropertyactionlistener
I'm trying to use the setPropertyActionListener tag to set a value in my backing bean. However, it doesn't work as I expected. Context: userService is an instance of my backing bean, which contains an int member, reqID. This, in turn, is the key to a map of objects that belong...

h:outputStylesheet inside ui:repeat

jsf,facelets,jsf-2.2,uirepeat,outputstylesheet
I'm trying to use to output a stylesheet link for every element of an ArrayList. This code produces no result: <ui:repeat value="#{includer.css}" var="ss"> <h:outputStylesheet name="#{ss}" library="css" /> </ui:repeat> However, if i change the Strings in the ArrayList to be full paths and replace h:outputStylesheet with plain html like : <ui:repeat...

Facelets error page works during ajax request with FullAjaxExceptionHandler, but does not evaluate EL during synchronous request

jsf,error-handling,web.xml,omnifaces
I am trying to configure a normal (non-ajax) request error page using Omnifaces library. I am able to use the FullAjaxExceptionHandler and with ajax request error and its page as shown in the demo. When I use the same error page with normal request the error page is shown, but...

selectonemenu, when editable=false, cannot submit the form

jsf,primefaces
My form is working if editable is set to true but not when it's false. When false the submit action method is not even called. I need it to be false (not editable so I can store the correct value in db). This is the menu I added. <tr><td> <h:outputLabel...

JSF Property not found exception. porperty not readable

jsf,cdi,el
can someone help out, I just don't get it, the other bean works fine, i'ts just that bean that sucks: BEAN: import java.io.Serializable; import java.util.List; import javax.enterprise.context.SessionScoped; import javax.inject.Named; @SessionScoped @Named class FeedbackController implements Serializable { private static final long serialVersionUID = 1L; private Lecture lecture; private List<Feedback> filteredFeedbacks; public...

java.lang.NoSuchMethodError: javax.faces.component.UIComponent.getPassThroughAttributes(Z)Ljava/util/Map; after migrating to JSF 2.2

jsf,migration,jsf-2.2,nosuchmethoderror
I am getting the below exception after migrating to JSF 2.2. Specifically, I'm upgrading Mojarra 2.1.17 to Mojarra 2.2.8. java.lang.NoSuchMethodError: javax.faces.component.UIComponent.getPassThroughAttributes(Z)Ljava/util/Map; at org.primefaces.renderkit.RendererUtils.renderPassThroughAttributes(RendererUtils.java:79) at org.primefaces.renderkit.CoreRenderer.renderDynamicPassThruAttributes(CoreRenderer.java:119) at org.primefaces.renderkit.CoreRenderer.renderPassThruAttributes(CoreRenderer.java:114) at...

Error occurred while convert the dataTable to excel. [duplicate]

excel,jsf,primefaces,datatable
This question already has an answer here: java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/RichTextString at org.primefaces.component.export.ExporterFactory.getExporterForType 2 answers I got these error message while click the export button in the sever. I can't convert that table. I used primeface 5.0 and netbeans 8.0.2 version and GlassFish server 4.1 How can i solve this problem?...

Manually added faces message doesn't appear in tab of accordion panel

jsf,message
I'm adding a faces message in an action method as below: FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_WARN, "Mail invalide", "Vérifier le mail"); FacesContext.getCurrentInstance().addMessage("connection:mail", message); I'm expecting it to show up at the below position in the tree: <h:body> <p:layout fullPage="true"> <p:layoutUnit position="center" > <p:accordionPanel multiple="true" activeIndex="0"> <p:tab title="Se connecter" > <h:form...

Execute onevent with values changed by listener

javascript,ajax,jsf
I have this code <h:commandLink> <f:ajax execute="@this" render=":organizerTable :organizerData :delete @form" onevent="deleteOrganizer" listener="#{organizercontroller.deletePossible}"/> <span id="minus" class="add-on glyphicon glyphicon-minus" aria-hidden="true"></span> </h:commandLink> When I click on the minus, the listener of the ajax tag should be executed before the onevent. Normally, it's the other way round. I tried this: function deleteOrganizer(data) {...

Validator regex pattern input accept only a number with 2-5 digits

regex,validation,jsf
I want to validate user's input data with a custom Validator in a JSF application. The data inserted must be a number between 2 and 5 digits. Facelet <h:inputText id="num1" label="num1" required="true" size="5" maxlength="5" styleClass="#{component.valid ? '' : 'validation-failed'}" value="#{sumaManagedBean.number1}" requiredMessage="You must enter a value"> <f:validator validatorId="validators.NumberValidator"/> </h:inputText> <h:message for="num1"...

JSF: Is there a way to bind method to h:outputLink?

jsf
I am working on something like this: A JSF template has a side-navigation bar which contains links(either anchor or h:outputLink), and there are cases where two options lead to the same link(page), but with a different value in view parameter, and thus rendering different data being displayed on the page....

dataTable doesn't show list [duplicate]

postgresql,jsf,datatable
This question already has an answer here: When should I load the collection from database for h:dataTable 1 answer I'm trying to render a list of products in a .xhtml page, from my database in Postgres: i'm using the JSF tag h:dataTable. Unfortunately, when I display the page, I...

Get to specific book using hyperlink in JSF [duplicate]

jsf,jsf-2
This question already has an answer here: Creating master-detail pages for entities, how to link them and which bean scope to choose 1 answer I have a very strange situation here. I have made my application in JSF and it looks just great, however I am not quite sure...

Is there a way to get the Base URL from an Application-scoped bean in JSF?

jsf,servlets,jsf-2
In my JSF Facelets pages I know I can just use #{request.requestURL} To get the full URL to build exportable links and the like. However I have an @ApplicationScoped bean where I need the base URL (i.e. "http://dnsname/app") for the purposes of reports and other data. Is there a standard...

How can I load a resource bundle properties file within a composite component?

jsf,composite-component,resourcebundle,properties-file
My component library directory tree is setup as the following: resources mylib css mycomponent.css properties mycomponent.properties mycomponent.xhtml I'd like to load the properties file within mycomponent.xhtml to use for messages. What is the proper way of doing this? Is there an f:loadbundle type of solution?...

how stick out a menu when clicking on a menu [on hold]

css,jsf,primefaces
I have a type of menu created in JSF. <p:menubar styleClass="menuPrincipal" id="menuBar" > <p:menuitem value="Inicio" url="/Inicio.xhtml" style="text-decoration:none" icon="ui-icon-home" id="inicio" /> <p:menuitem value="Agregar Excepciones" id="agregarExcepcion" url="/ExcepcionNuevo.xhtml" style="text-decoration:none" rendered='#{excepcionPendienteView.usuarioActual.tipoSolicitante eq "Administrador"}' /> </p:menubar> I want that when you click on a menu, highlight the option me where I am working. if I...

How can I selectall visible rows in an icefaces ace:datatable?

jsf,datatable,icefaces
It doesn't look like the ace:datatable component has a selectall/deselectall functionality...unless you shift+click on the table directly. I DON'T want to perform an ajax submit and modify the RowStateMap because: a) I'd rather not do any submits until the form submission b) RowStateMap.setAllSelected() selects ALL rows in the table regardless...

Ajax Rerender working for selectOneMenu, but not input text

jsf,richfaces
I'm a bit out of my element here, but I have two panelGroups, one that contains an input field of type text: <input type="text" value="#{myBean.value}" id="myId" > <a4j:support event="onchange" reRender="divToRerender" oncomplete="jsFunction()"/> </input> and another that contains a selectOneMenu: <h:selectOneMenu value="#{bean.value}" id="myId" > <f:selectItems value="#{myBean.options}" /> <a4j:support event="onchange" reRender="divToRerender" oncomplete="jsFunction()"/> </h:selectOneMenu>...

How to click on a p:commandButton using javascript [duplicate]

javascript,jsf,callback,commandbutton
This question already has an answer here: How to select JSF components using jQuery? 2 answers There are many tag in my JSF page.I want to click a p:commandButton using javascript in one of the forms. But it doesn't work. When I debug it use chrome ,it prompt The...

Render hidden elements using JSF and AJAX

ajax,jsf,jsf-2.2
I've been facing some problems using JSF with AJAX to render a table without reloading the whole page every time I submit a form. When I first run the server, my database is empty, so the page is supposed to show only a form to add books. When user submits...

Access particular row of p:datatable in Backing Bean on click of h:CommandLink without binding attribute

jsf,jsf-2,primefaces,datatable
Please find my code below for p:datatable having h:commandlink as one of its column: <p:dataTable id="listTable" value="#{listBean.lazyDatalist}" var="list" paginator="true" paginatorPosition="top" rows="10" rowIndexVar="rowIndex" rowStyleClass="#{(rowIndex mod 2) eq 0 ? 'rowStyleOdd' : 'rowStyleEven'}" lazy="true"> <p:ajax event="page" listener="#{listBean.searchLazyData}"/> <p:column style="width:3%;" headerText="#{msg['userlist.dt.srNo']}"> <h:outputText value="#{list.orderCount}"></h:outputText>...

Creating command links dynamically from a managed bean

jsf
I have a need to create command links dynamically based on content coming from elsewhere. When a user clicks on a link it should call a method in a managed bean, and the method needs to know which link was clicked. I can create the command links using the following...

How to use line chart extender attribute in primefaces 5.2

javascript,jsf,primefaces,xhtml,jqplot
I'm using primefaces 5.2 latest version and tried for line chart,its working fine. Am trying to change the line chart axes color,background,border...etc.but extender attribute is not working in latest primefaces version. My XHTML: <p:chart type="line" model="#{chartViewLine.lineModel1}" styleClass="legendpos" extender="chartExtender" style="height:300px; width:570px;"/> JAVASCRIPT: function chartExtender() { this.cfg.grid = { background: 'transparent', gridLineColor:...

How to declare the backing bean's name only once in a JSF facelet?

java,jsf
After spending 2 hours debugging my webapp (JSF facelets with Primfaces and JSF ManagedBeans) it turned out that I missspelled the name of the backing bean (with a lengthy name) in one dataTable (unfortunately, I did not get any error message, there was just no data showing up in the...

javax.el.PropertyNotWritableException when using EL conditional operator in value of UIInput

jsf,input,el,placeholder,conditional-operator
I get this error message: javax.el.PropertyNotWritableException: /u/editProfile.xhtml @64,140 value="#{empty userProfile.cfg.gpu or userProfile.cfg.gpu == '' ? usernavmsg.EditMe: userProfile.cfg.gpu}": null The problem is that when the value of a bean property is null the value of an inputText field switches from my ManagedBean property, to a resource string. So I cannot persist...

File upload via h:inputfile (prettyfaces) does not work

jsf,file-upload,glassfish,jsf-2.2,prettyfaces
I'm trying to upload a file to the glassfish application server (v4.1) via h:inputfile. xhtml-file and bean are prepared as almost every example in the web shows. I tried with and without Pretty Filter in web.xml, allowCasualMultipartParsing in context.xml, and a handful of other possible workarounds. None of them seemed...

primefaces treetable expand not working if jsf page location is changed

spring,jsf,spring-mvc,jsf-2,primefaces
Primefaces treetable expands if my xhtml webpage is in WebContent Folder but it doesn't expand if I move the same webpage to WEB-INF/views/jsf folder. I'm very new to JSF and I don't know where and what to change. If my webpage is in WEB-INF/views/jsf folder only the root node is...

How to define a style for ul which appears automatically [duplicate]

css,jsf
This question already has an answer here: How to use JSF generated HTML element ID with colon “:” in CSS selectors? 2 answers My xhtml page contains the code <h:form id="stackForm"> <p:orderList id="stack"> ... </p:orderList> </<h:form> It generates the html <form id="stackForm"> <table id="stackForm:stack"> <ul class="ui-widget-content ui-orderlist-list ui-corner-all ui-sortable"><li>...</li></ul>...

Primefaces validation not working

jsf,jsf-2,primefaces
I am working on a form, where i am using primefaces. When i validate an inputtext, then ajax message is working for only for field and not for the others, please, check my code below. <?xml version="1.0" encoding="ISO-8859-1" ?> <!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"...

Portlet IPC after recieved Event

jsf,events,event-handling,ipc,portlet
I have a Navigation portlet which schows all Students, when a Student gets clicked im sending a event with the id of the clicked student to other portlets. Sending and receiving the event is not the problem, that works fine. What i don't get, is how to proceed with the...

JSF Validators do not work if Random or SecureRandom used to generate component ID

jsf,jsf-2.2,mojarra,programmatically-created
When I use UUID#randomUUID() (which uses SecureRandom) or RandomStringUtils#randomAlphabetic(int) (which uses Random) to generate component ID for HtmlInputText validation stops working. If instead I set the component ID using an arbitrary hard-coded String (e.g. "C5d682a6f") the validation works as expected. Here's the code: import org.apache.commons.lang3.RandomStringUtils; import java.util.UUID; import javax.faces.component.html.HtmlInputText; import...

How to get a Http Session while a servlet is being initialised? [duplicate]

jsf,servlets,lifecycle,httpsession
This question already has an answer here: How do servlets work? Instantiation, session variables and multithreading 6 answers we can get the session if we can access to HTTP request object like below: HttpSession session = request.getSession(); But, How to retrieve the HTTP session inside init method of Servlet...

JSF facets not available in Eclipse

java,eclipse,jsf,facets
So I am watching a tutorial about how to configure JSF in eclipse. I understand that you click file -> new -> Dynamic Web Project. And then it gives you a few options. The Target Runtime will be (for me) Apache Tomcat version 8, and dynamic web module version will...

p:orderList converter getAsObject() doesn't call Object.toString()

jsf,primefaces,converter
I've written a custom converter as follows: @FacesConverter(value = "orderListConverter") public class OrderListConverter implements Converter { @Override public Object getAsObject(FacesContext context, UIComponent component, String value) { Object ret = null; if (component instanceof OrderList) { Object list = ((OrderList) component).getValue(); ArrayList<ExampleEntity> al = (ArrayList<ExampleEntity>) list; for (Object o : al)...

h:commandButton action method is not invoked [duplicate]

jsf,jsf-2.2
This question already has an answer here: commandLink/commandButton/ajax backing bean action/listener method not invoked 7 answers I have the below button: <h:commandButton value="Download" action="#{listFiles.downloadFile}" /> And the below action method: public void downloadFile() { // Some code. } But when I press the button nothing happens. The action method...

Change value of checkbox using ajax in JSF

ajax,jsf,facelets
I try to solve the following problem: i have a group of h:selectBooleanCheckbox that generates using ui:repeat: <h:form> <ui:repeat value="#{uiCheckboxList.list}" var="boxElement" varStatus="i"> <h:selectBooleanCheckbox id="a"> <f:attribute name="value" value="#{boxElement.enabled}"/> </h:selectBooleanCheckbox> <h:outputLabel value="#{boxElement.val}" for="a"/> </ui:repeat> </h:form> Values and label's text stored in array list and controls by servlet: @ManagedBean(name="uiCheckboxList")...

Refresh selection model of p:datatable on row deselection

jsf,primefaces,datatable,selection
I have a problem with the selection model of a Primefaces 5.0 datatable. This selection model does not process deselection properly: Selection of rows adds these roles as expected to the list of selected rows. But a deselection has no influence on this list; deselected rows remains in it. Only...

@FacesComponent on shared library

jsf,java-ee,websphere,jsf-2.2
I'm trying to use a custom jsf component on Websphere 8.5. The component class is annotated with @FacesComponent. The component is on a shared lib jar on the server. I already have an faces-config inside the jar META-INF folder. If the jar is inside my ear file it works as...

FacesContext#getViewRoot() returns null while setting for first time

jsf,locale,jsf-2.2,mojarra
I am trying to change my JSF application locale in one page and that has to change all my pages locale. I have followed this link, and it works well JSF locale is set per request/view, not for session If I run the application I can change the locale in...

Override rendering with a custom renderer

ajax,jsf,custom-renderer
I would like to override the output of the default <f:ajax> rendering. Is there a possibility to override the handling of the <f:ajax> tag respectively the renderer of this tag?

a4j:support - Value retrieved from h:selectOneMenu is always NULL

ajax,jsf,richfaces,ajax4jsf
There's a datatable with a h:selectOneMenu in each row. I want to be able to retrieve the value selected in the selectOneMenu in the bean. I'm using richfaces a4j:support tag to make AJAX calls to the backing bean. You can see the code below: DataTable header: <t:dataTable id="datatable" var="row" value="#{myBean.dataTableRows}">...

Re-create session scoped JSF managed bean programmatically

jsf,jsf-2,managed-bean,session-scope,recreate
I'm using Mojarra 2.1.29 and have a session scoped JSF managed bean @ManagedBean @SessionScoped public class UserContext{ //staff } and a spring bean: public class UserReproducer{ private User user; public void reporoduce(){ if(user == null){ //Here I need to recreate the userContext managed bean //do some other staff } }...

Conditionally render components with ajax conditionally only if validation passes

validation,jsf,jsf-2.2,conditional-rendering
I am using JSF 2.2 and I was wondering if there is a way to render components with ajax conditionally only if the validation passes. By using the render attribute of ajax the components will be rendered regardless of the validation passing or not. What I'm after is something like:...

How to display PDF in JSF, with content from ServletResponse

jsf,pdf,jsf-2,richfaces
In my application, I use jsf & richfaces, I want to display a generated pdf in web browser , I have generated this PDF in serverside and it is available in ServletResponse, but I am unable to display it in my web page. I have tried this question but, it...

Why won't my JSF app deploy to GlassFish?

jsf,netbeans,glassfish
Yesterday I had trouble with my app suddenly failing to deploy from NetBeans to GlassFish server. I now know why, and am going to answer this question myself. I just wanted to record this information for the next person that needs it. I hope the etiquette of that is OK?...

Retrieve the id of an Entity object as soon as the entity was instantiated?

jsf,jpa
Is there a way in JPA to retrieve the id of an Entity object as soon as the entity was instantiated? e.g Person person = new Person(); Currently i am using in my entity class the following strategy: @GeneratedValue(strategy = GenerationType.IDENTITY) If not is there a "Dummy Id" strategy for...

Parameters from f:param not submitted with AJAX request when form enctype is multipart/form-data

ajax,jsf,jsf-2,jsf-2.2,wildfly
I'm running Wildfly 8.2 and I'm using the JSF version bundled with it, 2.2.8-jbossorg-1. I have the following facelet: <h:form enctype="multipart/form-data"> <h:commandButton value="Submit"> <f:param name="myparam" value="true"/> <f:ajax execute="@this" render="@this"/> </h:commandButton> </h:form> When I press the submit button, several parameters are submitted, but not myparam. If I remove enctype="multipart/form-data" from the...

Eclipse + Wildfly + Maven EAR project, is it possible to have files update without redeploy?

eclipse,jsf,jsf-2.2,wildfly-8
I'm working on my first JavaEE/JSF project. It's currently set up with maven so that several jars and a war are deployed inside an EAR container. I spent a lot of time trying to get some kind of hot/autoredeploy type setup going a few weeks ago but gave up and...

JSF render dir=“rtl” when language is arabic

jsf,localization,dir,conditional-rendering
I want to render the text direction rtl (Right-To-Left) in an inputText when the browser's Accept-Language is arabic in my JSF application. When Accept-Language is english the text introduced by the user would be dir="ltr" (Left-To-Right). How can I do it?

Distinguish view from normal view in ViewHandler#createView()

jsf,custom-error-pages,viewhandler
I have defined error page in my web.xml for error 404 in this way: <error-page> <error-code>404</error-code> <location>/common/messages/pageNotFoundError.jsf</location> </error-page> Handling invalid page url works as intended - user is redirected to pageNotFoundError page. I have also defined custom view handler in faces-config.xml. The view handler overrides method createView(FacesContext context, String viewId)....

DynaForm Primefaces extensions gather submitted data

jsf,primefaces,primefaces-extensions
I am using DynaForm in Primefaces extensions. I have generated a dynamic form, but the problem is how to recover the submitted data from the controller. Here is how I am generating my form: this is the controller side model = new DynaFormModel(); DynaFormRow row; allfieldMessageList=getAllfieldMessageList(); for(FilledMessageField f:allfieldMessageList) { //...

Output data from database in JSF page

database,jsf,jsf-2
I am making a project using JSF, and I know how to get data from my view. I also know how to get data with the JDBC connector. And also how to put data in the view, from some objects, but my question is: How to put data directly from...

How to disable all components for the same type in a JSF page

jsf,jsf-2,disabled-control
I have let's said 4 pages who are dynamically included by a for like this: <c:forEach items="#{tareaController.mfuncionesAsociadas}" var="mFuncion" varStatus="loop1"> <p:tab id="t_funcion_#{loop1.index}" title="#{mFuncion.nombre}" > <f:subview id="tab_#{loop1.index}"> <p:panelGrid id="pg_funcion_#{loop1.index}"> <ui:include src="#{mFuncion.paginaFuncion}"></ui:include> </p:panelGrid> </f:subview> </p:tab> </c:forEach> I want to do the following: on every page I generate could be...

Wildfly 8.2 + JSF + SessionScoped : sometimes wrong data returned

jsf,session,cdi,wildfly,jboss-weld
In one of our systems in production we encounter a very weird problem in jboss 8.2 and latest JDK 7, centos 7 64 bits, latest primefaces on javax.enterprise.context.SessionScoped beans. (No jsf annotations are used in the whole project, only CDI annotation to avoid potential conflicts) At some point in time...

Omnifaces - ListIndexConverter, principle of operation

jsf,converter,omnifaces
I try to understand the principle of operation of the omnifaces.converter.ListIndexConverter @FacesConverter("omnifaces.ListIndexConverter") public class ListIndexConverter implements Converter { private static final String ERROR_LIST_INDEX_BOUNDS = "Index {0} for value {1} in component {2} is out of bounds."; private static final String ERROR_VALUE_NOT_IN_LIST = "Object {0} in component {1} does not appear...

JSF Composite Component with conditional popup panel

jsf,richfaces,el,composite-component
I'm trying to render a composite component that shows a popup panel based on the outcome of a backing bean method. So far no success. Would appreciate some help. GlassFish 4.1 Mojarra 2.2 RichFaces 4.5.4 Composite Component (conditionalActionLink.xhtml): <ui:component xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns:ui="http://java.sun.com/jsf/facelets"...

ajax validation error message [duplicate]

ajax,jsf,jsf-2,primefaces
This question already has an answer here: Custom JSF validator message for a single input field 1 answer how to add my own message for the client side validation in JSF. <div class="ui-grid-row"> <div class="ui-grid-col-3" align="left"> <h:outputLabel for="cmpny" value="Company Name:" style="font-weight:bold" /> </div> <div class="ui-grid-col-2"> <p:inputText id="cmpny" value="#{userData.cmpny}"> <f:validateLength...

Why can't I reference net.sf.jasperreports.engine.DefaultJasperReportsContext from JSF?

java,jsf,jasper-reports
I grabbed an old JSF (in Netbeans) project that I needed to update. I noticed that the libraries were missing, so I went and snagged the current version of JasperReports (.jar) and all the commons/other support .jars necessary. Ultimately, when I try to run the project it fails at the...

set focus to next input element after jsf's change value listener

javascript,jsp,jsf
in one of our front-end screens we have the following layout as follows <h:outputLabel for="firstName" value="first name" /> <h:inputText styleClass="required" id="firstName" size="30" maxlength="30" value="#{ownershipStoreInfoController.form.ownerFirstName}" onchange="submit()" valueChangeListener="#{ownershipStoreInfoController.useOwnerInfo}"> <e:validateRegExpr pattern="([A-Z,a-z,0-9,%@()#&amp;,.;:_\$\/\-\{\}\[\]\'\\s*]{1,30})?" /> </h:inputText> <h:outputLabel for="lastName" value="last name"...

Refresh parent node from backing bean with primefaces tree

jsf,primefaces,tree
Currently I am working on a project that use primefaces 3.4.1 version which does not support drag and drop in tree component. So I am using a contextMenu instead of drag and drop. <p:tree id="treeHierarchy" value="#{hierarchyManagementBackingBean.root}" var="node" dynamic="true" selectionMode="single" cache="false" style="width:99%;" selection="#{hierarchyManagementBackingBean.selectedNode}"> <p:treeNode id="idtreenode"> <h:outputText value="#{node.name} (#{node.entityType})" /> </p:treeNode> </p:tree>...

What URL to use to link other JSF pages in a JSF project

jsf,url,jsf-2,hyperlink
I am confused about how to link between files in a Java Server Faces project, when some of the files are in sub-folders. (I was going to attach screenshots so you can see the Nebeans project view, and files view of the example I am trying.... but I'm not allowed...

PrimeFaces p:dataList issues error “Property 'ime' not found on type java.lang.String”

jsf,primefaces,datalist
I want to make Checkbox menu and display data in dataList. Here is my xhtml: <h:form> <h:panelGrid columns="3" cellpadding="5"> <h:outputLabel for="menu" value="Demonstratori :" /> <p:selectCheckboxMenu id="menu" value="#{nastavnik.odabraniDemonstratori}" label="Demonstratori:" filter="true" filterMatchMode="startsWith" panelStyle="width:250px"> <f:selectItems value="#{nastavnik.sviDemonstratori}" var="demons" itemLabel="#{demons.ime} #{demons.prezime}" itemValue="#{demons}" />...

Submit form without attached file

jsf,jsf-2.2
I want to create JSF form with attached file. But also to give a option form the users to submit the for without attach file. I don't want this to be mandatory. <h:form id="form" enctype="multipart/form-data"> <div class="string"> <label class="name"> <h:inputText id="name" value="#{contacts.name}" pt:placeholder="Name*:"/> </label> </div> <label class="message"> <h:inputTextarea value="#{contacts.comment}" pt:placeholder="Comment*:"/>...

Render outcome of “action” attribute?

jsf,attributes,action,renderer
i want to completely rewrite a <h:commandButton> renderer. Now i'm stuck at rendering the "action" attribute of the button. Is there a possibility to render this attribute the same way it gets rendered by the standard renderer ? Is there a possibility to retrieve the generated script from somewhere ?...

Remove link outline from p:tabView

css,jsf,primefaces
Is there a way to remove the outline, when an user click on one of the <p:tabView> tabs? Set it in CSS did not help. a { outline: 0 none !important; } Here is a screenshot. ...

Is there a JSF toggle component or a way to theme an h:selectBooleanCheckbox with images?

jsf,button,checkbox,toggle
I tried using a toggle like below. Although it works, it breaks when used inside of a composite component - changing the singleSelect value outside of the component never updates inside the component: <h:commandButton disabled="#{cc.attrs.singleSelect}" image="/resources/img/collapse-single.gif"> <f:ajax listener="#{cc.toggleSingleSelect}" render="#{cc.clientId}"/> </h:commandButton> <h:commandButton disabled="#{! cc.attrs.singleSelect}" image="/resources/img/expand-single.gif"> <f:ajax...

Path to a file up in the hierarchy

jsf,jsf-2,navigation
Here is file structure of my JSF application. User directory is secured & one needs to authenticate to see user/success.xhtml. user/success.xhtml has a button which is used to logout. That button submits form to following method. public String logout(){ HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false); session.invalidate(); return "index"; } Last line of...

In Primefaces picklist, how to find that an item is moved from TARGET to SOURCE, Using Omnifaces Converter

jsf,jsf-2,primefaces,omnifaces
I have looked around and could not find a solution. I am using Omnifaces listConverter in the PickList component of Primefaces. When I move an item from SOURCE to TARGET. In the backing bean i get the new item ONLY on dualList.getTarget(). However when I move an item from TARGET...

f:convertNumber unexpectedly increments/decrements float value

jsf,jsf-2,floating-point,converter
I have a float property bound to <h:inputText>. For long values, it was automatically converting the values to exponential notation. I tried to use <f:convertNumber> to avoid the exponential value presentation. The value can be of two given below. Format 1: <18 digits> Format 2: <14 optional digits>.<3 option decimals>...

XPages: How to acces an application scope bean from a session scope bean

jsf,xpages
I need a value from my application scope managed bean in my session scope managed bean. Not sure how to get this done. Saw a poste here: https://guedebyte.wordpress.com/2012/05/19/accessing-beans-from-java-code-in-xpages-learned-by-reading-the-sourcecode-of-the-extensionlibrary/ But I get a bunch of errors... I also found this: JSF 2.0 Accessing Application Scope bean from another Bean so IM...

Output and Command Link in one in JSF

jsf,hyperlink,action
Is there a possibility to use both outcome and action in the same command link? I tried <h:commandLink outcome="page?faces-redirect=true" value="Got to Page" action="#{Bean.setValue("...")}" /> but it ignores the outcome. I have a table with data like this: ID Name Other Things Link to Next Page So I want to give...

Show String JSF [duplicate]

list,jsf,selectonemenu
This question already has an answer here: How to prepopulate <h:selectOneMenu> with entities from database? 3 answers I want to show in a list the names of the buildings have stored in the database, using h: selectOneMenu f: SelectItems. Part of .xhtml where I do this is: <h:form id="form-lista">...

Can @ManagedBean and @XxxScope be placed in a base class?

jsf,jsf-2,subclass,managed-bean
I have two @ManagedBean (javax.faces.bean.ManagedBean), parent and child. The parent managed bean is not abstract because we have to give liberty to the developer to use the parent if enough or inherit it with a child that holds specifically funcionality. I have problems with the injections bean and the @PostConstruct...

Avoid rendering empty byte array with

jsf,omnifaces,graphicimage,conditional-rendering
I got two <o:graphicImage> to display the stored image and a dummy image if there is no image. Actually, the size of the stored images can be zero. If so, the first <o:graphicImage is rendered, but the image is empty and not rendered properly. <o:graphicImage id="image" alt="Image" lastModified="#{userProfile.user.lastModified}" rendered="#{not empty...

Primefaces: Dialog with inputTextarea not updating controller's variable

jsf,jsf-2,primefaces
I have this Dialog: <p:dialog header="Ingrese Comentario" widgetVar="dlg1" appendTo="@(body)" modal="true" position="top" hideEffect="fold" showEffect="fold" closable="true" draggable="true" > <h:form id="d_ingresarComentario"> <h:panelGrid columns="2"> <p:inputTextarea value="#{tareaController.comentarioNuevo.comentario}" rows="7" cols="60" placeholder="Ingrese su comentario aquí" counter="display1" maxlength="200" counterTemplate="{0} Caracteres faltantes." > </p:inputTextarea> <br/>...

CSS for displaying empty div

css,jsf
I have a JSF template with three important components: template.xhtml: <div class="leftStripe"> <ui:insert name="leftStripe"></ui:insert> </div> <div class="mainStripe"> <ui:insert name="mainStripe"></ui:insert> </div> <div class="rightStripe"> <ui:insert name="rightStripe"></ui:insert> </div> style.css: .mainStripe{width:70%; float:left; margin: auto; min-height: 100%;} .leftStripe{width:15%; float:left; height:100%;} .rightStripe{width:14%; float:right;...

af:convertNumber element removes zero in the end of the value

jsf,numbers,converter,oracle-adf
My code: <af:inputText id="it1" label="Test"> <af:convertNumber groupingUsed="true" type="number" messageDetailConvertNumber="#,###,##" maxFractionDigits="2"/> </af:inputText> When I type 100,51 -- everything is fine, but if I would type 100,50, then '0' will be removed and entered value will be 100,5. How can I leave this '0' in the end? I need <af:convertNumber> element for...

Every include should refer to other instance

jsf,jsf-2,reference,uiinclude
I include a part of the XHTML page to my Web Application. This part can be included multiple times. And that's the problem! Because every include refers to the same java object. That means that every element has the same value. But I want for each include a new Java...

JSF link to external site without showing username and password in the URL

jsf,post,single-sign-on,commandlink
I was able to do a SSO(Single sign on) on click of external link from the code below. SSO works but username/password is seen on url. https://example.org/index.php?userLogin=user1&userPassword=pass123 <h:outputLink styleClass="ui-menuitem-link ui-corner-all" value="https://example.org/index.php"> <h:outputText value="Ext Tool" /> <h:outputText styleClass="ui-icon ui-icon-suitcase" style="float:left" rendered="#{userBean.in}" /> <f:param name="userLogin" value="#{userBean.user.eUser}" /> <f:param...

javax.servlet.ServletException the request doesn't contain a multipart/form-data or multipart/mixed stream

ajax,jsf,file-upload,jsf-2.2,mojarra
I've the below form which uploads a file via <h:inputFile> and <f:ajax>. <h:form enctype="multipart/form-data"> <h:inputFile id="file" value="#{bean.file}" /> <h:commandButton value="Upload" action="#{bean.upload}"> <f:ajax execute="file" render="file" /> </h:commandButton> </h:form> When I submit it, I get a JavaScript alert with the below error information: serverError: class javax.servlet.ServletException the request doesn't contain a multipart/form-data...

Unable to load servlet listener class: com.sun.faces.config.ConfigureListener

maven,jsf,tomee
I'm using apache-tomee-jaxrs-1.7.1 and I'm trying to deploy with maven 3 getting this error: Unable to load servlet listener class: com.sun.faces.config.ConfigureListener: These are my dependencies in pom.xml: ... <dependencies> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>6.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp.jstl</groupId>...