about 2 years ago - 3 comments
Javascript to Select One Radio Button
function selectOne(form, button) {
turnOffRadioForForm(form);
button.checked = true;
}
function turnOffRadioForForm(form) {
for (var i = 0; i < form.elements.length; i++) {
form.elements[i].checked = false;
}
}
JSF Code of h:dataTable Table on JSP Page
We will use valueChangeListener for this, as when user check the radio button we will get the binded value of bean. It is one column. More >
about 2 years ago - No comments
Get appplication from FacesContext
FacesContext ctx = FacesContext.getCurrentInstance();
Application app = ctx.getApplication();
Setting in Managed Bean Object
app.createValueBinding(“#appSessionBean.userDataBean}”).setValue(ctx, userDataBean);
Getting Managed Bean Object(s)
AppSessionBean appSessionBean = (AppSessionBean)app.createValueBinding(“#{appSessionBean}”).getValue(ctx);
userDataBean = (UserDataBean)appSessionBean.getUserDataBean();
where userDataBean is object in ApplicationSessionBean class and this said class is in faces-config with session scope.
about 2 years ago - 3 comments
import javax.faces.context.FacesContext;
public void addInSession() {
MySession mySession = new MySession();
mySession.setName(getMsg());
/* .getSession(boolean), true if we want to create new session, if want touse oldsession then false*/
FacesContext context = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) context.getExternalContext().getSession(false);
session.setAttribute("sessionObj", mySession);
if (session.getAttribute("sessionObj") != null) {
MySession mySavedSession = (MySession) session.getAttribute("sessionObj");
System.out.println("HTTP Session: " + mySavedSession.getName());
} else {
// do something
}
}
about 2 years ago - 4 comments
Here is the way, how we get request parameters from a JSP page (which is JSF enabled) in a HTTP request object.
import javax.faces.context.FacesContext;
//…your code
HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
String controlName = request.getParameter("formId:controlId");
Where formName is refer to the id of your form and controlId is referred to the id of your control.
about 2 years ago - No comments
Faces Console is a free utility get integrated in many IDEs as plugin and provide JSF (faces-config.xml) configuration facility in a GUI. if you are using NetBeans5.0 or Eclipse3.x you must try it.
http://www.jamesholmes.com/JavaServerFaces/console/