This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



May 20, 2011, 11:44 AM
24 Posts

How to get a Value from a UI Component

  • Category: Managed Beans in NSF
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags:
  • Replies: 1
 I know how to get a UIComponent from the xPage from my Managed Bean.
 
But what I can't figure out is how to the the current value contained in the UIComponent.
 
Eclipse says the getValue() and getSubmittedValue() are not methods of the UIComponent. 
 
 Thanks for your help,
 
-- Jeff 
 
 
 
 
May 20, 2011, 8:56 PM
24 Posts
Re: How to get a Value from a UI Component
 I figured it out.
 
I used Karsten's JSFUtils to get the UI Component like this:
 
import javax.faces.component.UIComponent; 
UIComponent comp=JSFUtil.findComponent("inputText1"); 
 
But I got the UIComponent, there was no get Value for get Submitted value. Thats because UIComponent is a base class.  
The class we need it the UIInput class.  Now the code looks like this: 
 
import javax.faces.component.UIInput; 
UIInput comp = (UIInput) JSFUtil.findComponent("inputText1"); 
 
Now, you can use comp.getValue() to get the current value of the field. 
 
I'll be using this a great deal in validators where I need to know the current value of one field to validate the current field.  
 
-- Jeff 
 
Karsten's JSFUtils are found here: 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal