Want detailed sample code(value list handler pattern) for my case

I am trying to write a Session Facade Bean with getAllUsers() method which get Collection pased from my UserBean(entity), to get all my users info.and I have a helper class called UserInfo
public class UserInfo implements java.io.Serializable
public String userid;
public String username;
public String password;
     public UserInfo()
     public void setUserInfo(String userid,String username,String password)
          this.userid=userid;
          this.username=username;
          this.password=password;
I dont' know How my ejb client(jsp maybe) to use value list handler pattern to implement getting all users shown.
I found http://java.sun.com/blueprints/corej2eepatterns/Patterns/ValueListHandler.html the sample code is to complex.
any one could help me figure out ...
what helper class do i need .or maybe interface
what is the best practice?
thanks in advanced.

Hi,
For a J2EE system with session facades, I've implemented that pattern based on the DTO pattern.
The idea is based on Sun's blueprint Pet Store implementation.
For that' I've created a DTO called "ListChunk", which holds a chunk of the complete list. In the Pet Store
application v1.3.2 it's called "Page".
So, those facade methods that would possibly return a huge list (such as getAllXXX and findXXX)
return a ListChunk. As arguments, those methods take start index and the maximum size.
If you want a value-list handler to control the iteration on your client side, you code such a class that
uses the facade method.
Here's some code:
public class ListChunk implements Serializable {
     private List list;
     private int startIndex;     // starts on '0'
     private int totalSize;
     public ListChunk(List list, int startIndex, int totalSize)  {
          this.list = list;
          this.startIndex = startIndex;
          this.totalSize = totalSize;
     public List getList()  {
          return list;
     public int size()  {
          return list.size();
     public boolean hasNext()  {
          return totalSize > (startIndex + list.size());
     public boolean hasPrevious()  {
          return startIndex > 0;
     public int getTotalSize()  {
          return totalSize;
}And a method in the facade could look like this:
     public ListChunk getAllCoWorkers(int startIndex, int maxSize, CoWorkerSortBy sortBy) {...}

Similar Messages

  • Connecting To Same Value List Handler

    I have a question about using the Value List Handler pattern. Right now I am just working on the design of my application (class diagrams, scenario diagrams, etc).
    I have a VLH that will retrieve data from the DB (via a DAO) and will return data to the caller. The VLH basically fronts the DAO. The caller in this case will be a Business Delegate. So the call sequence is:
    client (JSP) --> Business Delegate --> Value List Handler --> DAO
    Now the VLH is a stateless EJB. But the Business Delegate is just a plain Java class that will get instantiated on every call to the server. My hope is that it will connect to the same VLH instance (I use a ServiceLocator). But I'm not sure this will happen.
    According to what I read about Stateless Session EJBs, they are dedicated to a single client. But what is the "client" in my scenario? Is it the browser session? Or is it the Business Delegate? If its the latter, then will new instances of the Business Delegate be able to connect to the same VLH?

    Use a stateful session bean! Says so on the Sun Blueprints site for this pattern.

  • Value-list handler, value-list iterator and session-facade strategy

    Hello all,
    Further to an earlier post, I rewrote my post trying to me more accurate in my question.
    Here is my problem:
    I am trying to implement the value-list handler design pattern using the session facade strategy. In the pattern as it is described here
    (http://java.sun.com/blueprints/corej2eepatterns/Patterns/ValueListHandler.html) the client accesses the value-list handler AND the iterator directly.
    As I chose the session-facade strategy having my value-list handler as a stateful session ejb, I don't know how the client is going to access the iterator. I see only one option: Having the client access the iterator through the ejb value-list handler. This requires adding new methods to the ejb.
    Is this the correct way of doing it? Is there another way of doing this?
    Thanks in advance,
    Julien Martin.

    u can use project list handler as ur session facade.
    regarding ur second question ..session facade and value list handler session bean which is also a session facade( but there is difference between first and second) so u can use session facade and value listhandler

  • Caching using - Value List Handler

    Hi All,
    Iam new to Value List Framework.I had a doubt regarding the caching in Value List Handler.Suppose there are 1000 records in DB.I querying the DB using Value List Handler.I want to display the paging functionality in JSP.That is i want to display 50 recodrs each in the jsp.Then if have to provide the Link for another set of records.I had donr this functinality.What is the problem is if i click the hyperlink which is provided for PAgination Functionality now it is hiting the DB and fetching the recodrs and iam showing in JSP.I don't know how to do the Caching functionality using Value List Handler.so that i can avoid each time DB hit.First time i will hit the DB fetch all the records and store it in the Cache.Can anyone help me regarding this issue.

    hi [email protected]
    can you plz provide me some stuff for pagination using toplink. I am new to toplink and need to use pagination.

  • Transfer Objects in Value List Handler

    Do we need really the EJB for Caching the data using Value List Handler.If EJB is not required then how can we cache the data using Value List Handler

    Sorry for disturbing u again.Actually my requirments
    is , In the Jsp page i have to display 1000You are referring to java server pages and not java script correct?
    records(example) provided with pagination option ie
    each page should display 50 records and options will
    be given to user to see another 50 records by
    clicking the pagination hyper link.This time it
    should pick up from Cache memory not form DB.I came
    to know thru documentation posted in website that
    ValueList Handler provides the Caching Facility.Can i
    achieve this by using ValueList Handler.You can achieve it in any number of ways.
    Nothing in your description suggests that Value List Handler is going to help you in any substantial way.
    Another
    restrictions is not to use EJB.You have to get the data from somewhere.

  • Need sample code to get handle of Selected rows from ADF Table

    Hi,
    I am new to ADF. I have an ADF table based on VO object.On some button action,I need to get handle of selected rows in application module.
    If anybody is having sample code to do this then please share with me.
    Thanks,
    ashok

    wow now link http://blogs.oracle.com/smuenchadf/examples/#134 is working.thanks a lot.
    also the link http://baigsorcl.blogspot.com/2010/06/deleting-multi-selected-rows-from-adf.html is very useful. Thanks a lot for Sameh Nassar too.He made it clear that in 11g Select column is not available for a ADF table and provided a solution to get Select column.
    Thanks,
    ashok

  • Want help in compiling a list of upgrades for my Quicksilver (UK)

    Well my Quicksilver will be arriving in a few days and after asking a couple of questions about upgrades I'd now like to compile a list of upgrades for me to buy so I can everything with ease. I live in the UK and can you use eBay and any other website/source as long as it can get to the UK. I'd like to upgrade the following to begin with:
    - Sound card
    - RAM
    - Graphics card
    - USB 2.0 ports
    - DVD drive
    - PSU
    - Any other good PCI cards
    And the following later on:
    - Hard drives
    - CPU (if I feel I need to)
    So can you guys help me compile a list of recommended upgrades for each component and where I can buy the parts from as long as I can get them to the UK? I'd appreciate it very much.

    Hi-
    Recommend not leaving the hard drive for last. Machine performance is dependant on hard drives, and the faster the better. This should be the first item on your list.
    WESTERN DIGITAL Caviar SE16 WD3200AAKB
    Install maximum memory, 3x512MB PC133 DIMMs. Use only quality Mac compatible guaranteed memory.
    PC133 SDRAM DIMM 512MB
    Might be cheaper to buy from the US and pay VAT.
    OWC 512MB PC133 CL2 2-2-2 168 Pin High Performance SDRam
    A USB 2.0 PCI card does not have to be stated as Mac compatible if it has the NEC chipset.
    NEC Chipset 5 Port USB 2.0 Card
    Scan 5 Port PCI USB2 Card
    For optical drive, recommend the Pioneer DVR-112 or the DVR-115.
    Optical drives.
    For graphics card, you need 4x AGP graphics, with Core Image support. You'll have to buy the 9800 Pro Mac from the US, or search eBay for an ATI Radeon 9700 or 9800 Pro (must be Mac compatible stated). Flashed PC cards (made Mac compatible) Geforce 6200, 6800GT or Ultra, or 7800GS are also available on eBay.
    Radeon 9800 Pro Mac Edition
    You don't need to upgrade the PSU.
    Sound cards are only available from M-Audio, or, get a sound card in a box in the Griffin Firewave.
    If you plug good external speakers into the audio out, you can get excellent sound without a card.
    Recommend Harmon Kardon Soundsticks
    And, finally, CPU upgrades in the UK are pretty well limited to Sonnet.
    See MacUpgrades

  • I want to sample code (select query type is AQ$_SUBSCRIBERS)

    Hi.
    Now coding, OCI..
    select * from SYSTEM.AQ$_QUEUES;
    ~~~~~~~~~~~~~~~~~
    Data type is AQ$_SUBSCRIBERS.
    Help me.
    output to sample source.
    Thanks.

    * Such details are stored in a cookie.
    * You must allow that cookie (Tools > Options > Privacy > Cookies: Exceptions)
    * Make sure that you do not use [[Clear Recent History]] to clear the "Cookies" and the "Site Preferences"
    See also [[Enabling and disabling cookies]] and http://kb.mozillazine.org/Cookies

  • Problem with running sample code from XML Schema Processor for Java

    Hi there,
    I downloaded the XML Schema Processor for Java and tried it out. Unfortunately, it failed at the first step. FYI, I included all xmlparserv2.jar and xmlschema.jar in my classpath.
    I compiled XSDSample.java with a warning: XSDSample.java uses a deprecated API. Recompile with "-deprecation" for details. There was no problem with compiling XSDSetSchema.java.
    When I tried to run report.xml by typing java XSDSample report.xml, I got Parsing report.xml
    NonParserException: null.
    I guess that report.xml from the sample is not valid.
    Could any one give me a hint? Any suggestion would be greatly appreciated.
    ---Denali
    null

    Please post this message at:
    Forums Home » Oracle Technology Network (OTN) » Products » Database » XML DB

  • Do I need a Singleton pattern for this case

    Hello,
    I'm writing a game in Java and I have a very simple score manager class which just tracks the points the player so far has. I need to access this class in different pars of my app (gui, game core ...) so I created a singleton class which looks like this
    public class ScoreManager {
            private static ScoreManager instance = new ScoreManager();
            private int score = 0;
         private int highScore = 0;
         public static ScoreManager getInstance() {
              return instance;
         public int getScore() {
              return score;
         public int getHighScore() {
              return highScore;
         public void addScore(int scoreToAdd){
              score += scoreToAdd;
              if(score > highScore) {
                   highScore = score;
    }so far so good ..
    I would like to read the "highScore" from a file when the game starts and write it back when the game ends. I added those two methods:
         public void init(File highScoreFile) {
              highScore = readFromFile(highScoreFile);
                    score = 0;               
         public void dispose(File highScoreFile) {
                   writeToFile(highScoreFile);
         }So basically I call the init() method when the game stars and the dispose() when the game ends.
    It works but what I don't like is that the init() and dispose() methods are exposed and someone could call them in a wrong place.
    What would be a better way to do this ?
    Thanks for your help,
    Jesse

    safarmer wrote:
    You could keep track of the state (initialised, destroyed etc) in the manager and only perform the action if it is an expected state.
    private enum State { NOT_INITIALISED, INITIALISED, DESTROYED};
    private State currentState = State.NOT_INITIALISED;
    // i will leave the rest up to your imagination :) this looks good, thanks
    anotherAikman wrote:
    >
    It works but what I don't like is that the init() and dispose() methods are exposed and someone could call them in a wrong place. And who would that be? You´re the only one using the code, aren´t you?
    If not, you could still include in the documentation where to call those methods.
    no I'm not the only one working on this. Documentation can be useful but does not prevent calling wrong methods.
    YoungWinston wrote:
    I don't see any constructor. Usually, a singleton class should have a private one, even if it has no parameters. If you don't have any, Java will create a public no-parameter one as default.ok I forgot the private constructor.
    It works but what I don't like is that the init() and dispose() methods are exposed and someone could call them in a wrong place. Then my advice would be not to make them public. After all, your code is the only one calling these methods - yes?yes only the code of the app calls it.
    If you are convinced that your game requires one and only one score manager, then a singleton is probably the best way to go.
    I'm a little worried about the init() and dispose() methods though, because these suggest state changes, which is unusual for the singleton pattern. You may want to think about synchronizing them.
    An alternative might be to use properties to get and store your scores.ok for the synchronization. What would using the properties ? It would be just another type of storage backend and I'd still need to read/write it.
    Thanks for your help,
    J

  • Attachment: 'Hello World' word doc in zprogram - need sample code

    Team,
    I want a sample code for using 'Attachment' functionality. How to attach word docs, excel or images using a zprogram. For example, if I have a list of candidates then for each candidate (which is a single record) I want to attach candidate's resume.
    Thanks

    Hi ArS,
    Thanks for your reply.
    I am not familiar with SWO1.
    I did try to copy an existing object ype 'ADDRESS' to ZADDRESS.  On the following screen:
    Object Type      ADDRESS  
    Program          RSSOOT02 
    Object name      Address  
    Object Type      ZADDRESS  
    Program          ZRSSOOT02 
    Object name     ZAddress  .
    When I checked there were no inconsistencies. But when I  test I get the following:
    Obj Type ZADDRESS can not be executed.
    ***Also, What is CL_GOS_MANAGER?

  • Value List- EHP4

    Hi,
    We are working on PMR-ehp4. We have some ratings for the appraisals EX: 1- 5 Scale but when we see the same scales on portal as a standard SAP EHP4 fucntionality the blank fields against the ratings are showing "No value" Text on the portal.
    Could any one please share your inputs how to bring the "blank field" instead of "No Value" text.
    Thanks in advance
    VK

    u can use project list handler as ur session facade.
    regarding ur second question ..session facade and value list handler session bean which is also a session facade( but there is difference between first and second) so u can use session facade and value listhandler

  • BC4J - where is the best place to keep "Code" values?

    For tables with "Code" values (such as "ACCTG" for "Accounting", "RD" for "Reasearch and Development", etc) where the Code itself is a key (PK or AK) of the table and where I would be doing comparisons to a code value (such as setting a runtime where clause or param value), I generally build a wrapper class for the table and create public static final String values for the code values, so as not to litter these values throughout my code/pages/etc (centralizing maintenance when code values change, etc). The problem is that #1, these classes generally live in my application packages, resulting in less direct reuse and #2, changes to code values require recompilation, redistribution of the affected classes and restarting of OC4J listeners (as the classes are in the classpath).
    I would ideally like to find a place w/in the BC4J framework to declare these in an XML file (such as EntityXYZ.xml) that I could then access at runtime (w/o accessing oracle.jbo.server package objects). However, as my lookup VO's are SQL-based, not EO-based, I don't have a direct route via ViewRowImpl to the EntityImpl so that I can access the EO's XML properties. I don't really want to set them as properties of a VO, as multiple VO's could use these same codes, so I'd be back to a maintenance problem. Ideally, I would like to have these code values in some location that transcends AMs (ie, not define then at the AM-level either), as I could be using the same underlying table Code values in various AMs and would like to maintain these code values in only one place outside of the database. It seems that putting them on an EO, since that could be considered the BC4J definition of a table, and providing static access (for efficiency's sake) via some means would be a good solution, but I have concerns about the effect of "sharing" EOs across AMs as well as the problem w/ not wanting to directly access an EntityImpl in my client code (ie, when I don't have a VO hook to an EO).
    How are folks implementing this type of thing via BC4J? (Or are they at all?) Clearly, I could take the next step and implement this stuff better on my own than I'm currently doing, but would like to take advantages of BC4J's built-in XML property capabilities versus write my own (and it would be a more centralized place to keep that info, as well...)
    Thoughts, suggestions??
    Thanks,
    Jim Stoll

    Thanks for the reply Steve! I'll take a deeper look into the ToyStore app - an initial browse through didn't seem to reveal what I was looking for, but I was admittedly looking for a particular style of solution. I'll look at the .properties file scheme straightaway.
    I understand the ability to share VOs across AMs, as I do that pretty regularly. My concern about specifying code values at the VO level arises from the (likely) possibility that I could have more than one VO that needs to reference a lookup table 'code' value, and want to avoid having to specify the code values in more than one VO. I could build a 'reference' VO that held the code values as properties (or even hard-coded rows, I suppose), but would that not require me to create an instance of that VO when I wanted to reference the code values, even if I didn't need an actual instance of the VO? (My ideal goal is to mimic the efficiency and ease of access of a public static final variable.)
    I'll take a look at that .properties file based implementation and get back with any questions.
    Thanks Again!!
    Jim

  • Socket Programing in J2ME - Confused with Sun Sample Code

    Hai Everybody,
    I have confused with sample code provided by Sun Inc , for the demo of socket programming in J2ME. I found the code in the API specification of J2ME. The code look like :-
    // Create the server listening socket for port 1234
    ServerSocketConnection scn =(ServerSocketConnection) Connector.open("socket://:1234");
    where Connector.open() method return an interface Connection which is the base interface of ServerSocketConnection. I have confused with this line , is it is possible to cast base class object to the derived class object?
    Plese help me in this regards
    Thanks in advance
    Sulfikkar

    There is nothing to be confused about. The Connector factory creates an implementation of one of the extentions of the Connection interface and returns it.
    For a serversocket "socket://<port>" it will return an implementation of the ServerSocketConnection interface. You don't need to know what the implementation looks like. You'll only need to cast the Connection to a ServerSocketConnection .

  • ServerSession in FBS  (otn sample code)

    I download FBS OTN sample code which version
    use Toplink for manage persistence..
    I have notice about some class that hold
    ServerSession as it member variable
    such as
    ////////////// FBS
    package oracle.otnsamples.ibfbs.trademanagement.helper;
    public class StockRateHelper {
    // Toplink Server session
    private ServerSession server = null;
    public StockRateHelper()
    throws TradeManagementEventException{
    try {
    // Initialize ServerSession from session.xml
    server = (ServerSession) SessionManager.getManager().getSession(new XMLLoader(),
    "FBSServerSession",
    Thread.currentThread().getContextClassLoader());
    }catch(DatabaseException dbEx) {
    throw new TradeManagementEventException(" Error initializing Server Session :"+dbEx);
    public void loadRates(Collection stockRates)
    throws DatabaseException {
    // Initialize client session
    ClientSession client = server.acquireClientSession();
    // Enable batch-writing [ Write Optimization ]
    client.getLogin().useBatchWriting();
    // Sequence pre-allocation has been enabled in project.xml with size of 50
    // Get a transaction
    UnitOfWork uow = client.acquireUnitOfWork();
    // Register the objects with transaction
    uow.registerAllObjects(stockRates);
    // Commit
    uow.commit();
    I can deploy and run this sample (after spend a moment
    for fix database schema) on OC4J10g developer preview
    I have some Question
    - why ServerSession not need to login before it provide ClientSession
    - I don't see code for disconnect (logout) from DB , does it cause resource leak ?
    thank you

    Hi,
    why ServerSession not need to login before it provide ClientSession.When we use SessionManager to retrieve sessions, in the call to getSession(), if the session is not already in the session manager's in-memory cache of sessions, the session manager creates the session and logs in. Hence we don't have to login explicitly( when using SessionMananger).
    To open Session with No Login
    SessionManager manager = SessionManager.getManager();
    Session session = manager.getSession( new XMLLoader(), // XML Loader (sessions.xml file)
                                              "mysession", // session name
                    YourApplicationClass.getClassLoader(), // classloader
                                                    false, // log in session
                                                   false); // refresh session
    I don't see code for disconnect (logout) from DB , does it cause resource leak ?When using a three-tier architecture ( Sever-Client Session ), the client session is used to perform all operations. The client forwards all the request to the server session, which either operates on the cache or the database ( if the data is not present in the cache) . Hence the sever session is the entity that takes care of managing database resources and it has the intelligence built-in to manage the connections and resources. We don't have to worry about that. Finally when the
    application goes down, we must take care of closing the server session.
    We hav't explicitly closed the sever session in this application. If you require to close the server session and not
    depend on the timeout mechanism, you can explicitly close the connection when the application is destroyed.
    LoadDataServletCtxLsnr.java
    public void contextDestroyed(ServletContextEvent sce) {
        // Close server session
    I have notice about some class that hold ServerSession as it member variableAll the classes point to the same instance of SeverSession and they don't have seperate instances. There can be only one seversession for an application. The ServerSession instance is got from the Sigleton class SessionManager which manages the ServerSession.
    HTH.
    Regards
    Elango.

Maybe you are looking for

  • Getting the error while loading the master data

    Hi i have tried to delete the master data using right click and delete master data, but still there are data. Now i am trying to load this master data again then i am getting the message "0 from 50033 records" and data load got failed with error mess

  • SPA IP phones doesn't show calling number after the call was picked UP

    Hello,    Our different CISCO SPA IP phones models (at this time we are using 7.4.8a version) are working with Broadsoft AS. And now we have a problem: when CISCO SPA IP PHONE pickups the call ( by pressing BLF lamp) and the call is connected, Cisco

  • Now a new problem ejecting disc

    I inserted a music CD to copy to iTunes and after I tried to eject it but got this - "The disk "Untitled CD" is in use and could not be ejected. Try quitting applications and try again. I quit all applications but still it will not eject just says th

  • Strange Get-EventLog Error

    Hi, Scripting guru! I try to execute command: Get-EventLog-LogNameSecurity-Newest5 And get error: Get-EventLog : Log "Security" could not be read to completion due to the following error. This may have occurred because the log was cleared while still

  • Soft screeching sound on Muvo V200 when backlight is on

    Um, anyone pls help me... I just bought my Muvo V200 and the first time I on it, there's a soft screeching and disturbing sound.. But when the backlight off, the sound disappears.. When i press a button, the backlight ons and the same screeching soun