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


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

Question:

Tag: 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.

Is there a way to do this? Using commandLink or commandButton does not seem like an option to me since it will mess up the styling.

Thanks in advance.


Answer:

An output link is just a normal HTML link, so a conventional way to do this is with a query parameter, e.g. /contentarea.xhtml?myparam=value.

I don't think you should bind a method to the output link. That would involve a Javascript onclick handler (commandLink), and I don't think that's necessary here. That said, I'm surprised you say commandLink messes with the styling, as it renders a normal HTML link.

See also


Related:


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...

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...

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?...

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...

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...

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/>...

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...

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...

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?...

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...

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"...

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>...

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...

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

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...

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....

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>...

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"...

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...

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...

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}">...

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...

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...

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...

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...

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> ...

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...

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...

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...

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?...

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...

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...

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...

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...

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"...

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}"...

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...

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...

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 ?...

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*:"/>...

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...

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...

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. ...

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...

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...

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>...

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...

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...

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)....

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...