JSP page to immediately display whenever a new row is added in table?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

JSP page to immediately display whenever a new row is added in table?

MANISH SHARMA

Hi all,

  Can i solve following problem using reverse ajax?


I have oracle dbTable letssay testDbTable having column columnA and columnB.Whenever a new row is added in database table,it should display content of that row on JSP page in following manner.

columnA(value):----- and then columnB(value):........

lestsay after some time a new row is added in testDbTable. then output should be in two line. Added new row in testDbTable should be aove on previous row that was displayed earlier on JSP page.

columnA(value):----- and then columnB(value):........ columnA(value):----- and then columnB(value):........

But such action should be at same time whenever a new row is added.

The simplest way i could think of that check on database again and again for some predefined lenth of time,but this solution seems to be wasteful and suboptimal to me, so i was wondering is there a better way.

i think there should be a trigger on table,when a new row is added in db then trigger should be fired and display row content on JSP page. I know "how to create trigger on table" but after that i am blank,how will i display just added row on JSP. After trigger on db table how will i approach? Can Ajax solve my problem like auto refresh or watch on db table or sothing else? is there anyway i can listen to a trigger on my database from a .jsp script and force my client page to be refreshed ? Can you provide me any example link related to ajax,oracle dbtriggers and JSP?


If you have any working example like this,please mail me..Please show me direction

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: JSP page to immediately display whenever a new row is added in table?

david@butterdev.com
Reverse AJAX in combination with valid Java code can solve this problem
for you.  However, most of your problem is unrelated to DWR.  First you
need to determine how you are going to write your Java code to be
notified when triggers fire.  Once you have that working you can look at
our reverse AJAX examples in the dwr.war to get an idea of how you can
push these updates to the browser.

On 5/3/2011 5:16 AM, MANISH SHARMA wrote:

>
> Hi all,
>
>   Can i solve following problem using reverse ajax?
>
>
> I have oracle dbTable letssay testDbTable having column columnA and
> columnB.Whenever a new row is added in database table,it should
> display content of that row on JSP page in following manner.
>
> columnA(value):----- and then columnB(value):........
>
> lestsay after some time a new row is added in testDbTable. then output
> should be in two line. Added new row in testDbTable should be aove on
> previous row that was displayed earlier on JSP page.
>
> columnA(value):----- and then columnB(value):........
> columnA(value):----- and then columnB(value):........
>
> But such action should be at same time whenever a new row is added.
>
> The simplest way i could think of that check on database again and
> again for some predefined lenth of time,but this solution seems to be
> wasteful and suboptimal to me, so i was wondering is there a better way.
>
> i think there should be a trigger on table,when a new row is added in
> db then trigger should be fired and display row content on JSP page. I
> know "how to create trigger on table" but after that i am blank,how
> will i display just added row on JSP. After trigger on db table how
> will i approach? Can Ajax solve my problem like auto refresh or watch
> on db table or sothing else? is there anyway i can listen to a trigger
> on my database from a .jsp script and force my client page to be
> refreshed ? Can you provide me any example link related to ajax,oracle
> dbtriggers and JSP?
>
>
> If you have any working example like this,please mail me..Please show
> me direction
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: JSP page to immediately display whenever a new row is added in table?

MANISH SHARMA
Hi All,
         Any other approach without using triggers...?As trigger will fired or database server and reverse ajax code will run on application server.......So please tell me approach.
try to be more clear, i'm in lack of ideas in this problem, even it sounds like a classic :I have spend hours trying to play around with this but have got nowhere.
Your help is much appreciated

On Wed, May 4, 2011 at 5:53 AM, David Marginian <[hidden email]> wrote:
Reverse AJAX in combination with valid Java code can solve this problem for you.  However, most of your problem is unrelated to DWR.  First you need to determine how you are going to write your Java code to be notified when triggers fire.  Once you have that working you can look at our reverse AJAX examples in the dwr.war to get an idea of how you can push these updates to the browser.


On 5/3/2011 5:16 AM, MANISH SHARMA wrote:

Hi all,

 Can i solve following problem using reverse ajax?


I have oracle dbTable letssay testDbTable having column columnA and columnB.Whenever a new row is added in database table,it should display content of that row on JSP page in following manner.

columnA(value):----- and then columnB(value):........

lestsay after some time a new row is added in testDbTable. then output should be in two line. Added new row in testDbTable should be aove on previous row that was displayed earlier on JSP page.

columnA(value):----- and then columnB(value):........ columnA(value):----- and then columnB(value):........

But such action should be at same time whenever a new row is added.

The simplest way i could think of that check on database again and again for some predefined lenth of time,but this solution seems to be wasteful and suboptimal to me, so i was wondering is there a better way.

i think there should be a trigger on table,when a new row is added in db then trigger should be fired and display row content on JSP page. I know "how to create trigger on table" but after that i am blank,how will i display just added row on JSP. After trigger on db table how will i approach? Can Ajax solve my problem like auto refresh or watch on db table or sothing else? is there anyway i can listen to a trigger on my database from a .jsp script and force my client page to be refreshed ? Can you provide me any example link related to ajax,oracle dbtriggers and JSP?


If you have any working example like this,please mail me..Please show me direction



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: JSP page to immediately display whenever a new row is added in table?

