Myfaces 2.0.5 : Disable validation if no value entered in field - jsf

Currently we are moving application from Weblogic 11g to Jboss eap 7.
For JSF forms, custom validator is enabled in this application as below
<h:inputText id="lastName" maxlength="30" styleClass="InputBoxMedium" value="#{searchBean.lastName}" onkeyup="checkAllEmptyField('Search', 'searchActive', 'searchInactive', 5)">
<f:validator validatorId = "searchValidator"/>
</h:inputText>
Assume we have 10 similar fields,
In Weblogic, this validator is only called for validation for non-empty fields
In Jboss, validator is called for all fields.
we would like to have weblogic behavior in jboss.

Adding following in web.xml helped to resolve the problem in Jboss eap 7.....hope this will help someone in future....
<context-param>
<param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name>
<param-value>false</param-value>
</context-param>
Not sure why this was not required in weblogic :-(
below link helped me, pls check it for details
Shouldn't the validation be skipped when there is no value specified?

Related

ViewExpiredException despite high session timeout

for my Portlet(*) I'm getting "ViewExpiredException"s although my session-timeout in ROOT/WEB-INF/web.xml is set with 600 (minutes).
The (portletapp)/WEB-INF/web.xml has no session-timeout configured.
Also there is no configuration like
session.timeout=30
in a portal.properties like mentioned in https://www.liferay.com/de/community/wiki/-/wiki/Main/Session+Timeout
Regarding the exception I'm currently planning to set
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
But I'd like to understand the problem. Where can I find other session-timeout configurations, or is this a default I need to overwrite?
Regards,
Gunnar
(*) Liferay 6.2 EE SP10 on Tomcat 7.0.42, Mojarra 2.1.29, Portlet 2.0, Servlet 2.5, jstl 1.2.1, facelets 1.1.15, Primefaces 5.0
Update: Maybe I found the solution after more searching: Default session timeout for Apache Tomcat applications
(Tomcat's default session timeout in conf/web.xml)
Update: Problem not solved, own answer deleted.
I just got the "ViewExpiredException" again.
I added debug logging of
"maxInactiveInterval: " + PortalUtil.getHttpServletRequest(((PortletRequest)FacesUtil.getExternalContext().getRequest())).getSession().getMaxInactiveInterval()
and I see my 600 configured minutes as 36000 seconds.
Any hints why I keep getting "ViewExpiredException"s?
My next try will be the portal.properties-entry mentioned above.

tomahawk panelNavigation2 does not triggered actionlistener after upgrading to JSF2

I have migrated my web application from JSF 1.2 to JSF 2.1.
In my web.xml I have set the the following context-param to true in order to use bundle jars instead of using the provided wildfly jars.
<context-param>
<param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
<param-value>true</param-value>
</context-param>
I have placed the following jars into the WEB-INF/libs folder:
tomahawk21-1.1.14, jsf-api-2.1.0.jar and jsf-impl-2.1.0.jar
I can start the application und log myself in. However once I click on a MenuItem built as follows:
<h:form id="nav" styleClass="nav">
<t:panelNavigation2 id="panel-nav" expandAll="true">
<t:navigationMenuItems value="#{hello.menuItems}" />
</t:panelNavigation2>
</h:form>
nothing happens. I have programmatically set actionListener for the MenuItem. It did work fine when using JSF1.2.
Using remote debugging with eclipse clearly proves that the action listener method is not called.
Best regards
Edmond

HttpOnly settings can be done in application having servlet api-2.5 and web.xml 2.5 version?

wanna enable httpOnly attribute to session cookie for our application. we are using servlet-api 2.5 version and web.xml as 2.5 .. now i have tried adding below code in web.xml
<cookie-config>
<http-only>true</http-only>
</cookie-config>
i got error parsing error in web.xml at <cookie-config>
can any please help on this.. do i need to update servlet version to 3 and web.xml to 3 as well ...
or any other ways to do it writing in java code itself.. we are using jboss 5 version..

how to enable browser caching in jsf

I have created a web application using JSF 2.0. I got feedback from my friend saying I should do "Browser Caching" as I have many images.
However I don't know how to do same in JSF. Any idea/ hint would be appreciated.
Concept on what to be done would also work.
Just use <h:graphicImage name="..."> instead of <img src="...">. This way the default JSF resource handler will instruct the browser to cache them for 1 week by default, which is configureable with an implementation dependent context parameter, which is the following in case of Mojarra:
<context-param>
<param-name>com.sun.faces.defaultResourceMaxAge</param-name>
<param-value>3628800000</param-value> <!-- 6 weeks -->
</context-param>
Note, the same applies when using <h:outputScript> and <h:outputStylesheet> instead of <script> and <link rel="stylesheet">.

How to upload files in JSF 1.1?

I want to upload files in a JSF 1.1 project. JSF 1.1 doesn't support RichFaces file upload. I looked at Tomahawk, but I don't know how to use Tomahawk. Can anybody explain for me?
Which JARs do I have to use?
And taglibs?
And web.xml configuration?
And faces-config.xml configuration?
Or are there alternatives to Tomahawk?
Which JARs do I have to use?
The following ones:
tomahawk
commons-fileupload
commons-io
commons-logging
commons-el
I assume that you already have the JSF 1.1 JARs jsf-api and jsf-impl.
And taglibs?
Just the Tomahawk one, next to the two usual core/html tags:
<%# taglib uri="http://myfaces.apache.org/tomahawk" prefix="t" %>
And web.xml configuration?
You need the ExtensionsFilter. This filter will take care that JSF gets the right parameters out of a multipart/form-data request body.
<filter>
<filter-name>Extensions Filter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Extensions Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
And faces-config.xml configuration?
Nothing special. Just create a managed bean the usual way with a UploadedFile property which you bind to the value attribute of <t:inputFileUpload>.
See also:
How to upload files in JSF? (yes, it's targeted on JSF 1.2, but should work equally good in JSF 1.1).

Resources