I am using Struts here...referring "Action class" of struts..

Yes, when user saves the page it is inserted successfully in the
database. Data is then displayed on the same page...Now, user clicks
on refresh I need to fire an event to bring the data and render HTML.
Since I manipulated DOM, I won't have new id available in page
source.

Here is the sequence:
1) User types in browser http://server.com/page.do?dispatch=add - for
add operation
2) User will add the data and click on Save
3) Data is saved successfully. Here, I am trying to forward request to
"edit" action which will show another page so, I can show latest data
anytime on refresh event. I am able to forward the event successfully
but another page is not loaded. I think, because yest $.ajax() call is
not yet completed ?? I want to change URL in browser something like
http://server.com/page.do?dispatch=edit&pageid=123 - once data is
saved.

Following is my code. Let me know if you can suggest on this or if you
have any further questions:


          $('#savepage').click(function(e) {

                          $.blockUI({ message: "<h1>Page:Please wait...</h1>" 
});

                  $.ajax({
                      url: '/savePage.do?dispatch=save',
                      type:'POST',
                      dataType:'json',
                      data:{pageid:$("#pageid").val(),pagename:$
("#pagename").val()},
                      cache: false,
                      success:function(json){
                                  // here I can manipulate DOM and
show the inserted data
                          //$.get('/editPage.htm?dispatch=edit&pageid=' +
json.pageid);
                      },
                      complete: function(){
                          $("#pageid").val("");
                          $("#pagename").val("");
                          $.unblockUI();
                      },
                      error: function (error) {
                          alert("error:" + error);
                      }
                  });
                  return false;
              });

Thanks,
Bhavin

On Nov 25, 12:00 pm, "Jeffrey Kretz" <[EMAIL PROTECTED]> wrote:
> Unfortunately, I'm not familiar with "Action class"  Is this a JSP thing?
>
> When the user saves the new page with an ajax call, is it recorded in a
> database?
>
> If so, when the user then refreshes, shouldn't the server output the new
> page nodes correctly during the HTML render?
>
> JK
>
>
>
> -----Original Message-----
> From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
>
> Behalf Of Bhavin
> Sent: Tuesday, November 25, 2008 11:53 AM
> To: jQuery (English)
> Subject: [jQuery] Re: dynamic tree / treeview
>
> Thanks Jeffrey. I solved issue# 1 almost similar way you suggested.
> But I am more concern about issue # 2. I am not sure about the flow. I
> want something like:
>
> 1) Click on Create Page link. I want to allow users to create data
> which will be internally displayed in <ul><li> elements and user can
> drag&drop and save the sequence.
> 2) Open dialog, enter data & Save. Here I am using $.ajax(). Bringing
> data from Action class in JSON datatype.
> 3) I will get data in success of $.ajax(). I can manipulate DOM,
> insert <ul><li> elements with data and similar way I can create child,
> subchild of the nodes.
>
> The problem here is: When I create children dynamically, I want to
> make sure if user clicks on "Refresh" button then also data should be
> retained on the page. In above case, it is not retaining because I am
> not sure how to go ahead with that. Should I capture "Refresh" event,
> fire event to the Action class, bring the data and show it on the
> page? Or is there any other alternative? How can I make sure that
> whatever data I am showing on the page is updated one and latest?
>
> Please advice.
>
> Thanks,
> Bhavin
>
> On Nov 22, 3:29 pm, "Jeffrey Kretz" <[EMAIL PROTECTED]> wrote:
> > I'm not 100% I understood your question, but I'll give it a shot.
>
> > I have a dynamically rendered TreeView that is showing a page hierarchy,
> > parent and child.
>
> > There is an option to add/remove pages, as well as drag them around.
>
> > Because I need the id of the page and its parent, I render it in the HTML
> as
> > an attribute.
>
> > <li _pageid="132">
> >   PageName1
> >   <ul>
> >     <li _pageid="543">PageName2</li>
> >     <li _pageid="565">PageName3</li>
> >   </ul>
> > </li>
>
> > Database updates are handled as such:
>
> > var li = $(this);
> > var pageid = parseInt(li.attr('_pageid'));
> > var parentid = parseInt(li.parents('li:first').attr('_pageid'));
>
> > If I have a new set of child pages to render after an ajax call:
>
> > var li =tree.find('li[_pageid='+pageid+']');
> > if (li.length)
> > {
> >   var ul = li.children('ul');
> >   if (!ul.length)
> >     ul = $('<ul></ul>').appendTo(li);
> >   ul.html(newchildnodes);
>
> > }
>
> > Does this help?
>
> > JK
>
> > -----Original Message-----
> > From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
>
> > Behalf Of Bhavin
> > Sent: Saturday, November 22, 2008 2:48 PM
> > To: jQuery (English)
> > Subject: [jQuery] Re:dynamictree/ treeview
>
> > Anybody can guide me on this?
>
> > On Nov 21, 12:55 am, Bhavin <[EMAIL PROTECTED]> wrote:
> > > Hi
>
> > > I am using jquery to createtreestructure type of functionality
> > > dynamically. I have to add nodes by opening dialog and save it into
> > > the database. Once response is returned then I need to show it on the
> > > page. I have few doubts here:
>
> > > 1) Once node is inserted into the database and response is rendered on
> > > the page then how can I fetch id/value of the node. Here, DOM
> > > shouldn't be updated automatically? I am not able to fetch parent node
> > > id while adding child into it.
>
> > > 2) Once data is rendered on the page and if I refresh it then how
> > > should I show thetreewhich was already created dynamically? Do I
> > > need to bring all the data from the database by passing parentid?
>
> > > Please guide.
>
> > > Thanks,
> > > Bhavin- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

Reply via email to