I was asked if there was a way to control Mojarra JSF 2.x components with
jQuery. In this case they wanted to be able to control some aspect of the controls from
JavaScript on the loading of the document. Here are a couple of quick examples of controlling JSF components using jQuery.
- Set the background to a light gray
- Disable
form1:inputText1
- Change the value of
form1:inputText2
to Hello World! using a EL assignment to a JavaScript variable.
- Set
form1:inputText3
to be required.
index.xhtml
IndexBean.java
// Copyright 2011 Blue Lotus Software, LLC.
// Copyright 2011 John Yeary.
package bean;
import javax.enterprise.context.RequestScoped;
import javax.faces.bean.ManagedBean;
/**
*
* @author John Yeary
* @version 1.0
*/
@ManagedBean
@RequestScoped
public class IndexBean {
private String value = "Hello World";
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
0 comments :
Post a Comment