How to bind a complex object to a composite component
I'm using JSF2 and having an issue binding an object (EL Expression) as a parameter to my composite component.
I have written a composite component (not very complex) that will display a drop-down list of countries and should bind the selection to a provided target bean.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<!-- INTERFACE -->
<composite:interface>
<composite:attribute name="label" required="true" />
<composite:attribute name="requiredMessage" required="true"/>
<composite:attribute name="target" required="true" type="com.mycompany.entity.Country"/>
</composite:interface>
<!-- IMPLEMENATION -->
<composite:implementation>
<h:panelGrid columns="2">
<h:outputLabel for="country-list" value="#{cc.attrs.label}"/>
<h:panelGrid id="country" columns="1" styleClass="select-one-menu-panel" >
<h:selectOneMenu id="country-list"
enabledClass="select-one-menu-enabled" disabledClass="select-one-menu-disabled"
layout="pageDirection"
value="#{cc.attrs.target}"
required="true" requiredMessage="#{cc.attrs.requiredMessage}"
>
<f:selectItem itemLabel="#{msgs['label.pleaseSelect']}" itemValue="" />
<f:selectItems value="#{countryController.countries}" />
<a4j:ajax />
</h:selectOneMenu>
<a4j:outputPanel id="country-list-error-panel" ajaxRendered="true">
<h:message id="country-list-error" for="country-list" style="color:red"/>
</a4j:outputPanel>
</h:panelGrid>
</h:panelGrid>
</composite:implementation>
</html>
I want to be able to use the composite component in the following way:
<util:country-select
label="#{msgs['label.countryOfBirth']}"
requiredMessge="#{msgs['error.birthCountryRequired']}"
target="#{participant.countryOfBirth}"/>
When I load the page everything renders correctly, but when I select an item from the drop-down I get a validation error.
apply-form:j_idt77:country-list: Validation Error: Value is not valid
I know that it must be something with the way that I have the parameters defined but I simply can't find any information to help me figure this out.
Any light that you might be able to she on this would be greatly appreciated.
Thank you for the help...
Hi,
well, you can. What the ADF Data Control and thus the binding gives you is the JSF component binding and the business service access.
If you don't want to use ADF, then what you can do is
- Create an ADF BC root Application Module from a managed bean
e.g. see http://docs.oracle.com/cd/E21764_01/web.1111/b31974/bcservices.htm#CHDDDBFC
- Access the View Object for querying the data to display
- Expose the queried data so the component can handle it e.g. setter/getter for input components, ArrayList for tables (or you create the more complex component models like table and tree models)
Having outlined the above, here are some gotchas to watch out for
- Make sure creating the root application module is done such that you don't create/release it with each request. So you may consider a data serving managed bean in a scope like page flow or session
- Ensure you have helper methods that allow you to query and CRUD operate the View Object data
Frank
Similar Messages
-
JAVA&SOAP:how to return a complex object( the object has an object within)
Lets say my Complex object is :
public class PersonWithAddress {
private String name;
private int ssn ;
private Address add;
PersonWithAddress() {
name="Gagan Tandon" ;
ssn =1111;
add = new Address("1113","WestPlum Street");
public String getName() {
return name;
public int getSSN() {
return ssn;
public Address getAddress() {
return add;
This complex object has Address object embedded in it.
public class Address {
private String house;
private String street;
public Address (String myHouse,String myStreet) {
house = myHouse;
street = myStreet;
public String getHouse() {
return house;
public String getStreet() {
return street;
My deployment Descriptor is as following: check the mappings part.
<isd:service xmlns:isd=
"http://xml.apache.org/xml-soap/deployment"
id="urn:xml-soap-person-demo">
<isd:provider type="java"
scope="Application"
methods="getPersonWithAddress">
<isd:java class="PersonServer"/>
</isd:provider>
<isd:faultListener>
org.apache.soap.server.DOMFaultListener
</isd:faultListener>
<isd:mappings>
<isd:map
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:x="urn:xml-soap-person-demo" qname="x:PersonWithAddress"
javaType="PersonWithAddress"
java2XMLClassName="org.apache.soap.encoding.soapenc.BeanSerializer"
xml2JavaClassName="org.apache.soap.encoding.soapenc.BeanSerializer"/>
<isd:map
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:x="urn:xml-soap-person-demo" qname="x:Address"
javaType="Address"
java2XMLClassName="org.apache.soap.encoding.soapenc.BeanSerializer"
xml2JavaClassName="org.apache.soap.encoding.soapenc.BeanSerializer"/>
</isd:mappings>
</isd:service>
And in my SOAPRPC code at client end calls the following: check the mappingregistry code...
String serverHost = "http://localhost:8082/soap/servlet/rpcrouter";
SOAPMappingRegistry smr = new SOAPMappingRegistry();
Parameter p= null;
try {
System.out.println("here 0");
Response r=null;
Call c=new Call();
Vector parameters = new Vector();
System.out.println("here 1");
c.setTargetObjectURI ("urn:xml-soap-person-demo");
c.setMethodName ("getPersonWithAddress");
System.out.println("here 3");
c.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
// parameters.addElement (new Parameter("name", String.class, "Web Services Client", null));
// c.setParams (parameters);
c.setSOAPMappingRegistry(smr);
BeanSerializer beanSer = new BeanSerializer();
smr.mapTypes(Constants.NS_URI_SOAP_ENC,new QName("urn:xml-soap-person-demo","Address"),Address.class,beanSer,beanSer);
smr.mapTypes(Constants.NS_URI_SOAP_ENC,new QName("urn:xml-soap-person-demo","PersonWithAddress"),PersonWithAddress.class,beanSer,beanSer);
try
System.out.println("here 4");
r = c.invoke ( new URL(serverHost), "" );
// org.apache.soap.SOAPException can be thrown
catch ( Exception e )
e.printStackTrace();
// Check the response.
if (r.generatedFault ()) {
Fault f = r.getFault();
System.out.println ("Error Occurred: ");
System.out.println (" Fault Code = " + f.getFaultCode());
System.out.println (" Fault String = " + f.getFaultString());
// return f.getFaultString();
// return new String("gagan");
return null;
else {
System.out.println("here 5");
p = r.getReturnValue();
System.out.println("here 6");
// System.out.println( (String)greeting.getValue() );
System.out.println("SSN: " + ((PersonWithAddress)p.getValue()).getSSN());
return (PersonWithAddress) p.getValue();
catch( Exception e ){
e.printStackTrace();
// finally {
// return null;// String("not OK");
if (p==null)
return null;
else
return (PersonWithAddress) p.getValue();
When running this code..
The following error is thrown.
System.out.println("here 4") is printed.
[SOAPException: faultCode=SOAP-ENV:Client; msg=Unable to instantiate 'PersonWithAddress': Class org.apache.soap.encoding.soapenc.BeanSerializer can not access a member of class PersonWithAddress with modifiers ""; targetException=java.lang.IllegalArgumentException: Unable to instantiate 'PersonWithAddress': Class org.apache.soap.encoding.soapenc.BeanSerializer can not access a member of class PersonWithAddress with modifiers ""]
at org.apache.soap.rpc.Call.invoke(Call.java:294)
at PersonClient.getPersonWithAddress(PersonClient.java:92)
at PersonClient.<init>(PersonClient.java:11)
at PersonClient.main(PersonClient.java:20)
java.lang.NullPointerException
at PersonClient.getPersonWithAddress(PersonClient.java:96)
at PersonClient.<init>(PersonClient.java:11)
at PersonClient.main(PersonClient.java:20)
I am here 1
Exception in thread "main" java.lang.NullPointerException
at PersonClient.<init>(PersonClient.java:13)
at PersonClient.main(PersonClient.java:20)
What could be the problem..? Is there any info on net how could i pass complex objects of this type in Java through SOAP RPC.
GAGANHave you managed to sole the problem ? I have got similar one...
[SOAPException: faultCode=SOAP-ENV:Client; msg=Unable to instantiate 'auction.common.Property': auction/common/Property]
at proxy.soap.AuctionHistoryProxy.addAuctionProperty(AuctionHistoryProxy.java:515)
at java.lang.reflect.Method.invoke(Native Method)
(...) -
How to bind "Image Field" object on a database
Hi to all
I inserted into a dynamic PDF (Livecycle ES3 trial) an image field, but I don't understand how I can to bind a JPG into a database.
In (F5) preview... I'm able to open a image file on filesystem and visualize it on PDF form... but then? How to bind on database?
In my several tentatives I'm using a MS Access 2010 database table, where I defined a OLE object... but doesn't work.
Thank you at all.
visertHi,
I have not tried to do this, but this document provides some instructions.
http://partners.adobe.com/public/developer/en/livecycle/lc_designer_XML_schemas.pdfhttp://partners.adobe.com/public/developer/en/livecycle/lc_designer_XML_schemas.pdf
Hope it helps
Bruce -
Creating a new cell factory, how to bind to my object's property
As near as I can tell, the javafx binding using observable values, alot like jgoodies and its not like SWT databinding or WPF binding.
I was creating a cell factory for a TreeView. Just using a label to display the contents and calling toString, alot like the way it works now. However, I could not figure out to create a binding that would bind to a property on my domain object. Is there a way to specify the binding to the Label's text property so that whatever object that the cell's item's value has I can bind to a property that I specify on it e.g. the "name" property. But I could not see how to do that. Also, the only way I could figure out how to update the Label's value was from updateItem. I thought maybe I could even setup the binding in updateItem so that when the TreeItem's value changed at least it would automatically update the label binding, but the API did not seem to support that.
What's the right coding pattern to use when using straight Java coding?
I know in jgoodies I could do this using the PresentationModel approach or master-detail SWT or WPF with just specifying the property on the item's property that I want in WPF.
public static class MyTreeCell extends TreeCell<Object> {
Label label;
public MyTreeCell() {
label = new Label();
setNode(label);
@Override
public void updateItem(TreeItem<Object> arg0, boolean arg1) {
if (arg0 != null && arg0.getValue() != null) {
System.out.println("New value: " + arg0.getValue());
label.setText(arg0.getValue().toString());
} else {
System.out.println("New value is null and this println is called alot, why is that?");
super.updateItem(arg0, arg1);
}Well the presentation model thing worked fine and I have some machinery for the cell factory/cell item to obtain a tree cell based on the domain object type (a template/factory is placed into the properties in the scenegraph hierarchy). But its not smooth yet and the pattern does not quite translate well into javafx. Because the cell factory produces cells that could be used for a variety of domain object types, all the logic gets pushed down to the treecell subclass which makes it messy. Maybe this is where CSS selectors need to come in, you specify the class of a tree cell for a specific domain object type and you can set that at the root of the application so it cascades. I'll see if this approach works.
Here's the code for the javafx version of jgoodies' presentation model, less the corner cases. This allows you to bind to a property and change the bean underneath that the property accesses. I'm not convinced that having properties has observable values directly on the objects is the right model for javafx because of the coupling to the actual object the property represents. Sometimes, you need to represent the property concept separate from the actual object instance. Maybe this already exists in the library.
* An object binding object that creates object bindings based on property
* names specified as strings. This is a convenience class. Generally, the
* return values from <code>getProperty()</code> should be used for binding
* not the factory itself. The object should be a domain object bean with
* bean methods to get or set the value using java bean naming conventions.
* When the bean itself changes, the properties fire to indicate that their
* values may have changed and the observing object should update itself.
* <p>
* This only handles reading bean properties. Need to add set() logic.
* <p>
* TODO: Make this work better. Many corner cases to cover. Include PCL.
public static class BeanBindingFactory<T> extends ObjectBinding<T> {
T bean;
Map<String, CaptiveObjectProperty> properties = new HashMap<String, CaptiveObjectProperty>();
public Property getProperty(String property) {
if (property == null || property.isEmpty())
throw new IllegalArgumentException("Property cannot be null");
if (properties.containsKey(property))
return properties.get(property);
CaptiveObjectProperty p = new CaptiveObjectProperty(this, property);
properties.put(property, p);
return p;
public void setBean(T bean) {
this.bean = bean;
for (CaptiveObjectProperty p : properties.values()) {
p.invalidate();
fireValueChangedEvent();
public T getBean() {
return bean;
@Override
protected T computeValue() {
return bean;
* Lazily get the method representing the property.
* @author Mr. Java
* @param <T>
protected static class CaptiveObjectProperty<T> extends
ObjectPropertyBase<T> {
String property;
Method m;
BeanBindingFactory factory;
public CaptiveObjectProperty(BeanBindingFactory factory,
String property) {
this.property = property;
this.factory = factory;
@Override
public Object getBean() {
if (factory == null || factory.getBean() == null)
return null;
return factory.getBean();
@Override
public T getValue() {
if (m == null) {
m = getMethod();
if (m == null)
return null;
try {
Object rval = m.invoke(factory.getBean());
return (T) rval;
} catch (Exception e) {
e.printStackTrace();
return null;
@Override
public String getName() {
return property;
* Invalidate the method. Perhaps the bean changed to another object
* and we should find the method on the new object.
public void invalidate() {
m = null;
fireValueChangedEvent();
protected Method getMethod() {
if (factory == null || factory.getBean() == null)
return null;
String methodName = "get"
+ Character.toUpperCase(getName().charAt(0));
if (getName().length() > 1)
methodName += getName().substring(1);
try {
Method mtmp = factory.getBean().getClass()
.getMethod(methodName, new Class<?>[0]);
return mtmp;
} catch (Exception e) {
e.printStackTrace();
return null;
} -
How to bind a String object to java:comp/env name space?
Hi, does anybody know how to declare a String as a JNDI object in OC4J V904. I want to register a String named 'Foo' with the value 'val' with JNDI. Eventually I want to get the value of this by referencing this JNDI name:
java:comp/env/ejb/Foo
I don't really care how this is done either by declaring it by way of ejb-jar.xml or a global setting at the application server level.
Please assist!
Thanks
JThere are many possible ways.
- (BEST) Use the J2EE resource environment variable mechanism (ie resource-env-ref in ejb-jar.xml).
- (MEDIUM) Use OC4J startup classes.
- (IF ELSE FAILS) Use the InitialContext.rebind method. -
How to bind Hibernate domain objects to the UI layer
Dear All,
I am trying to bind FX UI controls to properties of a Hibernate Domain object. Is there any good example to refer to for this purpose?
Thanks & Regards,
Nitin GuptaAssuming you do not formulate your hibernate objects as pojos with javafx properties directly, if the hibernate object is a pojo with or without PCL, you can convert the properties of the pojo to observable values (or properties) directly. These are used in a bind statement.
Check out what jgoodies does with BeanAdapter or PresentationModel. You need the same concept. I've attached a class that does this for a pojo already (its an incomplete port of jgoodies PresentationModel). It will work for any pojo. It does not have setter support as it was just a demonstration. Its efficient for a pojo with a large number of properties. You could also write a very short property connector to produce one observable value per property. The value of the class below is to be able to swap out the bean being observed without having to change or reset the property observable values each time. Bind once and then just reset the bean (think master detail).
package scenegraphdemo;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.ObjectPropertyBase;
import javafx.beans.property.Property;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.beans.value.WritableValue;
* An object binding object that creates object bindings based on property names
* specified as strings. This is a convenience class to avoid having observable
* values directly dependent on the underlying bean. The actual bean the
* properties connect can be changed dynamically using the channel or
* <code>setBean</code>. This allows you to setup binding when you don't have
* the bean to bind to or the bean to bind to will change as in the detail part
* of a master-detail screen. Generally, the return values from
* <code>getProperty()</code> should be used for binding not the factory itself.
* The object should be a domain object bean with bean methods to get or set the
* value using java bean naming conventions OR it should use javafx property
* definition conventions. The factory will automatically listen for standard
* java bean changes using <code>PropertyChangeListener</code> approaches unless
* you indicate to not to.
* <p>
* When the bean itself changes, the properties fire to indicate that their
* values may have changed and the observing object should update itself. This
* object allows you to integrate your javafx/POJOs into the binding
* infrastructure without being dependent on the actual underlying bean. If you
* are familiar with jgoodies <code>BindingAdapter</code> this is a similar
* class.
* <p>
* This only handles reading bean properties. Need to add set() logic.
* <p>
* TODO: Make this work better. Many corner cases to cover.
* <p>
* TODO: Instead of just method calls on POJOs, also check for PCL. Note that
* javafx properties won't work easily they are always tied to the underlying
* object so I would have to write another CaptiveObjectProperty object that is
* essentially a delegator.
public class BeanPropertyFactory<T> extends ObjectProperty<T> {
ObservableValue<T> channel;
Map<String, CaptiveObjectProperty> properties = new HashMap<String, CaptiveObjectProperty>();
boolean listenForBeanPCLEvents = true;
public boolean isListenForBeanPCLEvents() {
return listenForBeanPCLEvents;
public void setListenForBeanPCLEvents(boolean listenForBeanPCLEvents) {
this.listenForBeanPCLEvents = listenForBeanPCLEvents;
if (getBean() != null)
removeBeanPCLListener(getBean());
* The bean channel where the bean is obtained.
* @return
public ObservableValue<T> getChannel() {
return channel;
public BeanPropertyFactory() {
setChannel(new ObjectProperty());
public BeanPropertyFactory(ObservableValue<T> channel) {
if (channel == null)
setChannel(new ObjectProperty());
else
setChannel(channel);
protected void setChannel(ObservableValue<T> channel) {
if (this.channel != null) {
removeBeanChangeListener(this.channel);
this.channel = channel;
if (this.channel != null) {
addBeanChangeListener(this.channel);
updateStringProperty(getBean());
invalidateProperties();
fireValueChangedEvent();
protected StringProperty stringProperty = new StringProperty();
* The string property is an observable toString property. It cannot be set.
* @return
public StringProperty beanStringProperty() {
return stringProperty;
public String getBeanString() {
return beanStringProperty().getValue();
* A listener that listens to changes in the bean channel. This only fires
* when the bean changes not when the properties on the bean change. The
* default actions updates the "string" property representation of this
* object as well as attaches property change listeners.
* @author Mr. Java
protected class BeanChangeListener implements ChangeListener {
@Override
public void changed(ObservableValue arg0, Object arg1, Object arg2) {
if (arg1 != null) {
BeanPropertyFactory.this.removeBeanPCLListener(arg1);
if (arg2 != null) {
BeanPropertyFactory.this.addBeanPCLListener(arg2);
updateStringProperty(arg2);
protected void updateStringProperty(Object obj) {
if (obj != null)
beanStringProperty().setValue(obj.toString());
else
beanStringProperty().setValue("null");
protected void removeBeanChangeListener(ObservableValue<T> obj) {
if (beanChangeListener == null)
beanChangeListener = createBeanChangeListener();
if (obj != null) {
obj.addListener(beanChangeListener);
protected void addBeanChangeListener(ObservableValue<T> obj) {
if (beanChangeListener == null)
beanChangeListener = createBeanChangeListener();
if (obj != null)
obj.removeListener(beanChangeListener);
* The instance of a change listener for detecting when the bean in the bean
* channel changes.
ChangeListener beanChangeListener = new BeanChangeListener();
* Subclass can override to create their bean change listener.
* @return
protected ChangeListener createBeanChangeListener() {
return new BeanChangeListener();
public BeanPropertyFactory(T bean) {
setChannel(new ObjectProperty(bean));
public Property getProperty(String property) {
if (property == null || property.isEmpty())
throw new IllegalArgumentException("Property cannot be null");
if (properties.containsKey(property))
return properties.get(property);
CaptiveObjectProperty p = new CaptiveObjectProperty(this, property);
properties.put(property, p);
return p;
@Override
public T getValue() {
return getBean();
* A listener that listens for property change events on the bean. When the
* bean changes, the listener must be removed then attached to the new bean
* but can use the same instance of this class. The action is to inform any
* existing property objects that the property has changed. The detection of
* property changes is centralized in the factory class for efficiency.
protected class BeanPropertyListener implements PropertyChangeListener {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (properties.containsKey(evt.getPropertyName())) {
CaptiveObjectProperty p = properties.get(evt.getPropertyName());
p.propertyChanged();
updateStringProperty(getBean());
* The cached listener instance to listen to the bean (in the bean channel)
* property change events if it supports PCL.
PropertyChangeListener beanPropertyListener;
* Subclasses can override to implement their own behavior. Its best to
* extend from <code>BeanPropertyListiner</code> to include the default
* behavior.
* @return
protected PropertyChangeListener createBeanPropertyListener() {
return new BeanPropertyListener();
* Add a listener only if the PCL methods exist. This listens for property
* changes on the bean's property not changes in the actually bean held by
* the bean channel.
protected void addBeanPCLListener(Object obj) {
if (!isListenForBeanPCLEvents())
return;
if (obj != null) {
if (BeanPropertyUtils.hasPCL(obj.getClass())) {
if (beanPropertyListener == null)
beanPropertyListener = createBeanPropertyListener();
BeanPropertyUtils.addPCL(obj, beanPropertyListener, null);
* Remove a listener only if the PCL methods exist.
* @see #attachBeanPCLListener
protected void removeBeanPCLListener(Object obj) {
if (obj != null) {
if (BeanPropertyUtils.hasPCL(obj.getClass())) {
if (beanPropertyListener == null)
beanPropertyListener = createBeanPropertyListener();
BeanPropertyUtils.removePCL(obj, beanPropertyListener, null);
* Invalidate the properties in the property cache. Then changed the bean in
* the bean channel. Then fire a value changed event.
* @param bean
public void setBean(T bean) {
invalidateProperties();
if (getChannel() instanceof WritableValue) {
((WritableValue) getChannel()).setValue(bean);
} else {
throw new IllegalArgumentException(
"Could not set bean value into a non-writable bean channel");
fireValueChangedEvent();
* Called to indicate that the underlying bean changed.
protected void invalidateProperties() {
for (CaptiveObjectProperty p : properties.values()) {
p.invalidate();
public T getBean() {
return getChannel().getValue();
* Lazily get the method representing the property prior to getting or
* setting. Because this is a property, it can also be bound to.
* @author Mr. Java
* @param <T>
protected static class CaptiveObjectProperty<T> extends
ObjectPropertyBase<T> {
* The string name of the property.
String readPropertyName, writePropertyName;
* If the property is really a javafx property, it is stored here.
Property<T> enhancedProperty;
* Used if the property is not an enhanced property.
Method readMethod, writeMethod;
* The factory that holds the bean we obtain values against.
BeanPropertyFactory factory;
public CaptiveObjectProperty(BeanPropertyFactory factory,
String property) {
this.readPropertyName = property;
this.factory = factory;
public CaptiveObjectProperty(BeanPropertyFactory factory,
String property, String writePropertyName) {
this.readPropertyName = property;
this.writePropertyName = writePropertyName;
this.factory = factory;
@Override
public Object getBean() {
if (factory == null || factory.getBean() == null)
return null;
return factory.getBean();
@Override
public void store(T value) {
if (writeMethod == null && enhancedProperty == null) {
getWriteMethod(value.getClass());
if (writeMethod == null && enhancedProperty == null) {
return;
try {
if (enhancedProperty != null) {
enhancedProperty.setValue(value);
return;
if (getBean() == null)
return;
writeMethod.invoke(getBean(), value);
return;
} catch (Exception e) {
e.printStackTrace();
@Override
public T getValue() {
if (readMethod == null && enhancedProperty == null) {
getReadMethod();
if (readMethod == null && enhancedProperty == null)
return null;
try {
if (enhancedProperty != null)
return enhancedProperty.getValue();
if (factory.getBean() == null)
return null;
Object rval = readMethod.invoke(getBean());
return (T) rval;
} catch (Exception e) {
e.printStackTrace();
return null;
@Override
public String getName() {
return readPropertyName;
* Invalidate the method. Perhaps the bean changed to another object and
* we should find the method on the new object. This is called prior to
* the <code>getBean()</code> being changed.
public void invalidate() {
readMethod = null;
fireValueChangedEvent();
* This is used to externally signal that the property has changed. It
* is quite possible that this object does not detect those changes and
* hence, an external object (in all cases the BeanPropertyFactory) will
* signal when a change occurs. Property change detection is centralized
* in the factory for efficiency reasons.
public void propertyChanged() {
fireValueChangedEvent();
protected Property getJavaFXReadProperty(String propertyName) {
if (factory.getBean() == null)
return null;
String methodName = getName() + "Property";
try {
Method mtmp = factory.getBean().getClass()
.getMethod(methodName, new Class<?>[0]);
enhancedProperty = (Property) mtmp.invoke(factory.getBean(),
new Object[0]);
return enhancedProperty;
} catch (Exception e) {
// e.printStackTrace();
// silently fail here
return null;
protected void getWriteMethod(Class<?> argType) {
if (factory == null || factory.getBean() == null)
return;
if (enhancedProperty == null)
enhancedProperty = getJavaFXReadProperty(getName());
if (enhancedProperty != null)
return;
writeMethod = getPojoWriteMethod(getName(), argType);
* Sets the method, either an enhanced property or the POJO method via
* reflection.
* @return
protected void getReadMethod() {
if (factory == null || factory.getBean() == null)
return;
enhancedProperty = getJavaFXReadProperty(getName());
if (enhancedProperty != null)
return;
// Look for standard pojo method.
readMethod = getPOJOReadMethod(getName());
* Return a get method using reflection.
* @param propertyName
* @return
protected Method getPOJOReadMethod(String propertyName) {
if (factory.getBean() == null)
return null;
// Look for standard pojo method.
String methodName = getGetMethodName();
try {
Method mtmp = factory.getBean().getClass()
.getMethod(methodName, new Class<?>[0]);
return mtmp;
} catch (Exception e) {
// silently fail here
// e.printStackTrace();
return null;
protected String getGetMethodName() {
String methodName = "get"
+ Character.toUpperCase(getName().charAt(0));
if (getName().length() > 1)
methodName += getName().substring(1);
return methodName;
* Return a set method using reflection.
* @param propertyName
* @param argType
* @return
protected Method getPojoWriteMethod(String propertyName,
Class<?> argType) {
if (factory.getBean() == null)
return null;
String methodName = getSetMethodName();
try {
Method mtmp = factory.getBean().getClass()
.getMethod(methodName, argType);
return mtmp;
} catch (Exception e) {
// silently fail here
// e.printStackTrace();
return null;
protected String getSetMethodName() {
String methodName = "set"
+ Character.toUpperCase(getName().charAt(0));
if (getName().length() > 1)
methodName += getName().substring(1);
return methodName;
* Obtain a property using the binding path. The binding path should be
* simple property names separated by a dot. The bean has to specified
* because the return value is a property that can be used directly for
* binding. The first property specified in the binding path should be a
* property on the bean.
* <p>
* The difference between this and <code>Bindings.select()</code> is not
* much other that it uses the bean factory machinery and the path can be
* specified as a string. Of course, the bean can be a plain pojo.
* @param bindingPath
* @return
public static Property propertyFromBindingPath(Object bean,
String bindingPath) {
if (bindingPath == null || bindingPath.isEmpty())
return null;
BeanPropertyFactory lastFactory = null;
Property lastProperty = null;
String[] parts = bindingPath.split("\\.");
if (parts.length > 0) {
for (int i = 0; i < parts.length; i++) {
if (parts.length() <= 0 || parts[i].isEmpty()) {
throw new IllegalArgumentException("Binding path part " + i
+ " has no length");
BeanPropertyFactory newFactory;
if (i == 0)
newFactory = new BeanPropertyFactory(bean);
else
newFactory = new BeanPropertyFactory(
(WritableValue) lastProperty);
lastProperty = newFactory.getProperty(parts[i].trim());
lastFactory = newFactory;
return lastProperty;
* Alot like <code>Bindings.select</code> but also handles pojos.
* @param bean
* @param path
* @return
public static Property propertyFromBindingPath(Object bean, String... path) {
String tmp = "";
for (int i = 0; i < path.length; i++) {
tmp += path[i];
if (i <= path.length - 1)
tmp += ".";
return propertyFromBindingPath(bean, tmp);
and a supporting classpackage scenegraphdemo;
import java.beans.PropertyChangeListener;
* Static methods for manipulating PCL for standard java beans.
* @author Mr. Java
public class BeanPropertyUtils {
protected final static Class<?>[] NO_ARGS = new Class<?>[] { PropertyChangeListener.class };
protected final static Class<?>[] ARGS = new Class<?>[] { String.class,
PropertyChangeListener.class };
protected final static String pclAddMethodName = "addPropertyChangeListener";
protected final static String pclRemoveMethodName = "removePropertyChangeListener";
* Return true if the class has PCL methods. Does not check for remove.
* <p>
* addPropertyChangeListener(PropertyChangeListener)
* <p>
* addPropertyChangeListener(String, PropertyChangeListener)
* @param bean
* @return
public static boolean hasPCL(Class<?> clazz) {
try {
if (clazz.getMethod(pclAddMethodName, NO_ARGS) != null) {
return true;
} catch (Exception e) {
// silently fail
try {
if (clazz.getMethod(pclAddMethodName, ARGS) != null) {
return true;
} catch (Exception e) {
// silently fail
return false;
* Add a listener.
* @param bean
* @param listener
* @param propertyName
public static void addPCL(Object bean, PropertyChangeListener listener,
String propertyName) {
try {
if (propertyName == null) {
bean.getClass().getMethod(pclAddMethodName, NO_ARGS)
.invoke(bean, new Object[] { listener });
} else {
bean.getClass()
.getMethod(pclAddMethodName, ARGS)
.invoke(bean,
new Object[] { propertyName, listener });
} catch (Exception e) {
e.printStackTrace();
* Remove a listener.
* @param bean
* @param listener
* @param propertyName
public static void removePCL(Object bean, PropertyChangeListener listener,
String propertyName) {
try {
if (propertyName == null) {
bean.getClass().getMethod(pclRemoveMethodName, NO_ARGS)
.invoke(bean, new Object[] { listener });
} else {
bean.getClass()
.getMethod(pclRemoveMethodName, ARGS)
.invoke(bean,
new Object[] { propertyName, listener });
} catch (Exception e) {
e.printStackTrace();
-
How to bind complex input/output types in web service data control
Hi,
I have created data control using external web service for simple input & output data type and its working fine.
But I don't know how it can be done for complex data types.
My external Web services have complex input & output types. Such as java object which contains another java object again it contains another java object or arry or java collection etc.
Each my service has one complex input data type and for this no user input is require so how I can do it without using any component for it.
I want to bind my page components with this input & output type.
What is the best approach to do this and how to bind screen component.
Regards,
DevangHi,
Thanks frank.
I already check this link before posting this so if you have any other link then kindly reply.
Regards,
Devang -
How to convert an array collection instance to a complex object for interaction with webservice
Hi there,
I have a stubborn problem that I am trying to work out the best way to solve the problem. I am interacting with a WebService via HTTPService calling a method called find(String name) and this returns me a List of ComplexObjects that contain general string and int params and also lists of other Complex Objects. Now using the code:
ArrayCollection newOriginalResultsArray = new ArrayCollection(event.result as Array)
flex converts my complex objects results to an arraycollection so that I can use it in datagrids etc. Now up until this part is all good. My problem is when getting a single instance from the results list, updating it by moving data around in a new datagrid for example - I want to interact with the webservice again to do an create/update. This is where I am having problems - because these webservice methods require the complex object as a parameter - I am struggling to understand how I can convert the array collection instance back to my complex object without iterating over it and casting it back (maybe this is the only way - but I am hoping not).
I am hoping that there is a simple solution that I am missing and that there is some smart cookie out there that could provide me with an answer - or at least somewhere to start looking. I guess if I have no other alternative - maybe I need to get the people who built the service to change it to accept an array - and let them do the conversion.
Any help would be greatly appreciated.
BertHi Bert,
According to my knowledge you can use describeType(Object) method which will return an XML... That XML will contain Properties and values just iterate through the XML and create a new Object.. Probably u can use this method...
public function getObject(reqObj:Object,obj:Object,instanceName:String,name:String=null,index:int=-1):Obj ect
if(!reqObj)
reqObj = new Object();
var classInfo:XML = describeType(obj);
var className:String = instanceName;
if(name!=null)
className=name+"."+className;
if(index!=-1)
className=className+"["+index+"]";
for each (var v:XML in classInfo..accessor)
var attributeName:String=v.@name;
var value:* = obj[attributeName]
var type:String = v.@type;
if(!value)
reqObj[className+"."+attributeName] = value;
else if(type == "mx.collections::ArrayCollection")
for(var i:int=0;i<value.length;i++)
var temp:Object=value.getItemAt(i);
getReqObject(reqObj,temp,attributeName,className,i);
else if(type == "String" || type == "Number" || type == "int" || type == "Boolean")
reqObj[ className+"."+attributeName] = value;
else if (type == "Object")
for (var p:String in value)
reqObj[ className+"."+attributeName+"."+p] = value[p];
else
getReqObject(reqObj,value,attributeName,className);
return reqObj;
Thanks,
Pradeep -
How to bind schema form data to existing objects?
I imported an existing PDF as my template and it make all the text, check boxes and text fields into objects - Great!
But now when I add a schema with my DB data field names I am unsure how to turn the existing objects on the form to the schema fields!!
Can anyone help?Open the DataView where your schema is visually represented and simply drag and drop the schema item onto the object that you want to bind it to. If the bind is successful a little icon will appear in the DataView beside the node.
If you select on object in the form and click on the Binding tab, you will see an expression representing what you are bound to. You can also use the icon there to navigate to the appropriate node in the schema. -
How to bind Links Detail Button to an object?
Hi,
As per the WebCenter Dev Guide, we can create link from "Any object to which you bind the custom JSF components, such as the Links Detail Button".
How to bind Link Details Button to an object?
TIAmaple_shaft wrote:
Each object has a unique id associated to it. One can retrieve that id string from an object by calling the toString() method, as long as this method hasn't been overridden from its default behavior.and if it has System has a method to help you.
But it is not quite a unique id. It might be, but a different JVM could implemented it as "return 1" and it would still technically satisfy the contract.
As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.) -
How to bind bar chart(columns) to array list object in c# win form
how to bind bar chart(columns) to array list object in c#win form
Hi Ramesh,
Did you want to bind list object to bar chart? I made a simple code to achieve binding list to bar chart.
public partial class Form0210 : Form
public Form0210()
InitializeComponent();
private void Form0210_Load(object sender, EventArgs e)
BindData();
public void BindData()
List<int> yValues = new List<int>(new int[] { 20, 30, 10, 90, 50 });
List<string> xValues = new List<string>(new string[] { "1:00", "2:00", "3:00", "4:00", "5:00" });
chart1.Series[0].Points.DataBindXY(xValues, yValues);
The links below might be useful to you:
# Data Binding Microsoft Chart Control
http://blogs.msdn.com/b/alexgor/archive/2009/02/21/data-binding-ms-chart-control.aspx
# Series and Data Points (Chart Controls)
https://msdn.microsoft.com/en-us/library/vstudio/dd456769(v=vs.100).aspx
In addition, if I misunderstood you, please share us more information about your issue.
Best Regards,
Edward
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
How to bind a user selected value to a view object bind variable?
Hi
I have two pages in ADF BC application. In the first page ,i will give a drop down menu to user which displays all the table names in my databse.
when the user selects a table and goes to the second page..he should be given a menu or a check list of all the columns in the user selected table....
to display the columns i have used the query
Select COLUMN_NAME from user_tab_columns where table_name = : table_name in the view object.
now how to bind the user selected table value in the first page to the table_name bind variable in view object ?
thanks
swathi.Hi,
depends on how the select box is implemented. With ADF and ADF Faces, the default value selection is the list index. In a value change listener you could look up the selected value from the underlying iterator. Store this value e.g. in a session attribute and point the NDValue of the ExecuteWithParams operation to #{sessionScope.your_attribute}
Frank -
How to bind an object to JNDI tree in iAS?
Hi all,
When I try to bind a string object to jndi tree, the following exception
occurs:
javax.naming.NamingException: Unable to get object instance from reference.
Roo
t exception is javax.naming.NamingException: Can't bind instance of class
java.lang.String
at com.netscape.server.jndi.RootContext.bindCtx(Unknown Source)
at com.netscape.server.jndi.RootContext.rebind(Unknown Source)
at com.netscape.server.jndi.RootContext.rebind(Unknown Source)
at javax.naming.InitialContext.rebind(InitialContext.java:385)
at jsp.APPS.bmx.test2._jspService(test2.java:76)
at jsp.APPS.bmx.test2.service(test2.java:42)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
at
com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown
Source)
The code fragment is:
Context ctx = new InitialContext();
String str = "hell,every one!";
ctx.rebind("abc", str);
Can anyone give some help? Thanks in advance.
JohnsonTo bind an object into the JNDI tree check the documentation here:
http://e-docs.bea.com/wls/docs81/jndi/jndi.html#475702
If this is to be used by all your applications that you deploy on the server check out the startup/shutdown class documentation here:
http://edocs.bea.com/wls/docs81/ConsoleHelp/startup_shutdown.html
Cheers
IV -
How to bind list data to XML Web service request
How do I bind specific columns in a DataGrid to the Web
service request? I'm having trouble finding any documentation that
addresses that specific pattern, i.e. sending a complex list to the
server via a Flex Web service send() command. I'm fairly new to
Flex programming and don't know if what I want to do is possible.
Here what I've been able to do so far.
1. Using a Web service called a service on the server and
retrieved a complex list.
2. Poplulated a DataGrid with the result
3. The user has selected multiple rows from the DataGrid
using a checkbox column
4. The user pressed a button that calls a Web service send().
This Web service should only send data from only two columns and
only for those rows the user has checked.
5. I can loop over the DataGrid and find the selected rows
and put them in another ArrayCollection called 'selectedRows'.
The issue is that I don't know how to bind 'selectedRows' to
the Web service. Right now I'm reading up on "Working with XML" in
the Programming with ActionScript 3.0 chapter. But I'm just fishing
here. No bites yet.Don't bind. Build the request object programatically, as you
are doing with your selectedRows AC, and send(myObject) that.
Tracy -
I am developing a desktop application in Wpf using MVVM and Entity Frameworks. I have the following tables:
1. Party (PartyId, Name)
2. Case (CaseId, CaseNo)
3. Petitioner (CaseId, PartyId) ............. Link Table
I am completely new to .Net and to begin with I download Microsoft's sample application and
following the pattern I have been successful in creating several tabs. The problem started only when I wanted to implement many-to-many relationship. The sample application has not covered the scenario where there can be a any-to-many relationship. However
with the help of MSDN forum I came to know about a link table and managed to solve entity framework issues pertaining to many-to-many relationship. Here is the screenshot of my application to show you what I have achieved so far.
And now the problem I want the forum to address is how to bind a combo box so that it retrieves Party.Name for the corresponding PartyId in the Link Table and also I want to populate it with Party.Name so that
users can choose one from the dropdown list to add or edit the petitioner.Hello Barry,
Thanks a lot for responding to my query. As I am completely new to .Net and following the pattern of Microsoft's Employee Tracker sample it seems difficult to clearly understand the concept and implement it in a scenario which is different than what is in
the sample available at the link you supplied.
To get the idea of the thing here is my code behind of a view vBoxPetitioner:
<UserControl x:Class="CCIS.View.Case.vBoxPetitioner"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:v="clr-namespace:CCIS.View.Case"
xmlns:vm="clr-namespace:CCIS.ViewModel.Case"
mc:Ignorable="d"
d:DesignWidth="300"
d:DesignHeight="200">
<UserControl.Resources>
<DataTemplate DataType="{x:Type vm:vmPetitioner}">
<v:vPetitioner Margin="0,2,0,0" />
</DataTemplate>
</UserControl.Resources>
<Grid>
<HeaderedContentControl>
<HeaderedContentControl.Header>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<TextBlock Margin="2">
<Hyperlink Command="{Binding Path=AddPetitionerCommand}">Add Petitioner</Hyperlink>
| <Hyperlink Command="{Binding Path=DeletePetitionerCommand}">Delete</Hyperlink>
</TextBlock>
</StackPanel>
</HeaderedContentControl.Header>
<ListBox BorderThickness="0" SelectedItem="{Binding Path=CurrentPetitioner, Mode=TwoWay}" ItemsSource="{Binding Path=tblParties}" />
</HeaderedContentControl>
</Grid>
</UserControl>
This part is working fine as it loads another view that is vPetioner perfectly in the manner I want it to be.
Here is the code of vmPetitioner, a ViewModel:
Imports Microsoft.VisualBasic
Imports System.Collections.ObjectModel
Imports System
Imports CCIS.Model.Party
Namespace CCIS.ViewModel.Case
''' <summary>
''' ViewModel of an individual Email
''' </summary>
Public Class vmPetitioner
Inherits vmParty
''' <summary>
''' The Email object backing this ViewModel
''' </summary>
Private petitioner As tblParty
''' <summary>
''' Initializes a new instance of the EmailViewModel class.
''' </summary>
''' <param name="detail">The underlying Email this ViewModel is to be based on</param>
Public Sub New(ByVal detail As tblParty)
If detail Is Nothing Then
Throw New ArgumentNullException("detail")
End If
Me.petitioner = detail
End Sub
''' <summary>
''' Gets the underlying Email this ViewModel is based on
''' </summary>
Public Overrides ReadOnly Property Model() As tblParty
Get
Return Me.petitioner
End Get
End Property
''' <summary>
''' Gets or sets the actual email address
''' </summary>
Public Property fldPartyId() As String
Get
Return Me.petitioner.fldPartyId
End Get
Set(ByVal value As String)
Me.petitioner.fldPartyId = value
Me.OnPropertyChanged("fldPartyId")
End Set
End Property
End Class
End Namespace
And below is the ViewMode vmParty which vmPetitioner Inherits:
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports CCIS.Model.Case
Imports CCIS.Model.Party
Imports CCIS.ViewModel.Helpers
Namespace CCIS.ViewModel.Case
''' <summary>
''' Common functionality for ViewModels of an individual ContactDetail
''' </summary>
Public MustInherit Class vmParty
Inherits ViewModelBase
''' <summary>
''' Gets the underlying ContactDetail this ViewModel is based on
''' </summary>
Public MustOverride ReadOnly Property Model() As tblParty
'''' <summary>
'''' Gets the underlying ContactDetail this ViewModel is based on
'''' </summary>
'Public MustOverride ReadOnly Property Model() As tblAdvocate
''' <summary>
''' Gets or sets the name of this department
''' </summary>
Public Property fldName() As String
Get
Return Me.Model.fldName
End Get
Set(ByVal value As String)
Me.Model.fldName = value
Me.OnPropertyChanged("fldName")
End Set
End Property
''' <summary>
''' Constructs a view model to represent the supplied ContactDetail
''' </summary>
''' <param name="detail">The detail to build a ViewModel for</param>
''' <returns>The constructed ViewModel, null if one can't be built</returns>
Public Shared Function BuildViewModel(ByVal detail As tblParty) As vmParty
If detail Is Nothing Then
Throw New ArgumentNullException("detail")
End If
Dim e As tblParty = TryCast(detail, tblParty)
If e IsNot Nothing Then
Return New vmPetitioner(e)
End If
Return Nothing
End Function
End Class
End Namespace
And final the code behind of the view vPetitioner:
<UserControl x:Class="CCIS.View.Case.vPetitioner"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vm="clr-namespace:CCIS.ViewModel.Case"
mc:Ignorable="d"
Width="300">
<UserControl.Resources>
<ResourceDictionary Source=".\CompactFormStyles.xaml" />
</UserControl.Resources>
<Grid>
<Border Style="{StaticResource DetailBorder}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="Petitioner:" />
<ComboBox Grid.Column="1" Width="240" SelectedValuePath="." SelectedItem="{Binding Path=tblParty}" ItemsSource="{Binding Path=PetitionerLookup}" DisplayMemberPath="fldName" />
</Grid>
</Border>
</Grid>
</UserControl>
The problem, presumably, seems to be is that the binding path "PetitionerLookup" of the ItemSource of the Combo box in the view vPetitioner exists in a different ViewModel vmCase which serves as an ObservableCollection for MainViewModel. Therefore,
what I need to Know is how to route the binding path if it exists in a different ViewModel?
Sir, I look forward to your early reply bringing a workable solution to the problem I face.
Warm Regards,
Arun
Maybe you are looking for
-
Error- while assigng FF-Owners to FF-Id's in GRC-10 AC
Hi Experts, Iam facing issue as below.. while configuring Super user assignment (while assigning owners to FF Ids) Please let me konow if nay one of you encountered same issue and how you resolved.. Error while processing your query What has happen
-
How do I partition my Time Machine back up drive (G-Drive) to back up both my IMac and my MacBook Air?
-
I just downloaded Creator to try it out. I went through the tutorials and now im starting to duplicate a c-cgi project to see how much easier it would be to develop it with Creator. Right now I have it connecting to an ingres database and the connect
-
RFC_NO_AUTHORITY - dump
Bonjour guys, I am getting a dump: RFC_NO_AUTHORITY User "TMSADM" has no RFC authorization for function group "SEUEXIST". How to correct the error You can check the RFC authorization beforehand with the function module AUTHORITY_CHECK_RFC.
-
DEBMDM06 based Idocs: Simple XML Vs Complex XML
The idocs we extracted from ECC "mdmc" Tcode based on DEBMDM type. Are they simple XML or Complex XML?? because we operate on AIX and according to IM referecne guide AIX does not support Complex XML via Import server