Example of a WS returning a class(a bean)
Hi Folks !
I need an example of a WS returning a class(a bean).
The class should have at least 2 attributes.
Any help is very appreciated.
Best regards !
Ricardo
Hello,
Study the following code - it should help:
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
* This is a fun applet to show how button events work.
public class EventTest extends Applet implements ActionListener{
Button shrinkButton, growButton;
int size = 50;
* init( ) creates two Button objects, adds an ActionListener
* to each (this actionListener listeners for when the Button is
* pressed) and then adds each Button to the applets Panel.
public void init( ){
shrinkButton = new Button( "Shrink");
shrinkButton.addActionListener( this);
add( shrinkButton);
growButton = new Button( "Grow");
growButton.addActionListener( this);
add( growButton);
* This method is called when a Button is pressed. It uses the
* method e.getSource( ) to see which Button called this method.
public void actionPerformed( ActionEvent e){
if( e.getSource( ) == shrinkButton)
size -= 10;
else
size += 10;
repaint( );
* This method is called from method actionPerformed( ) and
* repaints the text at the appropriate size.
public void paint( Graphics g){
Font font = new Font( "Ariel", Font.BOLD, size);
g.setFont( font);
g.drawString( "Big or Small?", 200, 200);
}I hope this helps.
Best regards
-Marek.
Similar Messages
-
WSIF - Can we return java class back to bpel (PLEASE HELP)
Scenario : We have old project and migrating to Oracle BPEL.
In this project we have Java Files and inside that java files we have many functions which return java object. Is it possible to return java value object to bpel process.
Steps which i have followed:
1. Created a WSDL file using the control file given below.
2. Changed the name spaces and types generated to XFMFRq and TXNLog as i/p and o/p.
3. Imported same file into oracle bpel.
4. Called the function : logbegin.
EXCEPTION : The types are not compactable is the exception we are getting but we are able to call the function and execute first line but not able to return TXNLOG class as an xml element to bpel.
For Example :
1. Java Method and this method returns Java Value Object
Java Control which has TXNLOG as the value object which will return the value.
CONTROL FILE
public TxnLog logBegin(com.hp.rtfs.xfmf.doc.XFMFRqDocument requestXML)throws Exception
//LogUtil.logDebug(LogConstants.MODULE_BPM,BPM_CONTROL_NAME,"Enter Method logBegin ");
txnLog=new TxnLog();
try
System.out.println("AMMA1121212");
LogUtil.logDebug(LogConstants.MODULE_BPM,BPM_CONTROL_NAME,"Entering Top user id update in LogBegin");
txnLog.setTlogChannelLoginId("AMMA1");
txnLog.setTlogChannelUserId("AMMA2");
System.out.println("AMMA2");
txnLog.setTlogChinChannelId("ATM");
txnLog.setTlogChannelSessionId("SESSION-1111");
System.out.println("AMMA3");
txnLog.setTlogCustCifKey((new Long("121212")));
txnLog.setTlogEmtnTxnCd("TXN-001");
System.out.println("AMMA4");
txnLog.setTlogSendIpAddr("10.1.1.1");
txnLog.setTlogChannelTxnSeqId(new Integer("1212"));
System.out.println("AMMA5");
TxnLogPK txnLogPk=new TxnLogPK(new Integer("121212"),
DateUtil.getDate(requestXML.getXFMFRq().getMsgRqHdr().getUID().getRTFSTransSeqUIDDt()),"1212");
txnLog.setTxnLogPK(txnLogPk);
System.out.println("AMMA6");
catch(Exception e)
//LogUtil.logError(LogConstants.MODULE_BPM,BPM_CONTROL_NAME,"Exception "+e.getMessage());
e.printStackTrace();
return txnLog;
TXN LOG value object is :
// Oracle JDeveloper Stub Generated Source
package com.hp.rtfs.ods.infra.trx;
public class TxnLog
implements java.io.Serializable
// Constructors
public TxnLog(com.hp.rtfs.ods.infra.trx.TxnLogPK p1, java.lang.Long p2, java.lang.String p3, java.util.Calendar p4, java.lang.String p5, java.lang.String p6, java.lang.String p7, java.lang.String p8, java.lang.String p9, java.lang.Integer p10, java.util.Calendar p11, java.lang.String p12, com.hp.rtfs.ods.infra.channel.ChannelInfo p13, java.util.Set p14) { }
public TxnLog() { }
public TxnLog(com.hp.rtfs.ods.infra.trx.TxnLogPK p1, java.util.Set p2) { }
// Fields
private com.hp.rtfs.ods.infra.trx.TxnLogPK TxnLogPK;
private java.lang.Long tlogCustCifKey;
private java.lang.String tlogEmtnTxnCd;
private java.util.Calendar tlogStartDt;
private java.lang.String tlogStat;
private java.lang.String tlogSendIpAddr;
private java.lang.String tlogChannelUserId;
private java.lang.String tlogChannelLoginId;
private java.lang.String tlogChannelSessionId;
private java.lang.Integer tlogChannelTxnSeqId;
private java.util.Calendar tlogEndDt;
private java.lang.String tlogChinChannelId;
private com.hp.rtfs.ods.infra.channel.ChannelInfo channelInfo;
private java.util.Set txnLogDatas;
// Methods
public com.hp.rtfs.ods.infra.trx.TxnLogPK getTxnLogPK() { }
public void setTxnLogPK(com.hp.rtfs.ods.infra.trx.TxnLogPK p1) { }
public java.lang.Long getTlogCustCifKey() { }
public void setTlogCustCifKey(java.lang.Long p1) { }
public java.lang.String getTlogEmtnTxnCd() { }
public void setTlogEmtnTxnCd(java.lang.String p1) { }
public java.util.Calendar getTlogStartDt() { }
public void setTlogStartDt(java.util.Calendar p1) { }
public java.lang.String getTlogStat() { }
public void setTlogStat(java.lang.String p1) { }
public java.lang.String getTlogSendIpAddr() { }
public void setTlogSendIpAddr(java.lang.String p1) { }
public java.lang.String getTlogChannelUserId() { }
public void setTlogChannelUserId(java.lang.String p1) { }
public java.lang.String getTlogChannelLoginId() { }
public void setTlogChannelLoginId(java.lang.String p1) { }
public java.lang.String getTlogChannelSessionId() { }
public void setTlogChannelSessionId(java.lang.String p1) { }
public java.lang.Integer getTlogChannelTxnSeqId() { }
public void setTlogChannelTxnSeqId(java.lang.Integer p1) { }
public java.util.Calendar getTlogEndDt() { }
public void setTlogEndDt(java.util.Calendar p1) { }
public java.lang.String getTlogChinChannelId() { }
public void setTlogChinChannelId(java.lang.String p1) { }
public com.hp.rtfs.ods.infra.channel.ChannelInfo getChannelInfo() { }
public void setChannelInfo(com.hp.rtfs.ods.infra.channel.ChannelInfo p1) { }
public java.util.Set getTxnLogDatas() { }
public void setTxnLogDatas(java.util.Set p1) { }
public java.lang.String toString() { }
public boolean equals(java.lang.Object p1) { }
public int hashCode() { }
---------------------------------------------------------------------------I have been bragging to my clients the benefits of
Java Applications, but one thing I couldn't convince
them is the use of a JVM. They dislike the idea of
downloading the JRE, and the slowness of programs
running in an interpreter. I am stumped for not being
able to satisfy their need for a .EXE program on their
Win32 systems. And, it would be ridiculous to go back
again to C++, after learning Java. I'm not going to address the JRE distribution as it's already been mentioned and there are several ways of approaching that problem that you can find easily in the forum so I won't waste space for it here.
What you need to address more than anything is the supposed slowness of java programs. The question at hand is slow as compared to what? In what context? A benchmark can be twisted to show whatever the author of the report wants it to show. Thus I tend to distrust such statistics in general due to the economical influence of the author or comissioner of the report being in the business of trying to sell something. Exactly what are they calling slow and what causes this perception on their part? I wouldn't sidestep the issue, or try to B.S. about it, but I'd be willing to bet that their fears are unfounded and based on superstition and hearsay.
>
Is their a tool or a way to convert .CLASS files into
.EXE(Win32) files, to make it execute faster and
independent? I know it would sacrifice portability,
but I have to give in to demands. As they say it,
"The customers are always right." Please, anybody out
there, shed some light for me on this one. Thanx in
advance.
BlueKnyght.ph -
Example codes for each and every class in API
hi,
Is there any place where i can get example code for eacha and every class in java API.
for eample...if i wanna find sample codes for all the clases in java.lang.*
please let me know ASAP.
thanks in advanceTry this
http://www.javaalmanac.com/egs/
It's almost complete, but you could help mr. Patrick Chan to write more samples for the few classes left in the Java API... -
Forte compilation returns Object.class incorrect version 48
Java programs that compile successfully fail in Forte CE V3.0 and return messages "Class file java/lang/Object.class has incorrect version 48, should be 45, 46 or 47". Does anyone know what this means and how it can be overcome?
ThanksIt means that the rt.jar in your classpath is more recent than the compiler Forte is using.
-
The TableModel.getColumnClass() always return String class
Hi, anybody here has ever encountered and problem like mine? Please help if you do.
I have an JTable and the table model derived from AbstractTableModel, I use TableSorter from the tutorial to sort the table(I have also implemented my own sorting method, but the result is the same), but whatever the data type of the table column, the getColumnClass() method always return String type, so the table is always sorted by String type.
My implementation of this method is as following:
return getValueAt(0, columnIndex).getClass();
What is possibly wrong?
Please help, thank you so much!
JanetPresumably the data in your first cell is a String object... therefore your code in getColumnClass() will always return String.class.
-
Example code for each and every class in java API
hi,
Is there any place where i can get example code for eacha and every class in java API.
for eample...if i wanna find sample codes for all the clases in java.lang.*
please let me know ASAP.
thanks in advanceCrossposted here: http://forum.java.sun.com/thread.jsp?thread=570264&forum=54&message=2820774
-
When to make a class a bean?
I can understand that if you have a GUI type class where you might want to make the class a Bean so that it can be used in tools like BeanBox.
But what if it is a non visible class? For example say a class that is used to interface to piece of equipment over the serial port? Are there any advantages to making the class a Bean?Ok. My info may be a little out of date, but I'll try.
In object oriented programming, we have these things called patterns. They are called that because that's what they are caled in the original book by the "gang of four", whose names I can't recall. An example of a pattern is the idea of passing an event around, or having graphical objects "inside" other ones, or making a class that serves as an interface to a complex set of other classes. These patterns are not always directly supported by the APIs or language, they are more abstract than that - ways that we programmers go about architecting solutions to certain kinds of problems. (nb: a pattern is not the same thing as an algorithim). Of course, some patterns are supported directly by the APIs: EventObject, EventListener etc.
One common pattern is an object that holds a set of values, that fires events and so on. Of course any object can do this, but architecturally speaking, some objects work that way more naturally than others. In Java, we call such an object a JavaBean.
Java supplies a standard for JavaBeans at http://java.sun.com/products/javabeans/docs/spec.html . This standard specifies that a java bean has a null argument constructor, it has getters and setters and that if a bean has a getFoo() method and a setFoo() method, then these together mean that the bean has a "property" named Foo, and so on.
Now physically, the only thing that a java bean must have is:
it must be public,
it must have a public, no-argument constructor
However, architecturally, we make a load of assumptions. For instance, if your class has a getFoo() and setFoo() method, but they have absolutely nothing to do with each other, then you class isn't a JavaBean, even though physically the compiler and tools have no way to know this. Likewise, if your class has a public no-arg constructor, but your class requires that you call the setup() method for it to work properly, then it is not a JavaBean. JavaBeans can be initialised into a reasonable starting state with the constructor alone.
So JavaBean or not JavaBean is not a class you inherit or an API you use, it's a way of doing things.
Having said that, there is api support for JavaBeans in the java.bean package. You can create "BeanInfo" classes for your beans that contain metadata about the beans: long textual descriptions for the properties, icons for tools to use when displaying the beans and so on.
As for JSPs:
From memory, you can tell your JSP that an instance of a bean is to be created for each session that the JSP deals with. So say we make a bean that acts as a shopping cart, with items that themselves are beans (item number, quantity). Inside the JSP you can do things like "print shopping cart.item[2].name", and the JSP will know to convert this to a call to foobean.getItem(2).getName(). The reason for making it a bean is to make it possible for the web server to manage the creation of these things and the retreiving of them on a session-by-session basis. They can also be passed as arguments and so on. Another nice reason to use a bean is that you can encode derived values as getter methods on the bean (eg: getTotalPrice()). This is a nice place to put such logic.
The JSP spec is at http://www.jcp.org/aboutJava/communityprocess/final/jsr053/ . (dont confuse it with the servlet Spec, which is on the same page). See section 4.1: Standard Actions/usebean. -
How to map AM method return values in the bean
Hello -
I have this requirement to map AM method return values in the bean as explained below. Please suggest a solution.
Scenario: I am calling an AM method, which returns a String object on page load.
AMImpl Method-
public String getProfileName (){
return "Profile";
I wish to catch this retun value in the Bean Variable on page Load. I have created a methodAction biding on page and invokeAction to call this method on Page Load, but I don't know how to catch this value in the bean. Please suggest how to achieve this. Also, I need to achieve this in jsp page. I can't use TaskFlow for this.
I am using ADF 11g.
Regards -
Rohit
Edited by: Rohit Makkad on Apr 21, 2010 12:23 AMHi, I think there are two ways, from the data control drag n drop the methods return value to the page. This way a binding for that will be created at the page definition eg retVal.
and in the backing bean you can access it by calling resolveExpression("#{bindings.retVal.inputValue}")
You can also call your method directly from the backbean
((YourAppModuleImpl) getBindings().getDataControl().getApplicationModule()).yourMethod();
public DCBindingContainer getBindings() {
return (DCBindingContainer) resolveExpression("#{bindings}");
I dont know if the second method suits you
Tilemahos -
Problem importing classes and beans
Hey there. Im having one major fustrating problem! When I code supporting classes and beans for my JSPs I get a code 500 internal server error when trying to import (via <%@ page import="class" %> and <jsp:useBean/>) Im storing my classes and beans in the WEB-INF folder and the calling JSPs are located in /ROOT/tests/8/jsp.jsp. Im using the following to import a class or bean:
<%@ import="aClass" %>
Seen as tho its in the WEB-INF folder I won't have to explicitly refer to where the class is located, just the class name.
I never had this problem when I was using my hosting service. Its only on my localhost server in which I get the Internal Server error.
Help appreciated, thx.
PS: Im quite new to JSP/Java Servlet.import (via <%@ page import="class" %> and
<jsp:useBean/>) Im storing my classes and beans in the
WEB-INF folder try put your class file in WEB-INF/classes.
or first put bean in the package, like WEB-INF/classes/packagename/beanclass
in jsp page:
<jsp:useBean id="Mybean" class="packagename.beanclass" scope="request" />
Question: is /ROOT a context entry in your server.xml?
Which JSP Container (version) you use? Maybe your localhost server's set up is different with your hosting. -
I created a project, and a JavaBean that connects to the database and I want to use it in a JSP page that exists in my project.
Bean:
package BeerPackage;
import java.sql.*;
public class ConnectionBean
JSP:
<%@ page import="BeerPackage.*" contentType="text/html;charset=windows-1252"%>
<jsp:useBean id="connection" class="ConnectionBean" scope="session"/>
Then I get the error:
Error(2): Unable to find class for bean: connection defined by tag with class: ConnectionBean
When I try to build the JSP
Any ideas?Seems even though I have an import, I still have to specify the package name in front of the useBean.
What am I missing here? -
Hello,
At times, I keep getting this error of unable to find class for bean even though, the definition I used for the Bean in the jsp page is as follows:
<jsp:useBean id="deptbean" class="avt.DepartmentHandler"
scope="session"/>
The Error I get is "Unable to find class for bean deptbean: defined by tag with class: avt.DepartmentHandler".
I had saved the Java class file DepartmentHandler before attempting on the jsp page which used this.
I have no clue as to why this is happening. Please do help.
Thanks in Advance.Hello,
I think I figured out why it is happening so, it was because I hadnt compiled the java class files and java bean files. Once I compiled the java files, I was able to get rid of the error.
Thanks. -
Error: Unable to find class for bean
Dear all,
please help help with the problem
i've a jsp as follows:
<@page import="java.util.*, com.abc.*" %>
<jsp:useBean id="mybean" class="MyClass" />
<% out.println("Testing bean"); %>
where MyClass.class is located WEB-INF/classes/com/abc/MyClass.class
it works fine in Oracle iAS with oc4j 1.0.2.1.1 (not 9iAS R2)
when i upgrade to 9iAS R2 with oc4j 9.0.3
it's complaining the error of
OracleJSP: oracle.jsp.parse.JspParseException: Line # 8, <jsp:useBean id="mybean" class="MyClass" />
Error: Unable to find class for bean: mybean defined by tag with class: MyClass
then i changed the line <jsp:useBean....> to
<jsp:useBean id="mybean" class="com.abc.MyClass" />
it didn't complain the error
anyone know that the syntax of specifying class must be coded as package.xxx.xxx etc?
Thank you very muchYou should specify the fully qualified class name (i.e. with package structure) in the class attribute of useBean tag.
Read the syntax of useBean tag here
http://java.sun.com/products/jsp/syntax/1.1/syntaxref1115.html
Chandar -
'invalid class-java beans not available for import
Hi Experts,
i am using java bean model in my Web Dynpro Application.
for that one i have created command bean(Customer) and in my command bean i am using some other class(CustomerInfo) as reference. this CustomerInfo class contains 4 attribtes(name ,id ,etc all are of type String)
when i try to import these 2 class into web dynpro (using java bean model),for the Customer class it
is giving an error message 'invalid class-java beans not
available for import'.but 2nd class(CustomerInfo) is imported successfully with out giving the error.what might be reason.
any help will be appriciated
Thanks in advance
With Regards
NaiduNaidu,
Please try to repeat JavaBean model import when running IDE in console mode (correspondign short-cut should be available in Windows Start menu, otherwise just copy original short-cut, edit it and change in command string "javaw" to java).
Post here what is shown on console during import.
VS -
Looking for a JCalendar Class or bean
I need to find a Calender class or bean that gives you a visual date selector, ie you can click through the months and select the day from a kind of date matrix, is there such a class out there freely available?
I was hoping IBM may have such a class, if so does anyone know how i can get it?
thanxHi,
I can send you two clasess (with code) for do this : an special JTextField (whoe present the user the date ) and when user click inside a JDialog with a Calendar.
Send me an e-mail at [email protected]
Bye -
Invalid Class -Java Bean not available for import
hai friends,
i have declared the bean but unable to import into webdynpro application
i am geting the error invalid Class-java bean Not available for improt
i am try for this since more than 10 days , i get the same error
even i thought there may be issues with nwds , i have installed thrice.
there is application download from the sdn tu_bonus calculation it is working
plz help me neede very urgentlyHi,
Go thro' these solved threads dealing with similar type of problem,
Import JavaBean Error : Invalid Class
invalid class - ..as Model Class already exist
Hope it helps to fix the error !
Regards
Srinivasan T
Maybe you are looking for
-
I am trying to pull some dates out of my database, and have them show up in a <cfselect> that users than then pick. I have: <cfselect name="ClassDate" size="1" required="yes" message="Please select the date the class began." query="RequestDate" value
-
Computer Freezes After iPhoto Album Mosaic Screen Saver
After using the Mosaic screen saver, my Mac will freeze, therefore resulting in me having to perform a hard shutdown, and reboot my Mac. When my Mac turns back on and I log in, Crash Reporter reports that AdobeResourceSychronizer crashed. The log is
-
Windows error when importing Essbase cube into OBIEE
Hi all: This question is perhaps more relevant to the OBIEE forum, but I put it up there a few days ago and got no response. So now I'm hoping to get some help on this side of BI land! My issue is that I'm trying to import an Essbase cube (system 11)
-
Hi, I am a PGA/LGA certified hardware engineer who worked R&D for decades. One of the processes in R&D is the Verification of design function within complex designs that both do and do not use computers and or software. In the case of a design where
-
HI, I'm planning to use a cdf function in my essbase outline - '@JgetMonthNumberWorkDays(2009, 1, "aus")' Now my question is..can we pass other essbase functions within this cdf and make it work ? e.g. Will something like below work? '@JgetMonthNumbe