Help on Java Bean
I have learnt java to a good point but ca someone help me on wrapping my classes to java beans. I need basic steps to wrapping my classes to javabeans. thanks
Base requirements are that the class is serializable and has public get/set method for attributes.
Similar Messages
-
Can some one help me to find a place for step by step documentation on how to create java bean and load an image thru java Bean on a form. I'm not loading from the same server it must be loaded from a different server.
Very urgent please. I really appreciate any help.
Thanks in advance.Hi,
for the first part of your question: start Forms Builder, press F1 and the seach for Bean Area. The online help also comes with code examples
for the second part, this URL will give you a head start: http://www.particle.kth.se/~lindsey/JavaCourse/Book/Java/Chapter11/loadingImages.html
Frank -
Is any one tell me that JAVA BEAN only used in WEB or also you in Desktop applications???? and aslo tell how i implement Java class and use JAVA BEAN. I need help regarding above matter
thanks in advance
Rehan MIrzaHere is a good link that indicate that JavaBean is not only for applets
http://java.sun.com/docs/books/tutorial/javabeans/whatis/beanDefinition.html
quote:
The JavaBeans API makes it possible to write component software in the Java programming language. Components are self-contained, reusable software units that can be visually composed into composite components, applets, applications, and servlets using visual application builder tools. JavaBean components are known as Beans.
Francois -
Help with java beans on initialisation
hi
I'm trying to use java beans for the first time
I'm calling a bean from a JSP page; the bean will not exist when the page is first called
<jsp:useBean id="user" scope="session" class="business.User" />I want to use properties/private attributes of the user bean to make a form "sticky" on the page, so that once the user has entered something, their input is there the next time they visit the page (eg back or via an href)
The problem is that the bean creates a user on the first call with properties that are null, which means that "null" is displayed on my form when it first appears
<td><input type="text" name="firstName" value="<jsp:getProperty name ='user' property='firstName' />"></td>I can code this out using a scriptlet but this defeats the beauty of java beans and jsp tags. How do I translate a null property so that nothing is displayed on the form?
Thanks for your helpSo.. my mini-designer should be something like an editor,with a pallette with beans(like JavaBeans) and when a user is dragging a bean into a form,my applicaton should generate the code fr that bean....something like that :)
-
Need help with Java Beans and PDA
How can I get Java Bean applets to work on a PDA, with either Palm or Pocket PC?
first hit on google
thankyou for using the georgemc google proxy -
Need Help-How Store the input parameter through java bean
Hello Sir,
I have a simple Issue but It is not resolve by me i.e input parameter
are not store in Ms-Access.
I store the input parameter through Standard Action <jsp:useBean>.
jsp:useBean call a property IssueData. this property exist in
SimpleBean which create a connection from DB and insert the data.
At run time servlet and server also show that loggging are saved in DB.
But when I open the table in Access. Its empty.
Ms-Access have two fields- User, Password both are text type.
Please review these code:
login.html:
<html>
<head>
<title>A simple JSP application</title>
<head>
<body>
<form method="get" action="tmp" >
Name: <input type="text" name="user">
Password: <input type="password" name="pass">
<input type="Submit" value="Submit">
</form>
</body>
</html>LoginServlet.java:
import javax.servlet.*;
import javax.servlet.http.*;
public class LoginServlet extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException{
try
String user=request.getParameter("user");
String pass=request.getParameter("pass");
co.SimpleBean st = new co.SimpleBean();
st.setUserName(user);
st.setPassword(pass);
request.setAttribute("user",st);
request.setAttribute("pass",st);
RequestDispatcher dispatcher1 =request.getRequestDispatcher("submit.jsp");
dispatcher1.forward(request,response);
catch(Exception e)
e.printStackTrace();
}SimpleBean.java:
package co;
import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.util.*;
public class SimpleBean {
private String user="";
private String pass="";
private String s="";
public String getUserName() {
return user;
public void setUserName(String user) {
this.user = user;
public String getPassword() {
return pass;
public void setPassword(String pass) {
this.pass = pass;
public String getIssueData() //method that create connection with database
try
System.out.println("Printed*************************************************************");
getUserName();
getPassword();
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Loading....");
Connection con=DriverManager.getConnection("jdbc:odbc:simple");
System.out.println("Connected....");
PreparedStatement st=con.prepareStatement("insert into Table1 values(?,?)");
System.out.println("~~~~~~~~~~~~~~~~~~~~");
String User=getUserName();
st.setString(1,User);
String Password=getPassword();
st.setString(2,Password);
st.executeUpdate();
System.out.println("Query Executed");
con.close();
s= "Your logging is saved in DB ";
System.out.println("Your logging is saved in DB *****************");
return(s);
catch(Exception e)
e.printStackTrace();
return "failed";
}submit.jsp:
This is Submit page
<html><body>
Hello
Student Name: <%= ((co.SimpleBean)request.getAttribute("user")).getUserName() %>
<br>
Password: <%= ((co.SimpleBean)request.getAttribute("pass")).getPassword() %>
<br>
<jsp:useBean id="st" class="co.SimpleBean" scope="request" />
<jsp:getProperty name="st" property="IssueData" />
</body></html>web.xml:<web-app>
<servlet>
<servlet-name>one</servlet-name>
<servlet-class>LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>one</servlet-name>
<url-pattern>/tmp</url-pattern>
</servlet-mapping>
<jsp-file>issue.jsp</jsp-file>
<jsp-file>submit.jsp</jsp-file>
<url-pattern>*.do</url-pattern>
<welcome-file-list>
<welcome-file>Login.html</welcome-file>
</welcome-file-list>
</web-app>Please Help me..Thanks.!!!
--Dear Sir,
Same issue is still persist. Input parameter are not store in database.
After follow your suggestion when I run this program browser show that:i.e
This is Submit page Hello Student Name: vijay
Password: kumar
<jsp:setProperty name="st" property="userName" value="userValue/> Your logging is saved in DB
Please review my code.
login.html:
{code}<html>
<head>
<title>A simple JSP application</title>
<head>
<body>
<form method="get" action="tmp" >
Name: <input type="text" name="user">
Password: <input type="password" name="pass">
<input type="Submit" value="Submit">
</form>
</body>
</html>{code}
LoginServlet.java:
{code}import javax.servlet.*;
import javax.servlet.http.*;
public class LoginServlet extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException{
try
String userValue=request.getParameter("user");
String passValue=request.getParameter("pass");
co.SimpleBean st = new co.SimpleBean();
st.setuserName(userValue);
st.setpassword(passValue);
request.setAttribute("userValue",st);
request.setAttribute("passValue",st);
RequestDispatcher dispatcher1 =request.getRequestDispatcher("submit.jsp");
dispatcher1.forward(request,response);
catch(Exception e)
e.printStackTrace();
}{code}
SimpleBean.java:
{code}package co;
import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.util.*;
public class SimpleBean {
private String userValue="";
private String passValue="";
private String s="";
public String getuserName() {
return userValue;
public void setuserName(String userValue) {
this.userValue = userValue;
public String getpassword() {
return passValue;
public void setpassword(String passValue) {
this.passValue= passValue ;
public String getissueData() //method that create connection with database
try
System.out.println("Printed*************************************************************");
getuserName();
getpassword();
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("Connection loaded");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@VijayKumar-PC:1521:XE","SYSTEM","SYSTEM");
System.out.println("Connection created");
PreparedStatement st=con.prepareStatement("insert into vij values(?,?)");
System.out.println("~~~~~~~~~~~~~~~~~~~~");
String userName=getuserName();
st.setString(1,userName);
String password=getpassword();
st.setString(2,password);
st.executeUpdate();
System.out.println("Query Executed");
con.close();
s= "Your logging is saved in DB ";
System.out.println("Your logging is saved in DB *****************");
return(s);
catch(Exception e)
e.printStackTrace();
return "failed";
}{code}
submit.jsp:
{code}This is Submit page
<html><body>
Hello
Student Name: <%= ((co.SimpleBean)request.getAttribute("userValue")).getuserName() %>
<br>
Password: <%= ((co.SimpleBean)request.getAttribute("passValue")).getpassword() %>
<br>
<jsp:useBean id="st" class="co.SimpleBean" scope="request" />
<jsp:setProperty name="st" property="userName" value="userValue/>
<jsp:setProperty name="st" property="password" value="passValue"/>
<jsp:getProperty name="st" property="issueData" />
</body></html>web.xml:<web-app>
<servlet>
<servlet-name>one</servlet-name>
<servlet-class>LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>one</servlet-name>
<url-pattern>/tmp</url-pattern>
</servlet-mapping>
<jsp-file>submit.jsp</jsp-file>
<url-pattern>*.do</url-pattern>
<welcome-file-list>
<welcome-file>Login.html</welcome-file>
</welcome-file-list>
</web-app>Sir I can't use EL code in jsp because I use weblogic 8.1 Application Server.This version are not supported to EL.
Please help me...How store th input parameter in Database through Java Bean -
Help with Login Form (JSP DB Java Beans Session Tracking)
Hi, I need some help with my login form.
The design of my authetication system is as follows.
1. Login.jsp sends login details to validation.jsp.
2. Validation.jsp queries a DB against the parameters received.
3. If the query result is good, I retrieve some information (login id, name, etc.) from the DB and store it into a Java Bean.
4. The bean itself is referenced with the current session.
5. Once all that's done, validation.jsp forwards to main.jsp.
6. As a means to maintain state, I prefer to use url encoding instead of cookies for obvious reasons.I need some help from step 3 onwards please! Some code snippets will do as well!
If you think this approach is not a good practice, pls let me know and advice on better practices!
Thanks a lot!Alright,here is an example for you.
Assume a case where you don't want to give access to any JSP View/HTML Page/Servlet/Backing Bean unless user logging system and let assume you are creating a View Object with the name.
checkout an example (Assuming the filter is being applied to a pattern * which means when a resource is been accessed by webapplication using APP_URL the filter would be called)
public doFilter(ServletRequest req,ServletResponse res,FilterChain chain){
if(req instanceof HttpServletRequest){
HttpServletRequest request = (HttpServletRequest) req;
HttpSession session = request.getSession();
String username = request.getParameter("username");
String password = request.getParameter("password");
String method = request.getMethod();
String auth_type = request.getAuthType();
if(session.getAttribute("useInfoBean") != null)
request.getRequestDispatcher("/dashBoard").forward(req,res);
else{
if(username != null && password != null && method.equaIsgnoreCase("POST") && (auth_type.equalsIgnoreCase("FORM_AUTH") || auth_type.equalsIgnoreCase("CLIENT_CERT_AUTH")) )
chain.doFilter(req,res);
else
request.getRequestDispatcher("/Login.jsp").forward(req,res);
}If carefully look at the code the autherization is given only if either user is already logged in or making an attempt to login in secured way.
to know more insights about where these can used and how these can be used and how ?? the below links might help you.
http://javaboutique.internet.com/tutorials/Servlet_Filters/
http://e-docs.bea.com/wls/docs92/dvspisec/servlet.html
http://livedocs.adobe.com/jrun/4/Programmers_Guide/filters3.htm
http://www.javaworld.com/javaworld/jw-06-2001/jw-0622-filters.html
http://www.servlets.com/soapbox/filters.html
http://www.onjava.com/pub/a/onjava/2001/05/10/servlet_filters.html
and coming back to DAO Pattern hope the below link might help you.
http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html
http://java.sun.com/blueprints/patterns/DAO.html
http://www.javapractices.com/Topic66.cjp
http://www.ibm.com/developerworks/java/library/j-dao/
http://www.javaworld.com/javaworld/jw-03-2002/jw-0301-dao.html
On the whole(:D) it is always a good practice to get back to Core Java/J2EE Patterns.and know answers to the question Why are they used & How do i implement them and where do i use it ??
http://www.fluffycat.com/java-design-patterns/
http://java.sun.com/blueprints/corej2eepatterns/Patterns/index.html
http://www.cmcrossroads.com/bradapp/javapats.html
Hope that might help :)
REGARDS,
RaHuL -
Hi,
I am creating a java bean in a jsp file. I want to pass this bean to a java class in the same jsp file.
eg:
A1.jsp
<jsp:useBean id="customer" class="com.Customer" scope="session"/>
<jsp:setProperty name="customer" property="*"/>
<% Teller teller=new Teller();
int custid=teller.addCustomer("customer");
%>
Teller.java
public class Teller
public int addCustomer(*C*ustomer pcus)
CustomerDb Cdb=new CustomerDb();
return Cdb.addCustomer(pcus);
CustomerDb.java
public class CustomerDb{
int customerid;
public int addCustomer(*C*ustomer pcus){
try{
some code....
When I try to compile Teller.java and CustomerDb.java it is giving error in the lines highlighted with bold.
Please help in this.Problem Description
You are getting
FRM-40735: WHEN-BUTTON-PRESSED trigger raised unhandled exception ORA-105100.
When you run FileUpload utility
Solution Description
Follow the steps given below to fix and run the FileUpload Bean successfully.
Make sure you have set your System Path similar to following, in the same order:
System PATH:
E:\Dev6i\bin;E:\Dev6i\forms60\java;E:\jdk1.2.2\bin;E:\jdk1.2.2\jre\bin;
E:\jdk1.2.2\jre\bin\classic; %SystemRoot%\system32;%SystemRoot%;
%SystemRoot%\System32\Wbem;C:\Program Files\Oracle\JInitiator1.1.8.16\bin;.
CLASSPATH :
E:\dev6i\forms60\java;E:\dev6i\forms60\java\UploadServer.jar;
E:\jdk1.2.2\jre\bin\classic;E:\jdk1.2.2\jre\lib;E:\Dev6i\TOOLS\COMMON60\JAVA\IMPORTER.JAR;.
Now, Open Form Builder ->Layout Editor->Program menu->Import Java Classes
Check here to make sure that the FileUpload.class is displayed there under
Oracle/forms/demos/uploadclient folder.
Note that the java bean uses the implementation class
file oracle.forms.demos.uploadclient.FileUploader
So, you need to put the FileUploader.class in
<ORACLE_HOME>\FORMS60\java\oracle\forms\demos\uploadclient\FileUploader.class
or you need to change the oracle.forms.demos.uploadclient.FileUploader
in implementation Class property matching to
the class name where you have actually put it.
You need to set archive_jini=f60all_jinit.jar,uploadclient.jar.sig in formsweb.cfg
Open the fileupload.fmb, remove the attached Library.
Open the fileupload.pll from File->Open.
Recompile all the procedure and packages again.
Save this fileupload.pll.
Then reattach this library as a attached library to this form, recompile the form.
This should solve the problem.
If the path is set as explained above solves the PDEUI0001 problem of
Java Importer also.
Explanation
Reason:
This error occurs when the upload button is pressed in the File upload utility
because the attached PLL library is not compiled properly.
Please let me know if this helps.
Regards
Grant Ronald
Forms Product Management -
Need some help how to generate xml from java bean.
Hi,
Can some one help me how to generate the xml format output from a java bean.
The bean contains around 15 to 20 attribute values.
Thanks in Advance.
sarayuYou can use XMLEncoder with custom persistence delegates if needed:
http://java.sun.com/products/jfc/tsc/articles/persistence4/ -
Learning about Java Beans. Help!.
Hello all.
I want to learn to create and use JavaBeans, but not by where to begin.
Somebody can explain to me that it is a Java Bean and as is used.
Knows some site where it can see examples or it has a tutorial on Beans.
Thank you very much.Hi
I've just started learning Java too on my own. What I know about JavaBeans for the moment is that a JavaBean is a visual component you can create and give methods(setters and getters).
For example: JPanel, JLabel, JTextField, these are examples of JavaBeans, but you can also create them by yourself.
I use JBuilder 5 Enterprise from Borland. You can download JBuilder 6, trial version I belief from www.borland.com. I'm not certain.
How do I create JavaBeans in JBuilder?
First you have to create a new Project. Then you can go to the menu File/New and you choose to create a JavaBean. Then JBuilder asks for some information, which package, name, base class...
I've made a JavaBean, xJTextField. With each JTextField, ussually you also have a JLabel, so I've created a JavaBean xJTextField based on a JPanel. In that panel I've placed two components, a JTextField and a JLabel. I've added some methods and that's it. Now I can place an instance of xJTextField on every frame and automatically I have a JLabel and JTextField.
I have just begon too with Java, I hope I helped you a bit. If you would like it, I can send you my project with my JavaBean and some explanation.
Do you know some interesting websites about J2EE?
Rik -
Need help in countdowntimer in java bean for jsp page
hi..im student..i need help with countdowntimer in jsp page..with java bean component..im use XHTML MP for my jsp page so i can use it in cellular phone with WAP 1..can anybody help me with this problem..thx
hi..im student..i need help with countdowntimer in jsp page..with java bean component..im use XHTML MP for my jsp page so i can use it in cellular phone with WAP 1..can anybody help me with this problem..thx
-
Need help for traping imported java bean exception
hi everyone
i have imported a java bean into my forms 9i using java importer utility which tries to rename a file on a give path(bean works fine when executed through sql client).
i have problem when called from when button pressed trigger, it throws me an ("FRM-40735 and ORA-105101 NON ORACLE EXCEPTION") error.
i have imported java.lang.exception class and constructed an exception handler to trap java exception in the trigger
as
EXCEPTION
WHEN ORA_JAVA.JAVA_ERROR then
message('Unable to call out to Java, ' ||ORA_JAVA.LAST_ERROR);
--check for ORA-105101
WHEN ORA_JAVA.EXCEPTION_THROWN THEN
ex:= ORA_JAVA.LAST_EXCEPTION;
message('Java Exception --: '||BIException.toString(ex));
ORA_JAVA.CLEAR_EXCEPTION;
WHEN OTHERS THEN
message('error :'||SQLERRM);
when i imported java.lang.exception i did not find any wrapper pl/sql function or procedure declared to read or get the error messages except for the functions named "new" ,my exception handler failed.
so i tried with BIException which also fails to trap the error i have no idea about BIException and its usage with in forms ,Please do help me out with this issue ASAP.
thanks in advance
Rgds
yashHi,
don't understand what the BIException is supposed to do in your code, can you try
WHEN ORA_JAVA.EXCEPTION_THROWN then
ex := ORA_JAVA.LAST_EXCEPTION;
message('Exception: '||Exception_.toString(ex));
where Exception_ is the imported java.lang.Exception package.
Frank -
Hi frnds i want to help in servlet,java bean and JSP
hi friends i'm right now in M.SC(IT) and i want to do project in SERVLET,,JAVA BEANS and JSP ,
so pls give me a title about that
NOTE: I develop a project in group(2 persons there)
my email id is : [email protected] , [email protected] , [email protected]You cannot pair your iPod to a cell phone, so forget about it.
The only way you can get free WiFi is to hang out at a Denny's, a Starbucks, or a truck stop, and I don't think your parents would approve.... -
Help required in building up the Java Bean for an XML data
Hi ,
I want to build a Java bean which will actually represent an xml data . The class will be named as User and it will typically represent the data in the follwing xml:
<user>
<cwsId>barbete</cwsId>
<firstName>William</firstName>
<lastName>Barber</lastName>
<status>true</status>
<role>
<roleCode>1000000177</roleCode>
<roleName>Customer Administrator</roleName>
</role>
<language>en</language>
<country>US</country>
<preferences>
<equipmentGroup>2717</equipmentGroup>
<dateFormat>MON-dd-yyyy</dateFormat>
<timeFormat>HH:MI AM</timeFormat>
<timeZone>-12:00</timeZone>
<daylightSavings>Y</daylightSavings>
<location>NC</location>
<recordsPerPage>10</recordsPerPage>
<historyPeriod>3</historyPeriod>
<distanceUnit>MILE</distanceUnit>
<fuelUnit>G</fuelUnit>
<unitIdDisplay>E</unitIdDisplay>
<smuUpdate>W</smuUpdate>
<countries>
<country>
<countryCode>GB</countryCode>
<countryName>UNITED KINGDOM</countryName>
</country>
<country>
<countryCode>US</countryCode>
<countryName>UNITED STATES</countryName>
</country></countries>
</preferences>
</user>
Now for single child nodes like cwsId of the main user node i have kept properties like
private String cwsId;
But i am not sure as to how to represent the nodes which contain subnodes like "preferences"node. Any ideas?What is the standard practice?One thing you could do is create an object model first, which will contain all the data for your user.
then all you need in the bean is a Hashtable with the name of the user as a key, and the user-object (which is actually the complete object model) as a value.
with the XML stated by you, you would get an object model something like this:
Class User
String cwsid;
String firstName;
ArrayList<Role> roles = new ArrayList<Role>(); //I'm assuming a user can have more then one role.
ArrayList<Country> countries = new ArrayList<Country>();
class Role {
String code;
String name;
class Country {
String code;
String name;
}And so on for all the varioous elemets of your XML. -
Help : Unable to use Java Beans in Oracle forms 6i
Hi ,
I have been trying to run few sample code to understand how to use Java beans in oracle forms 6i .But have been largely unsuccessfull.
It will be great if somebody can provide me with some simple form( and java code )which uses java beans concept to give some data to the java program and receive some data from it . Pls inform me about the settings that need to be done.
If you guys know it then pls take the pains of writing a simple form and java code.
i hope somebody will respond because your reply is very necesary for me to proceed.
U can email me the code > [email protected]
Thanks in advance.Thanks for your reply Francois.
Actually i am not facing problem understanding the programming technique.
I think the problem at my end is more of a cofiguration one.I am using forms version 6i
on oracle 8.
Every time i set the imlementation class property of the bean area it gives an error 13010 which translates to that "the class being mentioned is not extending the IView class".
The class i have written extends VBean so i am not sure why this error is occuring.
I think if oracle (correctly) finds the java class to use then i will be able to proceed.
Pls reply.
If you have some code that is working fine then pls send it to me.And also inform is some environment variables have to be set for its use.
Maybe you are looking for
-
Formula interpreter logical operator
Dasylab 10 I'm capturing voltage from a daq, using formula interpreter to make calculations and then generating a XY graph. As the values are being generated I am wanting to display in a digital display the Y peak value and the corresponding X value.
-
I have an 8520 and I just came home from the hospital. I have upgraded to the 5.0.0.822 op sys the phone battery died before I was able to get home. When I go to plug it in after getting home it will not charge or even lite up when plugged in. I h
-
Embed files not in memory?
Is it possible to embed files into flash projector that will not be loaded into memory immediately after executing exe file? I need it to copyprotect my CD-ROM. Idea - there will be 100 MB MP3-file inside flash projector. This MP3 will actually never
-
Hour discrepancy between Outlook calendar and icloud calendar
My Outlook calendar, iphone, ipad and icloud are set to the same time zone and time zone support is ON. But when I create an appointment on outlook it appears +1 hour in my apple devices. When I creat an appointment in my apple devices it appears -1
-
Folks'ses, i have a sever problem with JScrollPane for which i need a good explanation/solution: i have a JPanel that contains various components (a tree display of database objects). everything works fine until... ... i put that JPanel in a JScrollP