Problemas com InputText + Focus + CSS

UI Components for JSF
Post Reply
leonardobhbr
Posts: 18
Joined: 11 Mar 2011, 14:17

02 May 2012, 13:14

I'm having some problems related to the components of the container Primefaces (p: panel, p: panelGrid ep: fieldset) and CSS, when I use the default JSF container (h: panelGrid and h: panelGroup) works fine.

The problem only occurs if I use the p:inputText of Primefaces; when I use the h: inputText JSF works fine.

Below follow two examples consisting problem:
Example1:

Code: Select all

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core">

<f:view contentType="text/html">
	<h:head>
		<style type="text/css">
			input:focus,select:focus,textarea:focus {
				background: red;
				color: white;
			}
		</style>
	</h:head>
	<h:body>
		<h:form>
			<p:panel>
				<h:inputText value="" />
				<p:inputText value="" />
			</p:panel>
			<h:panelGrid columns="1">
				<h:inputText value="" />
				<p:inputText value="" />			
			</h:panelGrid>
		</h:form>
	</h:body>
</f:view>
</html>
Example2:

Code: Select all

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core">

<f:view contentType="text/html">
	<h:head>

		<style type="text/css">
.corFoco {
	background-color: red;
	color: white;
}
</style>

		<script type="text/javascript">
		$(document).ready(function(){
		    $('input[type="text"]').focus(function () {
		        $(this).addClass("corFoco");
		    });

		    $('input[type="text"]').blur(function () {
		        $(this).removeClass("corFoco");
		    });
		});		
</script>


	</h:head>
	<h:body>
		<h:form>
			<p:panel>
				<h:inputText value="" />
				<p:inputText value="" />
			</p:panel>
			<h:panelGroup>
				<h:inputText value="" />
				<p:inputText value="" />
			</h:panelGroup>
		</h:form>
	</h:body>
</f:view>
</html>
Thanks to all...

User avatar
T.dot
Expert Member
Posts: 620
Joined: 01 Feb 2012, 15:39
Location: Vienna/Austria

02 May 2012, 13:33

PF already has styleclasses for focused fields. Why don't you override them?

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

02 May 2012, 14:06

Code: Select all

.ui-inputfield.ui-state-focus {
   //...
}
applies to all components with an input field like inputText, inputMask, spinner ...

leonardobhbr
Posts: 18
Joined: 11 Mar 2011, 14:17

02 May 2012, 14:09

Thanks

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 34 guests