Displaying Complex Java Objects using netui
I have a java object with the following structure.
obj1
int name;
String ID;
ArrayList obj2;//coniatns multiple obj2 objects
obj2
int name;
String ID;
ArrayList obj3; //coniatns multiple obj3 objects
obj3
int name;
String ID;
How and what netui tags can I use to display this kind of structure for obj1?
I tried repeaters and it is not working for me.
Also if I have a structure like this
ArrayList obj4; //contains arrays's of multiple items.
obj4
String[] eventTime;
String[] eventDate;
How can I display this in a grid fashion using netui? The netui:gid tag only
wirks with RowSet and I have an ArrayList?
If I want to use simple jsp and not use netui tags what is the context for accessing
my form that I have in my page flow from the jsp? e.g. if I have a form in my
page flow called listForm which has gets and sets for
String[] eventTime;
String[] eventDate;
what is the context I use in my jsp to print values of eventTime and eventDate
in a grid like fashion without using nteui? I tried 'request' context but it
does not work. In netui we can use actionForm or pageFlow etc but what about
simple jsp context?
Please reply soon. Thanks
Try the <netui-data:getData> tag in the workshop documentation, It gives an example
"Kush" <[email protected]> wrote:
>
I have a java object with the following structure.
obj1
int name;
String ID;
ArrayList obj2;//coniatns multiple obj2 objects
obj2
int name;
String ID;
ArrayList obj3; //coniatns multiple obj3 objects
obj3
int name;
String ID;
How and what netui tags can I use to display this kind of structure for
obj1?
I tried repeaters and it is not working for me.
Also if I have a structure like this
ArrayList obj4; //contains arrays's of multiple items.
obj4
String[] eventTime;
String[] eventDate;
How can I display this in a grid fashion using netui? The netui:gid
tag only
wirks with RowSet and I have an ArrayList?
If I want to use simple jsp and not use netui tags what is the context
for accessing
my form that I have in my page flow from the jsp? e.g. if I have a form
in my
page flow called listForm which has gets and sets for
String[] eventTime;
String[] eventDate;
what is the context I use in my jsp to print values of eventTime and
eventDate
in a grid like fashion without using nteui? I tried 'request' context
but it
does not work. In netui we can use actionForm or pageFlow etc but what
about
simple jsp context?
Please reply soon. Thanks
Similar Messages
-
Write to java object using netui:select tag
Hello,
I am iterating through a hashmap of java objects using a netui-data:repeater.
<netui-data:repeater dataSource="{pageFlow.MyHashMap}">
<netui-data:repeaterItem>
<netui-data:repeater dataSource= "{container.item.HashMapOfEmbeddedObjects}">
<netui-data:repeaterItem>
<netui:select dataSource= "{container.item.type}" optionsDataSource= "{container.item.typeChoices}" /> </td>
<netui:select dataSource= "{container.item.default}"
optionsDataSource= "{container.item.defaultChoices}" /> </td>
</netui-data:repeaterItem>
</netui-data:repeater>
</netui-data:repeaterItem>
</netui-data:repeater>
The java object has a field "HashMapOfEmbeddedObjects" that is itself a hashmap of java objects. I want to be able to make a selection and have it be written to the
"type" and "default" fields of the embedded objects, but dataSource="{container.item.default}" does not save the value of the selection.
Is there anyway to use the netui:select tag to write to the field on a java object? Any help is greatly appreciated.I have done it in the past. The java object need not be actionForm. The following write-up I found in edocs will help you achieve this.
Page Flow-Scoped Form Beans
Page Flow-scoped Form Bean instances have the same life-cycle as the Controller file instance. They are created and destroyed when the Controller file instance is created and destroyed. This makes Page Flow-scoped Form Beans useful for storing data that has been accumulated across many different JSP pages.
To create a Page Flow-scoped Form Bean instance, construct a public member variable of the Form Bean in the Controller file.
public class myController extends PageFlowController
public MyFormBean pageFlowScopedBean = new MyFormBean();
Once you have created a Page Flow-scoped instance of a Form Bean, you can pass the instance to action methods by using the @action form="form_bean" annotation.
public class myController extends PageFlowController
public MyFormBean pageFlowScopedBean = new MyFormBean();
* @jpf:action form="pageFlowScopedBean"
* @jpf:forward name="success" path="displayData.jsp"
protected Forward submit( MyFormBean form )
return new Forward( "success" );
Each time the submit() method is invoked, it is passed the same instance of the Form Bean, namely, pageFlowScopedBean, the instance that was created when the Controller file instance was created.
For more info go to http://e-docs.bea.com/workshop/docs81/doc/en/workshop/guide/netui/guide/conReqScopedVsPageScopedBean.html
Good luck.
--SJ -
Persistenance for Java Objects Using Toplink
Hi All Happy New Year
I am trying the a tutorial in Jdeveloper 10.1.3.0.4 called
Provide Persistenance for Java Objects Using Toplink.
I have followed the instructions and get the following error.
com.evermind.reflect.UndeclaredExceptionTypeException: oracle.oc4j.rmi.OracleRemoteException
at __Proxy1.persistEntity(Unknown Source)
at acme.ejb.session.EmpSessionClient.main(EmpSessionClient.java:29)
oracle.oc4j.rmi.OracleRemoteException: Invocation error: java.lang.NoSuchMethodException: acme.ejb.session.EmpSession.persistEntity(java.lang.Object)
The release notes mention TopLink POJO's Must Implement java.io.Serializable When Returned From a Session Bean's Remote Interface (4902787) When creating a session bean facade for TopLink POJO objects, you must implement java.io.Serializable for each of the TopLink POJO objects returned from the SessionBean facade through a remote interface. This is typically required when using ADF Swing, a EJB Sample Client, or when your EJB Session Bean resides on a separate application server from the client. You can also tell you you need to implement java.io.Serializable when you get the following exception:
com.evermind.reflect.UndeclaredExceptionTypeException:
/oracle.oc4j.rmi.OracleRemoteException/
at __Proxy1.[Your Class Name Here] (Unknown Source)
The workaround is to manually edit each POJO object to implement java.io.Serializable.
I have only one POJO which is declared as follows:
public class EmpInfo implements Serializable {
Can anybody help me understand what I need to do to get it to work?
Many Thanks in AdvanceHi,
can you send me your test scenario/project at anuj dot k dot jain at oracle dot com. I tried reproducing this but was unable to do so.
Thanks,
anuj dot k dot jain at oracle dot com -
How to instantiate a java object (using JNI)?(n'more)
hey bschauwe, thanks for your last post, you were guessing but your 4th guess was right on the money of how id like to do it.
"4. An alternative way to return data to java from C is to instantiate a java object (using JNI), then use JNI to call that object's setters, then return the object at the end of the C routine."
I know now how to get the object's setters, I am just unsure how to instantiate a java object from the native C code using JNI. Also you said to returnt he object at the end of the c routine, that is just a good ol' return statement right? no other functions to release memory or anything are needed? So basically it would be something like:
JNIEXPORT jobject retObj JNICALL Java_AbfaRegion_getJSourceData
(JNIEnv *env, jobject thisObj)
//instantiate the java object on retObj????
//call setters with values from the c structures...
//return retObj??? no other memory releasing needed?
}Thanks again for all your help,
ShaneK sounds straight forward enough, the index in my book had nothing on <init> and I wasnt aware of the NewObject call. So my final (well for demonstration purposes) code should look something like:
JNIEXPORT jobject retObj JNICALL Java_AbfaRegion_getJSourceData
(JNIEnv *env, jobject thisObj)
jclass clazz;
jclass clazzTemp;
jmethodID mid;
jint val;
jobject tempObj;
//first instanciate the object
clazz = (*env)->GetObjectClass(env, retObj);
mid = (*env)->GetMethodID(env, clazz, "<init>", "()V");
//Get Object
tempObj = (*env)->NewObject(env, clazz, mid);
//get Class reference to instantiated class
clazzTemp = (*env)->GetObjectClass(env, tempObj);
//Start calling setters to set the object up.
mid = (*env)->GetMethodID(env, clazzTemp, "SetHeight", "(I)V");
(*env)->CallVoidMethod(env,tempObj, mid, struct->myHeight);
//set more members ...
//return the object back to java with its members filled out.
//before returning do I need to call (*env)->DeleteLocalRef(tempObj); ??
return tempObj;
}So is this how i do it for a function that is nativly defined as:
public native JSources getJSourceData();?
if this is right, then im cooking, and cannot thank you enough!
-Shane -
Design pattern for converting multiple complex Java objects to XML
What is the traditionally accepted high performance mechanism for converting Java objects to XML? Some options I have explored are:
1. SAX-JAXP
2. DOM-JAXP
3. JAXB
4. Castor
Which of these usually performs the best for large, complex objects which contain multiple subobjects?
Thanks.Take a look at XStream. It will simplify your life considerably.
Typical code snipped
XStream xStream = new XStream();
xStream.toXML(someJavaObject);That's it. Regarding the others...
1. SAX-JAXP
Can be used for XML -> Java Objects, but you have to write significant amounts of ugly, high maintainenance code
2. DOM-JAXP
Slower and more memory intensive than SAX because you need to read the whole object into memory first. Just as ugly and high maintenance.
3. JAXB
Actually very good for going from a POJO to XML, but rubbish in the opposite direction. The worst part is it adds an extra step to your build process as you need to tell it to generate and compile the source for doing this.
4. Castor
Not used it since JAXB came out. Works pretty much in the same way but also supports XML -> POJOs. -
Generation of XML file from Java objects using castor
I have the following java file(Customer.java).
public class Customer
private String ID;
private FirstName firstName;
private MiddleName middleName;
private LastName lastName;
private ArrayList address;
public ArrayList getAddress() {
return address;
public void setAddress(ArrayList address) {
this.address = address;
public FirstName getFirstName() {
return firstName;
public void setFirstName(FirstName firstName) {
this.firstName = firstName;
public String getID() {
return ID;
public void setID(String id) {
ID = id;
public LastName getLastName() {
return lastName;
public void setLastName(LastName lastName) {
this.lastName = lastName;
public MiddleName getMiddleName() {
return middleName;
public void setMiddleName(MiddleName middleName) {
this.middleName = middleName;
Using castor i have created an xml file(customer.xml) which has the following format.
<?xml version="1.0" encoding="UTF-8" ?>
- <customer ID="fbs0001">
<FIRSTNAME>Fred</FIRSTNAME>
<MIDDLENAME>B</MIDDLENAME>
<LASTNAME>Scerbo</LASTNAME>
- <ADDRESS>
<FIRSTLINE>No 18, Sheshadri road</FIRSTLINE>
<SECONDLINE>Gandhinagar Bangalore</SECONDLINE>
</ADDRESS>
- <ADDRESS>
<FIRSTLINE>ITPL</FIRSTLINE>
<SECONDLINE>Whitefield Bangalore</SECONDLINE>
</ADDRESS>
</customer>
I have used a mapping file to get this output.Is there a way where i can get the output xml in the following format without changing the Java object structure.If yes then please suggest how this can be done.
<?xml version="1.0" encoding="UTF-8" ?>
- <customer ID="fbs0001">
<FIRSTNAME>Fred</FIRSTNAME>
<MIDDLENAME>B</MIDDLENAME>
<LASTNAME>Scerbo</LASTNAME>
</customer>
<ADDRESS>
<FIRSTLINE>No 18, Sheshadri road</FIRSTLINE>
<SECONDLINE>Gandhinagar Bangalore</SECONDLINE>
</ADDRESS>
- <ADDRESS>
<FIRSTLINE>ITPL</FIRSTLINE>
<SECONDLINE>Whitefield Bangalore</SECONDLINE>
</ADDRESS>
I mean the output xml file should have the address as a separate tag not withing the root tag customer.Hello,
Castor's own discussion groups might be able to point you to the solution you're looking for (if this use case is possible using Castor).
Oracle has its own object-to-XML mapping tool that is part of the TopLink product. It allows you to map existing objects to an existing XML Schema. This can be done visually using the TopLink Workbench, or programmatically using the TopLink APIs. TopLink OXM also supports the JAXB specification.
Using TopLink OXM to get the desired XML result I would recommend the following. Map the Customer and Address classes to XML, but don't map the relationship between Customer and Address. Then make the calls to the marshaller something like the following:
marshaller.marshal(aCustomer, System.out);
for(int x=0; x<aCustomer.getAddress().size(); x++) {
marshal(aCustomer.getAddress().get(x), System.out);
Example - Using TopLink OXM to map an existing object model to an existing XML Schema:
http://www.oracle.com/technology/products/ias/toplink/preview/10.1.3dp4/howto/ox/index.htm
For more information on TopLink object-to-XML mapping:
http://www.oracle.com/technology/products/ias/toplink/preview/10.1.3dp4/objectxml/index.html
-Blaise -
Reg XML generation from java objects using SAX 2.0
i'm using java 1.6 and i've imported following class to generate XML from java objects
import com.sun.org.apache.xml.internal.serialize.OutputFormat;
import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
the following class has been imple her to create a Xml file and tag elements ,
OutputFormat of = new OutputFormat("XML", "iso-8859-1", true);
XMLSerializer serializer = new XMLSerializer(fos, of);
ContentHandler hd = serializer.asContentHandler();
hd.startDocument();
everything works fine but i'm getting warrnin reg the serializer and outputformat
warring is:
com.sun.org.apache.xml.internal.serialize.OutputFormat is Sun proprietary API and may be removed in a future release
com.sun.org.apache.xml.internal.serialize.OutputFormat is Sun proprietary API and may be removed in a future release
HOW CAN I AVOID DS WARRING PLZ HELP REG DS
thanks ,
with regards,
Rajesh.SI've been having the same problem. Here is what i found:
[http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6476630]
Hope that helps (or at least helps you feel better). -
Sending Java object using E-Mail
Dear Experts,
In my application I am trying write java Object in a file. Then I have to attach that file with an E-Mail. In the receiver side I have to download the file and read the Java Object from file.
The Problem is , when I am sending and receiving mail using outlook Express, My file is reduced by some Kbs(Example , I am sending 66kb but I am receiving only 64Kb).
If any of you have some ideas to solve the above problem, please let me know.
With Thanks
PanneerPerhaps you are trying to send binary but e-mail must be in text or the data will get filtered/mangled.
-
Problem with XMLEncoder for complex java object i
Hi All.
My problem with XMLEncoder is it doesnt transfrom java objects without default no arguement constructor. I was able to resolve this in my main java object class, by setting a new persistence delegate, but for other classes that are contained in the main class, they are not being encoded.
Thanks in advance for your answersBetter to put this in java forum :-)
Just check, if this helps.
http://forum.java.sun.com/thread.jspa?threadID=379614&messageID=1623434 -
Error Generating Java Objects using TopLink
Running online tutorial: Build a Web Application with ADF Faces and Oracle TopLink
Generated errors when trying to build Java Objects From Table Wizard at step 9.
[b]java.lang.NullPointerException
at oracle.ideimpl.log.TabbedLogManager.getMsgPage(TabbedLogManager.java:101)
at oracle.toplink.addin.log.POJOGenerationLoggingAdapter.updateTask(POJOGenerationLoggingAdapter.java:42)
at oracle.toplink.addin.mappingcreation.MappingCreatorImpl.fireTaskUpdated(MappingCreatorImpl.java:1049)
at oracle.toplink.addin.mappingcreation.MappingCreatorImpl.generateMappedDescriptorsForTables(MappingCreatorImpl.java:231)
at oracle.toplink.addin.mappingcreation.MappingCreatorImpl.generateMappedDescriptorsForTables(MappingCreatorImpl.java:201)
at oracle.toplink.addin.wizard.jobgeneration.JobWizard$1.construct(JobWizard.java:401)
at oracle.ide.util.SwingWorker$1.run(SwingWorker.java:119)
at java.lang.Thread.run(Thread.java:595)
Any help welcomed
regards
JohnSolved!!!
I had installed JDeveloper 10g inside a directory that had a space in the directory name. -
How can I call a java object from Web dynpro ABAP application?
I made Web dynpro ABAP application and posted it to SAP EP.
For certain business purpose, we need to call external 3rd party java object using 3rd party's java api in Web dynpro application.
Is there anybody who experienced this kind of java interface issue?
I know Web dynpro Java environment can fully support this kind of requirement. but regarding Web dynpro ABAP, I couldn't find any clue for this.
Any comment or suggestion would be greatly appreciated.
Thanks,
Raymond, ABAP Consultantif you have jco configured, then you can make calls to java api from ABAP .
check out this weblog.
/people/gregor.wolf3/blog/2004/08/26/setup-and-test-sap-java-connector-outbound-connection
Raja -
Generating an XML representation of arbitrary Java objects
Hi. Just for fun, I'm attempting to write some code which creates an XML representation of an arbitrary java object using reflection. The idea is that only properties with get/set methods should come through in the XML.
Here is the code:
package com.uhg.aarp.compas.persistence.common.xml;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.w3c.dom.Document;
import org.w3c.dom.DOMException;
import org.w3c.dom.Node;
import java.util.Stack;
public class XMLDAO {
public static String getXMLWithHeader(Object obj){
return "<?xml version=\"0\"?>" + getXML(obj);
* Returns an XML representation of an arbitrary object
public static String getXML(Object obj){
StringBuffer buffer = new StringBuffer();
AccessorMethod[] accessorMethods = getAccessorMethods(obj);
buffer.append("<" + obj.getClass().getName() + ">\n");
//List
if(obj instanceof List){
List objList = (List)obj;
Iterator iterator = objList.iterator();
while(iterator.hasNext()){
buffer.append(getXML(iterator.next()));
else{
for(int i = 0; i < accessorMethods.length; i++){
Object fieldObj = null;
try{
fieldObj = accessorMethods.invoke();
1. Primitive Wrapper or String(base case)
if(fieldObj instanceof Integer || fieldObj instanceof Float || fieldObj instanceof Double
|| fieldObj instanceof Long || fieldObj instanceof String){
buffer.append("<" + accessorMethods[i].getAccessorFieldName() + ">");
buffer.append(accessorMethods[i].invoke());
buffer.append("</" + accessorMethods[i].getAccessorFieldName() + ">\n");
else if(fieldObj instanceof Object[]){
buffer.append("<" + accessorMethods[i].getAccessorFieldName() + ">\n");
Object[] fieldArray = (Object[])fieldObj;
for(int j = 0; j < fieldArray.length; j++)
buffer.append(getXML(fieldArray[i]));
buffer.append("</" + accessorMethods[i].getAccessorFieldName() + ">\n");
}catch(Exception e){
System.out.println("Couldn't invoke method: " + accessorMethods[i].getName());
buffer.append("</" + obj.getClass().getName() + ">\n");
return buffer.toString();
* Returns the Object representation for the XML - used to rebuild Java objects
* converted to XML by XMLDAO.getXML().
public static Object getObject(String xmlString) throws ParserConfigurationException,
SAXException, IOException{
//the root element is the class name
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(xmlString);
Stack objectStack = new Stack();
return getObject(document);
private static Object getObject(Node n){
//every document is either an object or a bean property
//all bean properties have values
//no object has a value, it can only have bean properties
//the base case occurs when the document has a value
String nodeName = n.getNodeName();
if(n.getNodeValue() == null){
System.out.println("node " + nodeName + " is an object");
else{
System.out.println("node " + nodeName + " is a bean property");
return null;
* Returns all of the "getter" methods for the given object
private static AccessorMethod[] getAccessorMethods(Object obj){
Class theClass = obj.getClass();
Method[] objMethods = theClass.getMethods();
ArrayList methodList = new ArrayList();
for(int i = 0; i < objMethods.length; i++){
try{
methodList.add(new AccessorMethod(obj, objMethods[i]));
}catch(IllegalArgumentException e){}
return (AccessorMethod[])methodList.toArray(new AccessorMethod[methodList.size()]);
* Invokes the specified "getter" method and returns the result as an Object
private Object invokeAccessorMethod(Object obj, Method m) throws IllegalAccessException,
InvocationTargetException{
return m.invoke(obj, null);
package com.uhg.aarp.compas.persistence.common.xml;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
* Represents an AccessorMethod (i.e. getField()) on an Object
public class AccessorMethod{
private Object obj;
private Method m;
private String accessorFieldName;
* Constructor for AccessorMethod
public AccessorMethod(Object obj, Method m) throws IllegalArgumentException{
1. Method name starts with get
2. Method name does not equal get
3. Method takes no arguments
4. Method return type is not void
String methodName = m.getName();
if(methodName.indexOf("get") != 0 || methodName.length() == 3 &&
m.getParameterTypes().length != 0 && m.getReturnType() != null){
throw new IllegalArgumentException("Not a valid getter method " + methodName);
this.obj = obj;
this.m = m;
String tempName = m.getName().substring(3, m.getName().length());
this.accessorFieldName = Character.toLowerCase(tempName.charAt(0)) + tempName.substring(1, tempName.length());
public Object invoke() throws IllegalAccessException, InvocationTargetException{
return m.invoke(obj, null);
* Gets the m
* @return Returns a Method
public Method getM() {
return m;
* Sets the m
* @param m The m to set
public void setM(Method m) {
this.m = m;
* Gets the accessorFieldName
* @return Returns a String
public String getAccessorFieldName() {
return accessorFieldName;
* Sets the accessorFieldName
* @param accessorFieldName The accessorFieldName to set
public void setAccessorFieldName(String accessorFieldName) {
this.accessorFieldName = accessorFieldName;
* Gets the obj
* @return Returns a Object
public Object getObj() {
return obj;
* Sets the obj
* @param obj The obj to set
public void setObj(Object obj) {
this.obj = obj;
public String getName(){
return this.m.getName();
I'm having some trouble figuring out how to implement the XMLDAO.getObject(Node n) method. I was thinking of maintaining a Stack of the previous Objects as I traverse the DOM, but I think that might be unnecessary work. Basically I'm wondering how I determine what the last "object" is in the DOM from any given node. Anyone have any input?I think the end of my post got cut off:
I'm having some trouble figuring out how to implement the XMLDAO.getObject(Node n) method. I was thinking of maintaining a Stack of the previous Objects as I traverse the DOM, but I think that might be unnecessary work. Basically I'm wondering how I determine what the last "object" is in the DOM from any given node. Anyone have any input? -
Mapping XML object to java object gives ClassCastException
Hi All,
I am trying to map a specific XML object to a specific java object using web
services and received the following exception:
java.lang.ClassCastException: weblogic.soap.xml.XMLObject
at $Proxy0.getMonster(Unknown Source)
at serviceClient.TestServiceClient.main(TestServiceClient.java:46)
Exception in thread "main"
I tried to map a simple type:
<types>
<schema targetNamespace='java:biomaterials'
xmlns='http://www.w3.org/1999/XMLSchema'>
<element name="Monster">
<complexType>
<all>
<element name="name"
type="string"/>
<element name="age"
type="int"/>
</all>
</complexType>
</element>
</schema>
</types>
To the following java bean:
package biomaterials;
public class
ster{
private String name;
private Integer age;
public Monster(String name, int age) {
this.name=name;
this.age=new Integer(age);
public String getName() {
return name;
public void setName(String s) {
this.name=s;
public Integer getAge() {
return age;
public void setAge(int n) {
this.age=new Integer(n);
Here is my client code:
package serviceClient;
import java.util.Properties;
import weblogic.soap.codec.CodecFactory;
import weblogic.soap.codec.SoapEncodingCodec;
import weblog
ic.soap.codec.LiteralCodec;
import weblogic.soap.WebServiceProxy;
import weblogic.soap.SoapMethod;
import weblogic.soap.SoapType;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.ejb.*;
import biomaterials.ServiceSession;
import java.io.File;
import java.io.IOException;
import org.w3c.dom.Element;
import biomaterials.Monster;
public class TestServiceClient
public static void main( String[] arg ) throws Exception
Properties h = new Properties();
h.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.soap.http.SoapInitialContextFactory");
h.put("weblogic.soap.wsdl.interface",
ServiceSession.class.getName() );
Context context = new InitialContext(h);
ServiceSession serv =
(ServiceSession)context.lookup("http://localhost:7001/biocat/biomaterials.Se
rviceSession/biomaterials.ServiceSession.wsdl");
//try
//int result = serv.getTheNum();
//String result=serv.getBIXBiologicals();
//int result=serv.setBIXInfo("TARNUMBER");
Monster result=serv.getMonster();
System.out.print("The value is "+result);
} /* end of main */
} /* end of class */
Here is the method in my stateless session bean:
public Monster getMonster()
return new Monster("Sully",3);
And here is my whole wsdl file:
<% response.setHeader( "Content-Type", "text/xml; charset=utf-8" ); %>
<definitions
targetNamespace="java:biomaterials"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="java:biomaterials"
>
<types>
<schema targetNamespace='java:biomaterials'
xmlns='http://www.w3.org/1999/XMLSchema'>
<element name="Monster">
<complexType>
<all>
<element name="name" type="string"/>
<element name="age" type="int"/>
</all>
</complexType>
</element>
</schema>
</types>
<message name="getBIXBiologicalsRequest"></message>
<message name="getBIXBiologicalsResponse">
<part name="return" type="xsd:string" />
</message>
<message name="setBIXInfoRequest">
<part name="arg0" type="xsd:string" />
<part name="arg1" type="xsd:string" />
<part name="arg2" type="xsd:integer" />
</message>
<message name="setBIXInfoResponse"></message>
<message name="getMonsterRequest"></message>
<message name="getMonsterResponse">
<part name="body" element="tns:Monster"/>
</message>
<portType name="ServiceSessionPortType">
<operation name="getBIXBiologicals">
<input message="tns:getBIXBiologicalsRequest"/>
<output message="tns:getBIXBiologicalsResponse"/>
I am using weblogic 6.1 SP1 on WIN NT.
Please help me out in this issue.
Thanks in advance.
SapanHI !
i dont think that the servicepack is an issue in this case.
anyway i ahve tried it on 6.1SP4 and still getting similar results.
any pointers will be highly appreciated.
Thanks,
sapan
"manoj cheenath" <[email protected]> wrote in message
news:[email protected]...
I just skimmed through your email. You said you
are using WLS 6.1 SP1. Can you try this using
the latest SP. There are many bug fixes done
after SP1.
Web service support in 6.1 is very limited. But, It
looks like 6.1 can handle the case you are trying out.
regards,
-manoj
"Sapan Agarwal" <[email protected]> wrote in message
news:[email protected]...
Hi All,
I am trying to map a specific XML object to a specific java object usingweb
services and received the following exception:
java.lang.ClassCastException: weblogic.soap.xml.XMLObject
at $Proxy0.getMonster(Unknown Source)
at
serviceClient.TestServiceClient.main(TestServiceClient.java:46)
>>
Exception in thread "main"
I tried to map a simple type:
<types>
<schema targetNamespace='java:biomaterials'
xmlns='http://www.w3.org/1999/XMLSchema'>
<element name="Monster">
<complexType>
<all>
<element name="name"
type="string"/>
<element name="age"
type="int"/>
</all>
</complexType>
</element>
</schema>
</types>
To the following java bean:
package biomaterials;
public class
ster{
private String name;
private Integer age;
public Monster(String name, int age) {
this.name=name;
this.age=new Integer(age);
public String getName() {
return name;
public void setName(String s) {
this.name=s;
public Integer getAge() {
return age;
public void setAge(int n) {
this.age=new Integer(n);
Here is my client code:
package serviceClient;
import java.util.Properties;
import weblogic.soap.codec.CodecFactory;
import weblogic.soap.codec.SoapEncodingCodec;
import weblog
ic.soap.codec.LiteralCodec;
import weblogic.soap.WebServiceProxy;
import weblogic.soap.SoapMethod;
import weblogic.soap.SoapType;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.ejb.*;
import biomaterials.ServiceSession;
import java.io.File;
import java.io.IOException;
import org.w3c.dom.Element;
import biomaterials.Monster;
public class TestServiceClient
public static void main( String[] arg ) throws Exception
Properties h = new Properties();
h.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.soap.http.SoapInitialContextFactory");
h.put("weblogic.soap.wsdl.interface",
ServiceSession.class.getName() );
Context context = new InitialContext(h);
ServiceSession serv =
(ServiceSession)context.lookup("http://localhost:7001/biocat/biomaterials.Se
rviceSession/biomaterials.ServiceSession.wsdl");
file://try
file://int result = serv.getTheNum();
file://String result=serv.getBIXBiologicals();
file://int result=serv.setBIXInfo("TARNUMBER");
Monster result=serv.getMonster();
System.out.print("The value is "+result);
} /* end of main */
} /* end of class */
Here is the method in my stateless session bean:
public Monster getMonster()
return new Monster("Sully",3);
And here is my whole wsdl file:
<% response.setHeader( "Content-Type", "text/xml; charset=utf-8" ); %>
<definitions
targetNamespace="java:biomaterials"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="java:biomaterials"
>
<types>
<schema targetNamespace='java:biomaterials'
xmlns='http://www.w3.org/1999/XMLSchema'>
<element name="Monster">
<complexType>
<all>
<element name="name" type="string"/>
<element name="age" type="int"/>
</all>
</complexType>
</element>
</schema>
</types>
<message name="getBIXBiologicalsRequest"></message>
<message name="getBIXBiologicalsResponse">
<part name="return" type="xsd:string" />
</message>
<message name="setBIXInfoRequest">
<part name="arg0" type="xsd:string" />
<part name="arg1" type="xsd:string" />
<part name="arg2" type="xsd:integer" />
</message>
<message name="setBIXInfoResponse"></message>
<message name="getMonsterRequest"></message>
<message name="getMonsterResponse">
<part name="body" element="tns:Monster"/>
</message>
<portType name="ServiceSessionPortType">
<operation name="getBIXBiologicals">
<input message="tns:getBIXBiologicalsRequest"/>
<outputmessage="tns:getBIXBiologicalsResponse"/>
>>
>>
>>
>>
>>
>>
>>
I am using weblogic 6.1 SP1 on WIN NT.
Please help me out in this issue.
Thanks in advance.
Sapan -
2 TopLink Java Object from Table to be used in single selectOneChoice
Hello everyone, can I ask for help on how to solve my problem....
Here's my scenario, I have 2 tables namely tblCollege and tblCourse, they are related through tblCourse.CollegeCode = tblCollege.Code.
I use the jdeveloper wizard using TopLink -> Java Object from Table to add these table to my project. I created an EJB Data Control so that I can use them to my Userinterface using ADF Faces.
What I really want to do is that I need to have selectOneChoice component displaying:
tblCollege.Name + tblCourse.Name, and it should have a value of tblCollege.Code + tblCourse.Code,
so for example in my
tblCollege:
Code---------Name
1---------------Science
2---------------Music
tblCourse
Code-------Name-----------CollegeCode
1-------------Biology----------1
2-------------Computer-------1
3-------------Guitar------------2
what I want in my selectOneChoice is like this:
value----------display
1-1--------------Science-Biology
1-2--------------Science-Computer
2-3--------------Music-Guitar
I'm a little stuck on how I'm going to that. Thanks.Bawasi,
I see a couple of angles of attack, but this really depends on the technologies involved. If you are using ADF Bindings in combination with ADF Faces then you need to shape the data at the entity level. If ADF Bindings are no the in equation, you can take a less aggressive approach and shape the data in a managed bean. What is not clear to me is the end-to-end use-case. I see the read-only (i.e. how to get data to the drop box), but I am
not certain what attribute on an entity you are attempting to set. Are you trying to set the course for the current user or for a master schedule? Finally, notice that the final shape of your data set shows a unique combinations, you could increase the performance of your use-case and ease of development simply by denormalizing your schema.
--RiC -
How can I use XStream to persist complicated Java Object to XML & backward
Dear Sir:
I met a problem as demo in my code below when i use XTream to persist my Java Object;
How can I use XStream to persist complicated Java Object to XML & backward??
See
[1] main code
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
public class PhoneList {
ArrayList<PhoneNumber> phones;
ArrayList<Person> person;
private PhoneList myphonelist ;
private LocationTest location;
private PhoneList(String name) {
phones = new ArrayList<PhoneNumber>();
person = new ArrayList<Person>();
public ArrayList<PhoneNumber> getphones() {
return phones;
public ArrayList<Person> getperson() {
return person;
public void addPhoneNumber(PhoneNumber b1) {
this.phones.add(b1);
public void removePhoneNumber(PhoneNumber b1) {
this.phones.remove(b1);
public void addPerson(Person p1) {
this.person.add(p1);
public void removePerson(Person p1) {
this.person.remove(p1);
public void BuildList(){
location = new LocationTest();
XStream xstream = new XStream();
myphonelist = new PhoneList("PhoneList");
Person joe = new Person("Joe, Wallace");
joe.setPhone(new PhoneNumber(123, "1234-456"));
joe.setFax(new PhoneNumber(123, "9999-999"));
Person geo= new Person("George Nixson");
geo.setPhone(new PhoneNumber(925, "228-9999"));
geo.getPhone().setLocationTest(location);
myphonelist.addPerson(joe);
myphonelist.addPerson(geo);
public PhoneList(){
XStream xstream = new XStream();
BuildList();
saveStringToFile("C:\\temp\\test\\PhoneList.xml",convertToXML(myphonelist));
public void saveStringToFile(String fileName, String saveString) {
BufferedWriter bw = null;
try {
bw = new BufferedWriter(
new FileWriter(fileName));
try {
bw.write(saveString);
finally {
bw.close();
catch (IOException ex) {
ex.printStackTrace();
//return saved;
public String getStringFromFile(String fileName) {
BufferedReader br = null;
StringBuilder sb = new StringBuilder();
try {
br = new BufferedReader(
new FileReader(fileName));
try {
String s;
while ((s = br.readLine()) != null) {
// add linefeed (\n) back since stripped by readline()
sb.append(s + "\n");
finally {
br.close();
catch (Exception ex) {
ex.printStackTrace();
return sb.toString();
public String convertToXML(PhoneList phonelist) {
XStream xstream = new XStream(new DomDriver());
xstream.setMode(xstream.ID_REFERENCES) ;
return xstream.toXML(phonelist);
public static void main(String[] args) {
new PhoneList();
}[2].
import java.io.Serializable;
import javax.swing.JFrame;
public class PhoneNumber implements Serializable{
private String phone;
private String fax;
private int code;
private String number;
private String address;
private String school;
private LocationTest location;
public PhoneNumber(int i, String str) {
setCode(i);
setNumber(str);
address = "4256, Washington DC, USA";
school = "Washington State University";
public Object getPerson() {
return null;
public void setPhone(String phone) {
this.phone = phone;
public String getPhone() {
return phone;
public void setFax(String fax) {
this.fax = fax;
public String getFax() {
return fax;
public void setCode(int code) {
this.code = code;
public int getCode() {
return code;
public void setNumber(String number) {
this.number = number;
public String getNumber() {
return number;
public void setLocationTest(LocationTest bd) {
this.location = bd;
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(location);
f.getContentPane().add(location.getControls(), "Last");
f.setSize(400,400);
f.setLocation(200,200);
f.setVisible(true);
public LocationTest getLocationTest() {
return location;
}[3].
package test.temp;
import java.io.Serializable;
public class Person implements Serializable{
private String fullname;
@SuppressWarnings("unused")
private PhoneNumber phone;
@SuppressWarnings("unused")
private PhoneNumber fax;
public Person(){
public Person(String fname){
fullname=fname;
public void setPhone(PhoneNumber phoneNumber) {
phone = phoneNumber;
public void setFax(PhoneNumber phoneNumber) {
fax = phoneNumber;
public PhoneNumber getPhone() {
return phone ;
public PhoneNumber getFax() {
return fax;
public String getName() {
return fullname ;
public void setName(String name) {
this.fullname = name;
public String toString() {
return getName();
}[4]. LocationTest.java
package test.temp;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
import javax.swing.event.*;
public class LocationTest extends JPanel implements ChangeListener
Ellipse2D.Double ball;
Line2D.Double line;
JSlider translate;
double lastTheta = 0;
public void stateChanged(ChangeEvent e)
JSlider slider = (JSlider)e.getSource();
String name = slider.getName();
int value = slider.getValue();
if(name.equals("rotation"))
tilt(Math.toRadians(value));
else if(name.equals("translate"))
moveBall(value);
repaint();
protected void paintComponent(Graphics g)
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
if(ball == null)
initGeom();
g2.setPaint(Color.green.darker());
g2.draw(line);
g2.setPaint(Color.red);
g2.fill(ball);
private void initGeom()
int w = getWidth();
int h = getHeight();
int DIA = 30;
int padFromEnd = 5;
line = new Line2D.Double(w/4, h*15/16, w*3/4, h*15/16);
double x = line.x2 - padFromEnd - DIA;
double y = line.y2 - DIA;
ball = new Ellipse2D.Double(x, y, DIA, DIA);
// update translate slider values
int max = (int)line.getP1().distance(line.getP2());
translate.setMaximum(max);
translate.setValue(max-padFromEnd);
private void tilt(double theta)
// rotate line from left end
Point2D pivot = line.getP1();
double lineLength = pivot.distance(line.getP2());
Point2D.Double p2 = new Point2D.Double();
p2.x = pivot.getX() + lineLength*Math.cos(theta);
p2.y = pivot.getY() + lineLength*Math.sin(theta);
line.setLine(pivot, p2);
// find angle from pivot to ball center relative to line
// ie, ball center -> pivot -> line end
double cx = ball.getCenterX();
double cy = ball.getCenterY();
double pivotToCenter = pivot.distance(cx, cy);
// angle of ball to horizon
double dy = cy - pivot.getY();
double dx = cx - pivot.getX();
// relative angle phi = ball_to_horizon - last line_to_horizon
double phi = Math.atan2(dy, dx) - lastTheta;
// rotate ball from pivot
double x = pivot.getX() + pivotToCenter*Math.cos(theta+phi);
double y = pivot.getY() + pivotToCenter*Math.sin(theta+phi);
ball.setFrameFromCenter(x, y, x+ball.width/2, y+ball.height/2);
lastTheta = theta; // save theta for next time
private void moveBall(int distance)
Point2D pivot = line.getP1();
// ball touches line at distance from pivot
double contactX = pivot.getX() + distance*Math.cos(lastTheta);
double contactY = pivot.getY() + distance*Math.sin(lastTheta);
// find new center location of ball
// angle lambda = lastTheta - 90 degrees (anti-clockwise)
double lambda = lastTheta - Math.PI/2;
double x = contactX + (ball.width/2)*Math.cos(lambda);
double y = contactY + (ball.height/2)*Math.sin(lambda);
ball.setFrameFromCenter(x, y, x+ball.width/2, y+ball.height/2);
JPanel getControls()
JSlider rotate = getSlider("rotation angle", "rotation", -90, 0, 0, 5, 15);
translate = getSlider("distance from end", "translate", 0, 100, 100,25, 50);
JPanel panel = new JPanel(new GridLayout(0,1));
panel.add(rotate);
panel.add(translate);
return panel;
private JSlider getSlider(String title, String name, int min, int max,
int value, int minorSpace, int majorSpace)
JSlider slider = new JSlider(JSlider.HORIZONTAL, min, max, value);
slider.setBorder(BorderFactory.createTitledBorder(title));
slider.setName(name);
slider.setPaintTicks(true);
slider.setMinorTickSpacing(minorSpace);
slider.setMajorTickSpacing(majorSpace);
slider.setPaintLabels(true);
slider.addChangeListener(this);
return slider;
}OK, My questions are:
[1]. what I generated XML by XSTream is very complicated, especially for object LocationTest, Can we make it as simple as others such as Person object??
[2]. after I run it, LocationTest will popup and a red ball in a panel will dsiplay, after I change red ball's position, I hope to persist it to xml, then when I read it back, I hope to get same picture, ie, red ball stiil in old position, How to do that??
Thanks a lot!!Positive feedback? Then please take this in a positive way: if you want to work on persisting Java objects into XML, then GUI programming is irrelevant to that goal. The 1,000 lines of code you posted there appeared to me to have a whole lot of GUI code in it. You should produce a smaller (much smaller) example of what you want to do. Calling the working code from your GUI program should come later.
Maybe you are looking for
-
Org.xml.sax.SAXException: Error:General Schema Error
I am getting the error below. Any clues/workarounds? I am using WL 6.1. Thanks in advance, Eva The following files are below: Validate.java BMDefaultHandler.java validate.xml validate.xsd org.xml.sax.SAXException: Error:General Schema Error: Grammar
-
My ipod is not working at all when i plug it into my laptop i get an itunes sign and below that plugin sign also it says new software found however it first asks me to install the software disc which i dont have it with me now can you plz check for t
-
ITunes does not add album art though being added manually..
Hello people.. i have this problem, i just bought an iPod and used the iTunes 9 for the library and all. got some of the artwork from the store and some i downloaded manually and tried adding them.. now the thing is, it saved some of the artwork that
-
Hi everyone, How to configure incoming vendor invoice using edi Thanks Genie
-
PSE 10 Organizer for Mac - Partially correct Album search results
When clicking on an album, I get a huge amount of results but only 13, for example, should be in the album. Why does PSE 10 for the Mac give that kind of search response. How can I fix it? To clarify....clicking on an album marked Flowers gives me