Matt Conroy
Hi,

First off, this is not really a DWR question, but I will attempt to give some guidance by asking a couple of questions regarding the info below.

1. You say that you know how to write the database table trigger. Does this mean that you know how you are going to tell the java code that something changed in the database?

2. You would like to know how to add a row when the database table has a new committed row. This is an excellent use of reverse ajax and can be easily done with straight dom manipulation using javascript, the built in dwr utilities, or using  another addon javascript framework like jQuery or prototype. What method would you prefer to use? Do you have any restrictions?

Just taking a shot in the dark since I don't know your exact environment... You could have the database trigger fire a call to a servlet each time a row is committed which would then run some code that looked like the following:


Get the script sessions that are active for the page that we want to update. This eliminates the need to check every reverse ajax script session that is running on the site. Once we have the script sessions we can use the second code block to take some data and update a table on the client side. All that the second code section does is send javascript to the client to be executed via the reverse ajax connection that is open.
  String page = ServerContextFactory.get().getContextPath() + "/reverseajax/clock.html";
        Browser.withPage(page, new Runnable() {
            public void run() {
                Util.setValue("clockDisplay", output);
            }
        });


		  // Creates a new Person bean.
                Person person = new Person(true);
                // Creates a multi-dimensional array, containing a row and the rows column data.
                String[][] data = {
                    {person.getId(), person.getName(), person.getAddress(), person.getAge()+"", person.isSuperhero()+""}
                };
                // Call DWR's util which adds rows into a table.  peopleTable is the id of the tbody and 
                // data contains the row/column data.  
                Util.addRows("peopleTable", data);
Note that both of the above sections of code are pulled straight from the documentation examples @ http://directwebremoting.org/dwr-demo/. These are only simple examples of how reverse ajax can sent data to the client, but your exact situation seems to be more dependent on how you receive the notification than how you update the client screen.

Without some type of database notification to the java code I think you will have to poll the system at set intervals. You could make the system a little more efficient even when polling by verifying that there are reverse ajax script sessions active for the page before polling the database for info.

Just thoughts. Hope they help.

- Matt -


On 5/3/2011 9:55 PM, MANISH SHARMA wrote:
Hi All,
         Any other approach without using triggers...?As trigger will fired or database server and reverse ajax code will run on application server.......So please tell me approach.
try to be more clear, i'm in lack of ideas in this problem, even it sounds like a classic :I have spend hours trying to play around with this but have got nowhere.
Your help is much appreciated

On Wed, May 4, 2011 at 5:53 AM, David Marginian <[hidden email]> wrote:
Reverse AJAX in combination with valid Java code can solve this problem for you.  However, most of your problem is unrelated to DWR.  First you need to determine how you are going to write your Java code to be notified when triggers fire.  Once you have that working you can look at our reverse AJAX examples in the dwr.war to get an idea of how you can push these updates to the browser.


On 5/3/2011 5:16 AM, MANISH SHARMA wrote:

Hi all,

 Can i solve following problem using reverse ajax?


I have oracle dbTable letssay testDbTable having column columnA and columnB.Whenever a new row is added in database table,it should display content of that row on JSP page in following manner.

columnA(value):----- and then columnB(value):........

lestsay after some time a new row is added in testDbTable. then output should be in two line. Added new row in testDbTable should be aove on previous row that was displayed earlier on JSP page.

columnA(value):----- and then columnB(value):........ columnA(value):----- and then columnB(value):........

But such action should be at same time whenever a new row is added.

The simplest way i could think of that check on database again and again for some predefined lenth of time,but this solution seems to be wasteful and suboptimal to me, so i was wondering is there a better way.

i think there should be a trigger on table,when a new row is added in db then trigger should be fired and display row content on JSP page. I know "how to create trigger on table" but after that i am blank,how will i display just added row on JSP. After trigger on db table how will i approach? Can Ajax solve my problem like auto refresh or watch on db table or sothing else? is there anyway i can listen to a trigger on my database from a .jsp script and force my client page to be refreshed ? Can you provide me any example link related to ajax,oracle dbtriggers and JSP?


If you have any working example like this,please mail me..Please show me direction



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: JSP page to immediately display whenever a new row is added in table?

Section8
>>>Get the script sessions that are active for the page that we want to update. This eliminates the need to check every reverse ajax script session that is running on the site. Once we have the script sessions we can use the second code block to take some data and update a table on the client side. All that the second code section does is send javascript to the client to be executed via the reverse ajax connection that is open.

I am Currently having a similar problem when using DWR server Push.I have tries to implement a solutions as suggested above.But in my case I need to pass a java collection back to the GUI.(E.g. List<Instrument>).

When you try to alter this functionality to support other data types such List<Instrument> I couldn't find a Clean method.

Is there a better method that could be devised to transfer objects when using server push using this method ? (Resorting to String conversion :(  seemed to be the method suggested in most of the web examples.)

Does DWR provide a JSON based approach that may facilitate easy Object or Collection based data transfers for server side push? If a JSON based data transfer is possible for server side Push, could you please give some heads up on some document, site or sample code that may be of any assistance.Any such lead would be much appreciated for I have found nothing concrete on this topic :(
Loading...