Forums Register Login

Included JSP always at top of the page

+Pie Number of slices to send: Send
Good night!

I have a problem including a jsp inside another jsp. I have a jsp with some fields and i'm trying to include it inside another one using ajax.
This is the code of my main jsp:


When the "jobId" select changes, the "jspToChange" is updated with the following function:



The problem is that when the "jobId" select changes, the included jsp displays at the top of the page and not in the position where the "jspToChange" div is.

I hope that you understand my question.
Thanks in advance for your help.






+Pie Number of slices to send: Send
What are you returning as the response? A full HTML page? If so, don't. It should just be a fragment.

Also, why a POST?
+Pie Number of slices to send: Send
Hi Bear!

Thank you for your response. What I'm returning is a JSP which has some textfields. I've used that function before and it worked; however, the difference was that i used a table to separate all the elements. For example:



Then, when i called the ajax function the jsp was updated where the div tag ("jspToChange") was and everything was perfect. However, now that i'm not using this table, when i call the ajax function, the jsp always appears at the top of the page and not where the div is (after the "select"). The thing is that i think that using this table is not good at all because i should use css instead. What i tried was using css and setting the "jspTochange" position to absolute, but it didn work.

Any suggestions?
Thanks.

+Pie Number of slices to send: Send
I want to show you my problem to see if you can help me.

What i have is this:



The red square is the jsp that i need to update, and the blue one is my main jsp (it has a menu, a submenu and some images). If I use a table to separate the elements, when the select value changes this is what happens:



As you can see, it is updated correctly. But, as I said before, I think that using a table is not correct. Then, if I don use a table i get this:



As you can see, whitout the table, it doesn't update the JSP in the correct way. Is there a different method to do this?
Thanks in advance.
+Pie Number of slices to send: Send
Use the debugger in the browser to inspect the DOM. It will show you where the elements actually are in the structure. When not using the table, what do you return?
+Pie Number of slices to send: Send
Hi bear!

I used the debugger and i noticed that when the "select" changes, a new table with the updated elements is created, and it's placed at the top, not inside the div tag. But, if I use the table, when the "select" changes, the new table with the updated elements is placed inside the div tag. I return the same JSP in both cases, the only difference is that I use the table to separate the elements in the example that works correctly. The thing is that i don't like using this table, i'd prefer to solve my problem using css.

Is there a way to do what I want without using this table?
Thanks in advance!
+Pie Number of slices to send: Send
 

Bear Bibeault wrote:When not using the table, what do you return?

 
+Pie Number of slices to send: Send
Perhaps I'm missing something, but what I see is this:

You start with a div whose id is "jspToChange". Then you execute an AJAX request which replaces that div with something else -- maybe a table, maybe something which isn't a table but we don't know what it is. But at any rate now you don't have anything in your DOM whose id is "jspToChange", so the next time you execute that AJAX request its result would be put into some default location. That could be at the start of the page, I suppose, I don't remember what happens when you use a nonexistent id value there.
+Pie Number of slices to send: Send
Hi Bear!

In both cases a return a JSP which is like this:



It has some other textfields, but in both cases it's the same JSP. The problem seems to be in the main JSP.
Thanks!
+Pie Number of slices to send: Send
 

Paul Clapham wrote:Perhaps I'm missing something, but what I see is this:

You start with a div whose id is "jspToChange". Then you execute an AJAX request which replaces that div with something else -- maybe a table, maybe something which isn't a table but we don't know what it is. But at any rate now you don't have anything in your DOM whose id is "jspToChange", so the next time you execute that AJAX request its result would be put into some default location. That could be at the start of the page, I suppose, I don't remember what happens when you use a nonexistent id value there.



Yes, you are right. Actually, it puts the result JSP inside a table ("wwformtable"). What i don't understand is why if I use a table to separate the elements in the main JSP it works correctly?
Thanks!
+Pie Number of slices to send: Send
 

Richard Le wrote:Hi Bear!

In both cases a return a JSP which is like this:




The JSP gets returned unprocessed? Or is that actually not what's being returned?
+Pie Number of slices to send: Send
These are the details of what I'm returning:

First, the ajax request:



And this is part of my struts configuration file. As you can see, what I do in the ajax request is to call this action to update the JSP that is inside the "jspToChange" div.



Thanks!
+Pie Number of slices to send: Send
 

Paul Clapham wrote:Perhaps I'm missing something, but what I see is this:

You start with a div whose id is "jspToChange". Then you execute an AJAX request which replaces that div with something else -- maybe a table, maybe something which isn't a table but we don't know what it is. But at any rate now you don't have anything in your DOM whose id is "jspToChange", so the next time you execute that AJAX request its result would be put into some default location. That could be at the start of the page, I suppose, I don't remember what happens when you use a nonexistent id value there.



The html(<some html>) JQuery method replaces the html content of the matched element(s), not the matched element itself.
Here's the api page.
If you try to please everybody, your progress is limited by the noisiest fool. And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 981 times.
Similar Threads
Refresh jsp inside another jsp using ajax
change event is firing twice
Data Tables(TableTools) - Export to CSV and PDF is not working jQuery Javascript
jQuery datepicker JSP question
502 Bad Gateway error during process
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 07:51:20.