Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!

Kenneth Miller

Greenhorn
+ Follow
since Jun 30, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kenneth Miller

You can configure a mesage bundle in the faces-config.xml and add following entry to message bundle to override the input required message.

javax.faces.component.UIInput.REQUIRED=This field is required
10 years ago
JSF
In startup servlet's init method get hold of the ServletContext, instantiate your managed bean, call it's method and set the managed bean as attribute of the ServletContext.
That seems to do the trick.
Eg.
public void init(ServletConfig config) throws ServletException {
ServletContext context = config.getServletContext();
MyBean myBean = new MyBean();
myBean.setTest("test");
context.setAttribute("myBean", myBean);
super.init(config);
}
When now referencing the managed bean from a jsf page. The test attribute is populated correctly.
10 years ago
JSF
it should be fine as you have the required attribue set to to true. You're saying the action method associated with the form submit is called but your custom method isn't ?.
Regards,
Kenneth
10 years ago
JSF
Hi Jason,
Maybe calling the method from a dummy managed property's setter method might help. Not sure whether the managed property's on a bean are set sequentially based on the order in the faces-config file. Might be worth a try.
Regards,
Kenneth
10 years ago
JSF
Hi,
There is no support for stored procedures in JPA. However I found using spring jdbc template for stored procedures a breeze.
http://static.springsource.org/spring/docs/2.0.x/reference/jdbc.html
I think you should be able to intergrate jdbc template quite nicely into EJB3.
HTH.
Regards,
Kenneth
Hi,
This section from http://www.ibm.com/developerworks/java/library/j-jsf3
should give you all you need.

Validation methods in backing beans

As an alternative to creating a separate validator class, you can simply implement custom validation in a backing bean method, as long as the method adheres to the same argument signature as the Validator interface's validate method. For instance, you might write the following method:

[SomeBackingBean.java]

public void validateEmail(FacesContext context,
UIComponent toValidate,
Object value) {
String email = (String) value;

if (email.indexOf('@') == -1) {
((UIInput)toValidate).setValid(false);

FacesMessage message = new FacesMessage("Invalid Email");
context.addMessage(toValidate.getClientId(context), message);
}

}



The method would then be used in the JSF tag via the validator attribute as shown here:

<h:inputText id="email"
value="#{UserRegistration.user.email}"
validator="#{UserRegistration.validateEmail}"
required="true">
</h:inputText>

Regards,
Kenneth
10 years ago
JSF
Assuming your managed bean is session scoped. Why not get it from the session object or construct the managed bean and set it on the session object from a startup servlet.
Eg.
FacesContext context = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) context.getExternalContext().getSession(false);
MyBean myBean = new MyBean();
myBean.method();
session.setAttribte("myBean", myBean);

I think this should work.

BTW.
the servlet-class in your code clipping should be a servlet. It can't be a managed bean.

HTH.
Regards,
Kenneth
10 years ago
JSF