How to design using J2EE pattern?
I am new to J2EE and I would like some ideas on how I should design the following system in J2EE pattern. I am required to use JSP pages + EJB to implement a very simple online shopping system. And I already created the following classes:
This is the EJB object interface.
package assignment;
import java.rmi.*;
import javax.ejb.*;
import java.util.Vector;
public interface ShoppingSystem extends EJBObject {
public boolean LoginAsCust(String id,String pwd) throws RemoteException;
public boolean LoginAsAdmin(String id,String pwd) throws RemoteException;
public Vector getMusicCategories() throws RemoteException;
public Vector getCategoryItems(String category) throws RemoteException;
public MusicRecording getMusicRecording(String id) throws RemoteException;
}This is the home interface.
package assignment;
import java.rmi.*;
import javax.ejb.*;
public interface ShoppingSystemHome extends EJBHome {
public ShoppingSystemHome create() throws RemoteException, CreateException;
}This is the session bean objects.
package assignment;
import java.rmi.*;
import javax.ejb.*;
import java.util.Vector;
public class ShoppingSystemBean implements SessionBean {
// data item to hold a reference to a passed Session context
private SessionContext ctx;
// save the session context
public void setSessionContext(SessionContext x) { ctx = x;}
// the various method implementations
// imposed on us by interface
public void ejbCreate() {}
public void ejbActivate() {}
public void ejbPassivate() {}
public void ejbRemove() {}
public boolean LoginAsCust(String id,String pwd) throws RemoteException{
public boolean LoginAsAdmin(String id,String pwd) throws RemoteException{
public Vector getMusicCategories() throws RemoteException{
public Vector getCategoryItems(String category) throws RemoteException{
public MusicRecording getMusicRecording(String id) throws RemoteException{
}I will probably need to create a shopping cart class and a database accessor class. What I would like to know is , do I need to divide the shopping cart class into three components: Home interface, EJB object interface, SessionBean object.
Please give me some ideas on how I can develop this system using EJB. (This is just a school assignment)
Thanks.
know is , do I need to divide the shopping cart class
into three components: Home interface, EJB object
interface, SessionBean object.Shopping cart is a typical example of a stateful session bean. So you need to write a session bean. And, of course, every session bean consists of three things: remote interface, home interface and bean class.
Please give me some ideas on how I can develop this
system using EJB. (This is just a school assignment)In this case you can tell them to fuk off.
Similar Messages
-
Which Design Pattern and how to design using OOP this scenario
I am having trouble designing a module, can anybody help me?
Because it will be hard to maintain this kind of module, I also think that this can test my skill of design pattern usage.
Requirement
This is basically an agricultural project (web application). I need to design a module where some calculation takes place.
There are different crops involved like maize, tomato, okra etc. Each of these crops has different traits.
Each trait has a measurement scale which lies in integer like 200-1000. Now let's say I have planted the crop and done measurement noted down the traits. Now I want to do some sort of measurement. Some measurements are simple and some are complex.
Example
Lets take an example of crop maize. I have recorded observations for 15 traits. (We'll use trait1-trait15 as examples, the actual name can be like plt_ht, yld, etc.)
I recorded 5 observations for each trait:
trait1 trait2 trait3 trait5 trait6..... trait15
01,02,03,04 01,02,03,04 01,02,03,04
User logs into system and selects his crops and enters data for these observations. I have to calculate either average or sum of the data entered for each trait.
Complexity / centre of the problem
So far it's simple but complexity comes when I have some different formulas for some of the traits.
Example: trait YLD has a formula based on which I have to calculate its value, which may also depend on some other traits. Each different crop can have different traits.
All this I am able to do - whenever user selects crop I will check for those specific traits and do calculations (if it's not a special trait then I either average or sum it, based on db entry), but there is a lot of hard coding.
I would like to have suggestions on a better way of handling this.
My code needs to handle both simple and complex calculations.
Simple calculations are easy, I have take average of value entered for trait.
The problem comes when I have to do complex calculations, since each crop have different traits with their own formulas, so to calculate I have to check for crop and then for complex trait. So I have to hardcode the trait name of complex traits.
Can any tell me how I can design this using Java oops [?!?] so that I can make it generic?
I have about 10 different crops. Some calculations are specific to crops, so there will be lot of code like the if below:
hasZeroValue = (HashMap<String, ArrayList<String>>) dataValues[1];
} else if(cropId.equalsIgnoreCase("MZ") && traitName.equalsIgnoreCase("Shelling")) {
avg=HybridTestDataUtility.calculateAvg(traitName, dataPoint, dataTraits, traitValues,dataPvalues, dataPoint, type);
avg=avg*dataPoint;
traitAvg=getMaizeYeild(traitName, traitAvg, population, avg, hybrid, area);
} else if(cropId.equalsIgnoreCase("OK") && traitName.equalsIgnoreCase("YLDGM")) {
avg=HybridTestDataUtility.calculateAvg(traitName, dataPoint, dataTraits, traitValues,dataPvalues, dataPoint, type);
//avg=avg*dataPoint;
Object[] dataValues=getOKRAYield(traitName, traitAvg, population, avg, dividend,hasZeroValue,hybrid,repl);
traitAvg = (HashMap<String, Float>) dataValues[0];
hasZeroValue = (HashMap<String, ArrayList<String>>) dataValues[1];
} else if(cropId.equalsIgnoreCase("HP") && traitName.equalsIgnoreCase("w1-w10")) {
avg=HybridTestDataUtility.calculateAvg(traitName, dataPts, dataTraits, traitValues,dataPvalues, dataPoint, type);
avg=avg*dataPoint;
Object[] dataValues=getHotPepperYield(traitName, traitAvg, population, avg,dividend,hasZeroValue,hybrid,repl);
traitAvg = (HashMap<String, Float>) dataValues[0];
hasZeroValue = (HashMap<String, ArrayList<String>>) dataValues[1];
} else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("TLSSG_70")) {
traitAvg=calculateTLCV(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues,50);
} else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("TLSSG_100")) {
traitAvg=calculateTLCV(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues,50);
} else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("YVMV_60")) {
traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
} else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("YVMV_90")) {
traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
} else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("YVMV_120")) {
traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
} else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("ELCV_60")) {
traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
} else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("ELCV_90")) {
traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
} else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("ELCV_120")) {
traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
} else if(cropId.equalsIgnoreCase("OK") && traitName.equalsIgnoreCase("YVMV_60")) {
traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
} else if(cropId.equalsIgnoreCase("OK") && traitName.equalsIgnoreCase("YVMV_90")) {
traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
} else if(cropId.equalsIgnoreCase("OK") && traitName.equalsIgnoreCase("YVMV_120")) {
traitAvg=tomatoYVMVCalculation(traitName, traitAvg, dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
} else if(cropId.equalsIgnoreCase("OK") && traitName.equalsIgnoreCase("ELCV_60")) {Can anybody think of a way to make a generic approach to this?There are crops and each crop have traits , traits are actually a mesuremet
scale to decide growth of a seed of a particular crop.
This module is to for planters to observe growth of seeds sowed of certain
crops and take down n no of observation for each trait and upload in csv format.Once they enter
data i have to either avg out the values or sum the values or sometimes
there are more complex function that i have to apply it may differe for each
trait .This is the whole module about.Just to give an idea about how they
will enter data
Hyubrid(seed) trait1 trait2 trait3 trait5 trait6..... trait15
Hybrid1 01 02 03 04 01
HYbrid2 04 06 08 04 01
HYbrid2 04 06 08 04 01
HYbrid2 04 06 08 04 01
HYbrid2 04 06 08 04 01
Once they enter data in this format i have to give result something like
this.
Here avg colum does not necessaryly mean avg it can be sum or any formula
based resutl.Hybrid is the seed for which they record the observation.
I have shown avg column only for two tratis it is actually for all the
traits.
Hyubrid(seed) trait1 Avg trait2 avg trait3 trait5 trait6..... trait15
Hybrid1 01 01 02 04 03 04 01
HYbrid2 04 04 06 10 08 04 01
HYbrid2 04 04 06 12 08 04 01
HYbrid2 04 04 06 14 08 04 01
HYbrid2 04 04 06 12 08 04 01
Hope this clarifies atleat a but
The data are not correctly indented but there is no way i can format it. -
Simple design using J2EE, examples?
Warning newbie question...
I'm in the process of designing a simple Web App that allows a user to submit an HTML form that passes the information to a database to be stored.
Other info:
- Can use only J2EE
- App server is JBOSS
- DB2 database
- Would like to use EJB's as I suspect this app has a lot of growth behind it.
Does anyone know of any examples that show how to do something similar to what I described above?
Any feedback is appreciated. thanks!know is , do I need to divide the shopping cart class
into three components: Home interface, EJB object
interface, SessionBean object.Shopping cart is a typical example of a stateful session bean. So you need to write a session bean. And, of course, every session bean consists of three things: remote interface, home interface and bean class.
Please give me some ideas on how I can develop this
system using EJB. (This is just a school assignment)In this case you can tell them to fuk off. -
How can I use j2ee(jsp) connect msolap
I look for long,but not find,please tell me.thanks
I don't think you really searched all that hard.
http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=jsp+msolap -
Can I use j2ee in gprs mobile phone?
How can I use j2ee in gprs moblie phone?
Actual mobile phone are unlikely to support J2EE themselves as this is mostly server-side technology.
You can get phones though that support J2ME, these can the communicate with a server running J2EE technologies.
I'm not sure however if any gprs phones yet support J2ME, and it also depends on where you live.
Try looking in the devices section at www.microjava.com -
Question of using Struts for the J2EE pattern
I am now using Struts for the development. I have 3 questions about J2EE
pattern by the use of Struts:
1) How can I use Struts to create the Front Controller? In the book
descibing Front Controller, it is a servlet file which receives the request
and then dispatches to the appropriate view according to the request.
However, in using Struts, should I use the same way? However, I found that
in using Struts, I can call the controller class which subclass
ActionServlet, all the views forwarded are declared in the
struts-config.xml. Am I right in this method?
2) In the project, there is a Front Controller which dispatches the request
to the appropriate view (jsp file). Of course, I use Struts to do this.
However, I expect that the user is impossible for going to the view (jsp
page) directly by typing the address of the jsp file. I hope that the user
can go to the view through the controller only. How can I do this?
3) There is a problem by using browser - when a user browses a site, he can
press the 'back' button to the previous page, and then click the 'forward'
button also. How can I prevent this by using Struts? I found that in some
sites, when the user clicks the 'back' button, an error page displays. How
can I do this? Thanks!
Many Thanks!
StephenI'll take a stab at number 2 and number 3.......
2) You could have the controller object place a "flag" in the request that is dispatched to the JSP. Make the JSP check for that flag to ensure that this request came from the controller object. If the request comes from anywhere other than the controlle object, you can display an error page, or you could redirect them back to the controller. You could also use the HTTPSessionObject to place flags for users and have the JSP check there.
3) Keep a log of the user's activities in the HTTPSession. Whenever a page is invoked, have it check to see if the user has already been here, and if it is appropriate for the user to be here again.
Hope this helps!!
I'm not really a java programmer, I just play one on TV. -
How to publish crystal report designed using SAP Add-on toolbar
we have installed the crystal report designer V10 and the SAP add-on on the desktop.
we have designed a formatted report in crystal report designer using an existing BW report that was created using Bex query designer. After this we saved the crystal report back in BW to a role.
We have not published the report to crystal enterprise server, since the connection to same is not in place.
We would like to know how to publish this report in Enterprise portal ?
Can we bypass publishing the report to crystal enterprise server and publish the report on browser or through EP ?hi
Check on this help page if it can help you
http://help.sap.com/saphelp_erp2004/helpdata/en/f1/0a569ae09411d2acb90000e829fbfe/frameset.htm
REgards
Alain -
How to design SSRS report using SharePoint 2010 List Version History
Hello,
I am using Sharepoint 2010 list, i need to design SSRS report using Sharepoint List Version History. Could please let me know how to design.
Thank you.
Kind RegardsYou could do that with SQL Server Reporting Services, Please follow the instructions from the link below:
http://www.mssqltips.com/sqlservertip/2068/using-a-sharepoint-list-as-a-data-source-in-sql-server-reporting-services-2008-r2/
Hope that would work fro you.
Please Mark as Answer, if the post works for you.
Cheers,
Amar Deep Singh -
How to upload a file into server using j2ee jsp and servlet with bean?
How to upload a file into server using j2ee jsp and servlet with bean? Please give me the reference or url about how to do that. If related to struts is more suitable.
Anyone help me please!u don't need j2ee and struts to do file uploading. An example is as such
in JSP. u use the <input> file tag like
<input type="file"....>You need a bean to capture the file contents like
class FileUploadObj {
private FormFile srcFile;
private byte[] fileContent;
// all the getter and setter methods
}Then in the servlet, you process the file for uploading
* The following loads the uploaded binary data into a byte Array.
FileUploadObj form = new FileUploadObj();
byte[] byteArr = null;
if (form.signFile != null) {
int filesize = form.srcFile.getFileSize();
byteArr = new byte[filesize];
ByteArrayInputStream bytein = new ByteArrayInputStream (form.srcFile.getFileData());
bytein.read(byteArr);
bytein.close();
form.setFileContent(byteArr);
// Write file content using Writer class into the destination file in the server.
... -
How to use report designer using bex analyser give screenshots details
how to use report designer using bex analyser give screenshots details
Hi,
As per my understanding you want to see Query Designer when you execute the query in BEx Analyzer.
When you launch BEx analyzer,you should be able to see new tab of "Business Explorer" in your Toolbar.
So,when you execute the query in BEx analyzer,in order to goto query designer screen,click on Tab "Business Explorer",select option "Change Query" and then select the option "ChangeQuery (Global Definition)".
It will open the query designer in which you can modify the query and save it.
Regards,
Nilima -
How to use report designer using bex analyser ineed screeenshots steps
how to use report designer using bex analyser ineed screeenshots steps
Please try to search and stop asking for all types of screen shots. Thanks!
-
Hi all.
Sorry if this seems a simple question but I really sorry for the troubles. I'm a new user with LabVIEW and currently using LabVIEW 8.6 for a final year project of mine. I’m trying to monitor the temperature reading in 4 different depth of pavement for every 1 hour interval continuously for 1 month duration. Basically I’ll be using 4 separate thermocouples type J and NI 9219 device. My problems are:
I’m not sure how to design the LabVIEW programming for my application.
How to get the temperature reading data in Excel spread sheet.
How to set the min, max and average daily temperature for each thermocouple.
Thank You.
Regards,
Amanus
Thermocouples Layout:
Solved!
Go to Solution.Introduction to LabVIEW
Follow that link to some getting started tutorials. There should be all you need in there to get you going with both the software and hardware
- Cheers, Ed -
How to design a layout using coding?
hi
how to design a layout using coding?Could this help you??? <a href="https://wiki.sdn.sap.com/wiki/display/profile/2007/07/19/Editingthestandardtemplateforanewprogram">https://wiki.sdn.sap.com/wiki/display/profile/2007/07/19/Editingthestandardtemplateforanewprogram</a>
Greetings,
Blag. -
How to design and use tabstrip in webdynpro
hi,
i trying to design tabstrip in webdynpro(SE80), i dont know how to design and use it. if u have screenshot or any other document give me. its pretty useful for my requirment. guide meHi Saravanan,
In your view, you have to add the UI element TabStrip. You will have an empty tab strip then. Right click on the tab strip, and add a 'Tab'. Continue in this manner to add as many tabs as you want. Each tab will have a header, specify the tab title in that.
Now go to each tab, right click and insert element. You could insert any element like a table, Input fields etc. Event handling has to be done separately for these elements. At the tabstrip level, you need to handle only the onTabSelect event. This is the event triggered when you change tab selection in the tabstirp. In the properties of the tab strip, there will be a field selectedTab. Specify the ID of the tab which you want as selected. This will be your initial selection.
You can also enable and disable tabs, say grey out tabs that have no data etc. All this can be done by context attribute binding.
You can also refer to the view by name TABSTRIP in the component WDR_TEST_EVENTS.
Regards,
Uday -
How to use CQL patterns in CEP?
Hi,
How to use CQL patterns and what is the use ?Try the new Stream Explorer interface and check out the patterns section. These are pre-defined patterns that allow you to look for trends, missing events, duplicates, W Pattern, etc. These do in-memory incremental processing of data with high throughput and low latency.
The SX user interface allows you to easily define a data stream and start applying a pattern. An Event Processing Network (EPN) with a CQL processor and the CQL are generated automatically and the results are immediately shown on the user-interface.
Maybe you are looking for
-
Safearray in ABAP - (JAVA PropertyValue)
Hi, I like to open a OpenOffice file in ABAP. For this I need a paramter array that is call in JAVA PropertyValue How can I do this in ABAP? For more infos look at this question vom xonox in the OO-forum http://www.oooforum.org/forum/viewtopic.phtml?
-
How to make a pdf bookmark in Preview?
I have merged a couple of PDF files and I want to set the bookmarks to be able to locate the begging of each one more easily. How can I do this?
-
When I connect my iPhone to my iTunes, my iTunes doesn't detect the phone
When I connect my iPhone (iPhone 3GS) to my Mac laptop, my iTunes (10.5.2) doesn't detect my phone, but the phone sti charges and acts like it's properly connected. On the iTunes, there is no icon revealing that the iPhone is detected, what can I do
-
Hi, I created a PDF form where I have open, next, previous buttons, and I'm able to connect to the access database, and it's working fine. Now, I want to be able to search by last name from the access database, and retrieve the results in a dropdown
-
Can IMAP be setup with IOS 8?
I cannot see any of my sub folders in my mailbox? Is always seems to default to pop settings (port 110) vs. imap (port 143)?? Port 143 gives an error, server not responding...?