Push messages from business logic into backing bean

In my simple web application a table with the contents of a database table is shown to the client. Now I want this table in the browser to be updated each time the db table is updated. In my business logic a jms message is fired to a specified topic each time the db table is updated. The reverse ajax stuff needed for the client update is provided by the Icefaces jsf implementation. There is a backing bean for each session which is responsible for the server side rerendering of the client. Now my question is: How do I connect the bussiness logic firing a jms message if the db table is updated, with the backing bean?
My thoughts:
1. Create a message listener for the topic. Each time the message listener receives a message it notifies the backing beans of each session to rerender the client. But how does the message listener know about the backing beans?
2. The backing bean responsible for rerendering the client adds itself as a listener. But where? As I understand it cannot be a backing bean and a jms MessageListener at the same time.
Has anyone an idea/pattern for this problem?

You could keep a list of beans that need to be notified in the application scope. (You should probably use weak references so that they may be garbage collected.) Then you JMS listener could get access to them.
Somebody posted a thread recently where they were doing something very similar, you might want to try to find it.

Similar Messages

  • Getting data from view object into backing bean

    Hi,
    My requirement is explained below -
         I have a ADF editable table in a jsf page which is connected to backend database table. In the table there are 6 columns and only 2 are editable. So when user inputs a value in first input column an event is triggered such that the data for all the remaining columns should be fetched from another database table.
    Typically if we are not using ADF development environment. We would have had a simple business method which creates the sql query by taking the input from textbox with simple where clause and I would have got the data. I am not getting any idea how to do this in ADF. I have the second table as view object but how to access the view object from backing bean and get data based on the input given.

    Hi,
    step 1) Expose a method on the ViewObject Impl class
    step 2) define arguments for the method as needed to identify the row to read data from
    step 3) retrieve the row from the VO that holds the data you want to add and return a HashMap with this information
    step 4) expose the method on the client interface (Java menu selection on the View Object)
    step 5) In the PageDef file, create a method binding to the method you exposed on the ViewObjectImpl
    step 6) Call the method binding from the managed bean like
    OperationBinding getDataFromVO = (OperationBinding) BindingContext.getCurrent().getCurrentBindingsEntry().get("Name of method binding);
    getDataFromVO.getParamsMap().put("name of arguments1", value1);
    getDataFromVO.getParamsMap().put("name of arguments2", value2);
    Object retData = getDataFromVO.execute();
    if(retData != null && getDataFromVO.getErrors().size()==0){
      HashMap retDataMap = (HashMap) retData;
    ... follow the rest of your logic ....
    Frank

  • Seprating Persistence logic from business logic

    Hi all !!
    I was thinking about that is there any known way or a possible way by which i can write a Entity Bean in which i can seprate the business logic and Persistence logic. Like what if i want to decide at the deployment type whether my Bean is gonna be BMP or CMP.Becuzz it may be possible that CMP may work fine with a particular container but does'nt work with some other vendor's container , so at the deployemnt time i can juzz switch it to BMP rather than CMP.
    Any comments?
    Thankzz

    Greetings,
    Hi all !!
    I was thinking about that is there any known way or a
    possible way by which i can write a Entity Bean in
    which i can seprate the business logic and Persistence
    logic. Like what if i want to decide at the deploymentYep! It's called a DAO (Data Access Object). Of course, this is only useful for BMP beans...
    type whether my Bean is gonna be BMP or CMP.Becuzz it
    may be possible that CMP may work fine with a
    particular container but does'nt work with some other
    vendor's container , so at the deployemnt time i can
    juzz switch it to BMP rather than CMP.
    Any comments?Absolutely. First implement your bean class for CMP, then extend from it to make a BMP version. Then during assembly/deployment select the version appropriate to the environment. You can increase your application's portability even further by encapsulating the persistence logic in a DAO which could then be accessed from a JavaBean in JSPs/servlets (or applications) directly. :)
    ThankzzRegards,
    Tony "Vee Schade" Cook

  • How to get selected items from a tree in backing bean without adfbc

    Hi ADF Experts,
    Below is my code for af:tree. My question is how can I get selected Items from the selectionListener (without adf bc) this uses formation of tree from backing bean.
    Using Jdev 11.1.1.7.0
    <af:tree var="node" value="#{pageFlowScope.MerchandizeBean.model}"
                      binding="#{pageFlowScope.MerchandizeBean.treeModel}"     id="tree" immediate="true" autoHeightRows="0"
                           styleClass="AFStretchWidth" rowSelection="multiple"
                           selectionListener="#{pageFlowScope.MerchandizeBean.treeNodeSelection}">
                    <f:facet name="nodeStamp">
                      <af:commandLink text="#{node.classDescription}"
                           actionListener="#{pageFlowScope.MerchandizeBean.createListManyItemForMerchandise}"           id="displayTable" partialSubmit="true">
                      </af:commandLink>
                    </f:facet>
                  </af:tree>
        public void treeNodeSelection(SelectionEvent selectionEvent) {
            // Add event code here...
            RichTree tree = (RichTree)selectionEvent.getSource();
                    TreeModel model = (TreeModel)tree.getValue();
                    //get selected value
    Thanks
    Roy

    Hi,
    in a multi select case, try
    RowKeySet rks = tree.getSelectedRowKeys();
    Iterator iter = rks.iterator();
    while(iterator.hasNext()){
    Object aKey = iterator.next();
    tree. setRowKey(aKey);
    Object rowData ? tree.getRowData();
      .... do something with the data here ...
    Frank

  • Separating presentation from business logic.

    I recently wrote an article on how to separate JSP presentation from the business logic without a complicated framework.
    http://labs.revision10.com/?p=16
    I haven't seen this exact approach taken before, but believe it works fairly well for most simple web applications. Applications which tend to attract many developers to PHP do to its simple architecture.
    What are your thoughts on this approach?
    Thanks!

    Here goes the answers to your question. (according to my knowledge)
    1. Deciding a server is depends on your design of the application. According to point 3, you are better to use JMS with publish and subscribe model. In this case you have to choose a JMS server that supports your needs
    2. Again it is depends on your Design, one way is to put a shared memory for data and write a thread that reads from the shared memory or use java.net package or use JMS etc.
    3. Create one JMS source and all other will be JMS destinations.
    4. You can use EJBs or Java classes based on your requirements and design to process the data.
    5. Using AWT or Swing as a presentatin layer is good. But you desperately want to display it using Win 32 objects, then why dont to go for Microsoft technologies??

  • How can fill javascript array from list in jsf backing bean

    Hello
    i have an array in javascript and i want to fill in from the list which is coming from the backing bean how can i do that.
    Regards

    Hi,
    using the ExtendedRenderkitService class you can send JavaScript calls from a managed bean to the client. So in your case you call a client side javaScript method and pass the array information as an argument. The way you pass the array data is up to you. You may just pass a character delimited list, or use JSON object notation in case the list shows objects. Note that this is for JDeveloper 11.In 10.1.3 there is no server side JavaScript API. Here you would have to add the JavaScript to the page when rendering it.
    Frank

  • Push messages from GETTER to the UI

    Hi,
    I would like to push some messages to the UI from the GET methods. I have new context node and i want to do my validations and push some messages from each attribute in the context node. How can i do that ?
    Thanks
    Aman

    Hello,
    This won't answer your question, but if you need to do some validations and push some messages accordingly, why don't you use method DO_PREPARE_OUTPUT or DO_VALIDATE_INPUT / DO_FINISH_INPUT of your controller class?
    Because I'm not sure the GET methods of the model class si the best place to put your coding in this case.
    Anyway, here is some example of how to throw messages to the UI:
    DATA: lv_msgsrv          TYPE REF TO cl_bsp_wd_message_service.
    lv_msgsrv = cl_bsp_wd_message_service=>get_instance( ).
    lv_msgsrv->add_message( iv_msg_type       = 'I'
                               iv_msg_id         = 'MESG'    "#EC NOTEXT
                               iv_msg_number     = '001' ).
    Hope this helps,
    Nicolas Busson.
    PS: sorry Masood, I was writting my answer while your were posting yours... and obviously yours is even better! thanks a lot.
    Edited by: Nicolas BUSSON on Nov 25, 2009 6:29 PM

  • Get selected row from af:table in backing bean

    Hi Experts,
    I have an af:table and i have seelctBoolean check box in that. If the user select 'x' nos of check boxes i want to display the row data of those selected rows. Can somebody help me in getting the selected row data in backing bean?
    I am using adf faces and backing bean.
    JSF Code:
    <af:table value="#{demo.partyList}" var="row"
    rowBandingInterval="0" binding="#{demo.t1}" id="t21"
    rowSelection="multiple">
    <af:column>
    <af:selectBooleanCheckbox text="#{row.person_first_name}"
    label="Label 1" id="sbc1"
    />
    </af:column>
    <af:column>
    <af:inputText value="#{row.emirate}"/>
    </af:column>
    </af:table>
    <af:commandButton action="#{demo.print}" text="Print"/>
    BB Code:
    public void print(){
    // what code to write here
    }

    This is the code
    JSF ::
    <af:table value="#{createOpportunity.dataList}" var="row"
    rowBandingInterval="0" binding="#{demo.t1}" id="t21">
    <af:column headerText="Model">
    <af:selectBooleanCheckbox text="#{row.modelRange}"
    label="Label 1" id="sbc1" value="#{row.selected}"/>
    </af:column>
    <af:column headerText="Description">
    <af:outputText value="#{row.description}"/>
    </af:column>
    <af:column>
    <af:inputText value="#{row.quantity}"/>
    </af:column>
    </af:table>
    <af:commandButton action="#{createOpportunity.print}" text="Print"/>
    Backing bean Code::
    public void print () {
    selectedDataList = new ArrayList<ModelDescription>();
    for (ModelDescription dataItem : dataList) {
    if (dataItem.isSelected()) {
    System.out.println(dataItem.getQuantity());
    selectedDataList.add(dataItem);
    // dataItem.setSelected(false); // Reset.
    Clicking on the print button shows "We have 0 rows selected"
    Thnks for ur replies guys ..
    Edited by: Wannabe Java Guru on Mar 9, 2011 1:43 AM

  • Raise an ERROR message from Script logic

    Hi All
    Here i have developed a custom copy funtion im not using standard copy functionality.
    I am trying to copy from working version to another version ex: V01 to V02. I have scoped these two versoins in script logic.
    But when user runs DM package for a different version other than v01 and v02 then user has to get the error message.
    Can i achive this by including some code in the script logic. i dont want to use the security options on user level.
    is there any function to raise error??
    Please suggest thanks in advance.
    Regards
    AK

    Hi AK,
    As I understood from your question, you want to copy always from V01 to V02. No other versions will be used other than these 2. So, it will be better to have them hardcoded in your script logic, instead of keeping error messages for the user. Anyways, you dont want the user to enter anything other than V01 and V02.
    Hope this helps.

  • I moved a lot of messages from different profiles into a new profile and obviously that did not work. Help.

    The messages i moved from different profiles show up in Thunderbird below folders I have set up. Here is an example:
    !%26!AAAAAAAAAAAYAAAAAAAAAEar6xxG3IpIp77Cdd9KJ%2FjCgAAAEAAAAMR3mYqi1U1OmSpmool4dwEBAAAAAA%3D%3D%40graphicadd.com.wdseml
    Can anyone understand what I have done and help me fix this problem? Thanks.

    see that wdseml part..... that means that they are files created for the sole purpose of allowing the ever so slightly intellectually disabled windows search to find emails. '''They are not emails'''. They do not contains any attachments!
    Emails are stored in files with the same name as the folder you had them in inside Thunderbird... so the inbox folder in Thunderbird will be the inbox file. To make it easier there is always an MSF file with it. So in this case inbox.msf.
    Using this add-on https://addons.mozilla.org/en-US/thunderbird/addon/importexporttools/ you can import these native MBOX files into your current version of Thunderbird.

  • Reconciliation: push updates from an OpenLDAP into OIM 11g

    Hello everyone ,
    Is there in the latest OIM a "push" connector that would allow a reconciliation process (ie inward flow into OIM) starting from an OpenLDAP directory system?
    Thanks,
    Nikos

    Yeah, you're right, unfortunately we have dual authorative password model, where a user can change the password from OIM when he is accessing a OIM through a web interface or from his Windows machine through the domain controller. We need the use case to work fully both ways ideally.
    A plan-B solution is to use a directory synchronization mechanism outside of OIM that would connect OID and AD, but we would prefer not to.

  • How do I install the modules from Business Catalyst into Dreamweaver?

    They have changed things around compared to Dreamweaver 6. I have my website on the B.C. website, but don't know how to add the modules on Dreamweaver.

    Thanks for the reply. I already have the add on installed. I've had it installed and using it for a few months now. The issue is, unlike the previous version before DW CC, I was able to install the modules on my computer and open them up in D.W. and was able to add the modules to my pages through D.W.
    I'll look at the link again and see if that is what it's showing me what to do.

  • Seperating presentation from 'business logic'

    I have a program for keeping track of games played and keeping a league table. However, I currently think the way I do the output of the league table using the toString() function shown later is a pretty poor way to do it. OK, let's be honest, it sucks!
    My idea is to have some sort of intermediate function which, say generates a structure with just the basic information and then have some other function which displays that info. The basic information might be in the format of an array (one row per player) where each row is a map ('name'->name info, 'grade'->grade info).
    But I dunno. I welcome your OO ideas for doing this nicely!
    Bear in mind I'm still fairly new to Java please ;-).
    Thanks.
    RANK LIST
    1. 1160 Alactaga (1160) (played 2)
    2. 1131 Brius (1131) (played 8)
    3. 1111 Chadi (1111) (played 3)
    4. 1073 Killer Giraffe (1073) (played 7)
    5. 1071 Fitzchev (1071) (played 6)
    6. 1053 Dragon (1053) (played 3)
    7. 1003 Marco d'Orange (1003) (played 2)
    8. 1000 HOrace (1000) (played 2)
    9. 1000 Coboi (1000) (played 0)
    10. 976 Mimick (976) (played 3)
    11. 950 Penestratus (950) (played 1)
    12. 947 Computer (947) (played 1)
    13. 944 Petit Gayole (also known as ETP Migrator) (944) (played 3)
    14. 919 Tartarus (919) (played 2)
    15. 918 Black Jack III (918) (played 6)
    16. 839 Heraldo (839) (played 4)
    17. 822 Aragorn (822) (played 5)And the code that generates it:
    * Created on 22-sept.-2003
    package core;
    // Java imports
    import java.util.*;
    * @author priorhu
    public class League extends Players {
         private static final int BASIC_SWING = 50;
          * Main routine for recalculating rankings based on a given game
          * Pour le rating, voici ce que je [Didier "Chadi" Charneux] propose,
          * c'est pas tr?s compliqu?.
          * La m?thode de calcul est la suivante :
          * 1/ calculer le ratio entre l'?quipe gagnante et l'?quipe perdante (ratio = points ?quipe perdante / points ?quipe gagnante).
          * 2/ multiplier ce ratio par lui-m?me pour que ce soit significatif (Ratio sig = ratio**2)
          * 3/ multiplier le r?sultat par 50 (points= ratio sig * 50)
          * 4/ ajouter les points aux gagnants et les retirer aux perdants
          * Exemple : Team A 2500 points, Team B 3000 Points
          * Team A gagne                    Team B gagne
          * 3000 / 2500 = 1,2                2500 / 3000 = 0,8
          * 1,2 * 1,2 = 1,44                     0,8 * 0,8 = 0,64
          * 50 * 1,44 = 72                     0,64 * 50 = 32
          * +72 points pour les gagnants      +32 points pour les gagnants
          * -72 points pour les perdants      -32 points pour les perdants
          * @param game
          * Created on 22-sept.-2003
         public void scoreGame(Game game) {
              Iterator playersIter;
              Team winningTeam = game.getWinningTeam();
              Team losingTeam = game.getLosingTeam();          
              double winnersGrade = winningTeam.getTotalGrade();
              double losersGrade = losingTeam.getTotalGrade();
              double swing;
              swing = losersGrade / winnersGrade;
              swing = swing * swing;
              swing = swing * BASIC_SWING;
              int roundSwing = (int) swing;
              System.out.println("Grading change: " + roundSwing
                   + " calculated as follows: "
                   + BASIC_SWING + " * (" + Math.round(losersGrade) + " / " + Math.round(winnersGrade) + ")**2");
              regradePlayers(winningTeam, roundSwing);
              regradePlayers(losingTeam, -roundSwing);
              System.out.println("");
          * Regrade each of the players in the given team
          * @param team
          * @param delta
          * Created on 06-nov.-2003
         protected void regradePlayers(Team team, int delta) {
              Set players = team.getPlayers();
              Iterator playersIter = players.iterator();
              while (playersIter.hasNext()) {
                   Player teamPlayer = (Player) playersIter.next();
                   Player leaguePlayer = this.getNamed(teamPlayer.getName());
                   int oldGrade = teamPlayer.getGrade();
                   int newGrade = oldGrade + delta;
                   // Before
                   System.out.print(leaguePlayer + " => ");
                   // After
                   leaguePlayer.setGrade(newGrade);
                   leaguePlayer.notePlayed();
                   System.out.println(leaguePlayer);
                   this.put(leaguePlayer.getName(), leaguePlayer);
          * Create a string version of the ranked list
         public String toString() {
              String rankListString = "";
              rankListString += "RANK LIST\n";
              rankListString += "---------\n";
              Collection players = this.values();
    //          System.out.println(players);
              Player[] playersArray = new Player[players.size()];
              Iterator playersIter = players.iterator();
              int playerNo = 0;
              while (playersIter.hasNext()) {
                   playersArray[playerNo++] = (Player) playersIter.next();
              Comparator rankComparator = new Comparator() {
                   public int compare(Object o1, Object o2) {
                        int comp;
                        Player p1 = (Player)o1;
                        Player p2 = (Player)o2;
                        if (p1.getGrade() < p2.getGrade()) {
                             comp = 1;     
                        else if (p1.getGrade() > p2.getGrade()) {
                             comp = -1;
                        else {
                             comp = 0;
                        return comp;
              Arrays.sort(playersArray, rankComparator);
              for (int pNum = 0; pNum < playersArray.length; pNum++) {
                   Player player = playersArray[pNum];
                   rankListString += (pNum + 1) + ". " + player.getGrade() + " " + player.toString() +  "\n";
              return rankListString;
    }

    Assuming you add an a method called something like getData() that returns a 2 dim array with each row being a players. Something like the following:
    import com.fdsapi.ArrayComparator;
    import com.fdsapi.FormattedDataSet;
    public class League extends Players {
      // I'll hardcode array.  I'm guessing at
      public Object[][] getData() {
        Object[][] players={
                                          {new Long(1160), "Alactaga", new Long(2)},
                                          {new Long(1111), "Chadi", new Long(3)},
                                          {new Long(1131), "Bitius", new Long(8)},
        return players;
      // Using the FormattedDataSet to sort the array and display the data. 
      public String getReport() {
         Object[][] players=getData();
         // sort by column 0 in descending order
         ArrayComparator.sort(players, 0, "desc");
          // The following declaritive syntax says to display all rows according to the last parameter.
          // ##rowNum - dynamically substitute the the current row.
          // ##colnum - displays the data for a column (indexed starting at 1)
         Template template = new Template();
         template.initialize("body_row_data",0,0,"##rowNum. ##1 ##2 (##1) (played ##3)");
          // This will return the same report you did in your code.
          FormattedDataSet fds=FormattedDataSet.createInstance();
          return fds.getFormattedDataSet(null, players, template);
    }Note the FormattedDataSet is much more powerful than this. Out of the box it can do html tables, xml, drop down listboxes, lisboxes, radio buttons and more. Plus you can easily create your own templates like the above.
    For a live demo and to download check out: http://www.fdsapi.com

  • How to get specific rows from the vo or Iterator in the backing bean?

    Hi,
    I have to get the specific number of rows from iterator in the backing bean. means i want to get the records from the VO or Iterator only from 5 th record to 10th record its like rownum in SQL.
    We can use rownum in VO sql query. but there would be a performance issue with that ...
    SO i am trying to get the rows from ADF Iterator once we fetch from DB.
    Is it possible to do that ?
    Do we have any way to set the pointer to the VO/Iterator like setFirst() and after that setMaxResult to retrun the rows between first and maxresult..
    Thanks

    If this is for pagination, then af:table offers pagination by design when you set accessmode=RangePaging or RangePagingIncremental in VO. Paginated queries are fired when scroll down in the table. Explore this option before you try out any custom solution
    To answer the question,
    Note: same logic i have implpemented ADF with EJB ..In EJB Query class we have setFirst(int) and setMaxResult(int) methods...simply i did setFirst(30) and setMaxResult(10)..It worked fine...Theoretically speaking the same can be achieved by setting setRangeStart() on the viewobject(which in turn sets to the default rowset) and by setting max fetch size on VO + accessmode=RangePaging. However when you use table with ADF binding, these will be overridden by the binding layer. If you are not using ADF binding, then the above is same as what you did for JPA entity. Other option is, you build expert mode VO with rownum for this special case, which will work if you dont need to set accessmode=RangePaging for VO.

  • Mail is moving old messages from folders into the inbox

    Hey,
    Mail has started behaving really weird. It has started to move old messages, from various folders into the inbox. When i try to move it back, i have to use the contextual menu to do that, drag and drop doesn't work.
    Has anyone experienced this before? Help is greatly appriciated!
    /Andreas

    Hi Andreas.
    Verify/repair the startup disk (not just permissions), as described here:
    The Repair functions of Disk Utility: what's it all about?
    After having fixed all the filesystem issues, if any, and ensuring that there’s enough space available on the startup disk (a few GB, plus the space needed to make a backup copy of the Mail folder), proceed as follows to re-create Mail’s index:
    1. Quit Mail if it’s running.
    2. In the Finder, go to ~/Library/Mail/. Make a backup copy of this folder, just in case something goes wrong, e.g. by dragging it to the Desktop while holding the Option (Alt) key down. This is where all your mail is locally stored.
    3. Locate Envelope Index and move it to the Trash. If you see any other “Envelope Index”-named file there, delete it as well.
    4. Move any “IMAP-”, “Mac-”, or “Exchange-” account folders to the Trash. Note that you can do this with IMAP-type accounts because they store mail on the server and Mail can easily re-create them. DON’T trash any “POP-” account folders, as that would cause all the mail stored there to be lost.
    5. Open Mail. It will tell you that your mail needs to be “imported”. Click Continue and Mail will proceed to re-create Envelope Index — Mail says it’s “importing”, but it just re-creates the index if the mailboxes are already in Mail 2.x format.
    6. As a side effect of having removed the IMAP account folders, those accounts may be in an “offline” state now. Do Mailbox > Go Online to bring them back online.
    Note: For those not familiarized with the ~/ notation, it refers to the user’s home folder. That is, ~/Library is the Library folder within the user’s home folder, i.e. /Users/username/Library.

Maybe you are looking for

  • Samsung Note 3 front camera quality on video call

    i love skype on my samsung galaxy note 2 the sound and video quality is good,,,,but not on note 3...i only get black and white video quality and get a lot of dropped call...skype,please fix this issue...

  • Handling checkboxes in ALV Grid.

    Hi  guys. I have displayed an ALV grid with checkboxes. I want to opearate on the selected checkboxes by the user by clicking on a added button. I am using oops and using function set_table_for_first_display. if no box is selected the function works

  • This is Urgent!

    Hi I am Joel Pérez ( http://otn.oracle.com/experts ) , I have problem to login with my account. I request my username and password and the system was able to send me it to my e-mail but in spite of that the username and password are correct the syste

  • Help with date calculation

    Hi, I have a requirement something like this. Iam trying to figure it out how can I do with simple sql statement. I have start dates for each row. I need to update the end_date column for each row using the value (next row start date-1). But Iam havi

  • Looking for test demo of new 21/27 iMac in-house in Carmel, IN

    Hi all. I am looking for someone that might be willing to let my parents see and use their 21"/27" iMac at there house for a little while. They absolutely DETEST the new glossy screens, at least how they look when they are the store. But their house