I am using display tag to display a table of records that is opened inside a dialog, but when i click on pagination link , it redirect to anothe page and hide dialog
I need to keep pagination in the same dialog
Thank's in advance.
I would suggest you use a iframe in the dialog box and within the iframe you use the displaytag.
JSP with dialog:
<sj:dialog>
<iframe src="path/to/actionwithdisplaytable.action" with="" height="">
</iframe>
</sj:dialog>
JSP with displaytag:
<displaytag:...>
<displaytag:column/>
</displaytag:...>
Thank you for your response, the problem is fixed by adding the requestURI, containg the name of myAction.
Related
This link helped me to perform autocompleter in struts2. Through this tag i could
A> Show list form database
B> Insert value in database which were not in list
All worked fined..
But, now i have to use struts2-jquery plugin to show that page containing *dojo tag* in a pop-up window. On doing so, the pop up window just appears, and the page is redirected to the form's action. This problem was solved when i removed the dojo tag-sx from the head of that page.
Now the pop up is shown, but i can't insert value which are not in my list. i.e i can't perform the second option mentioned(B)
I've checked this showcase, but struts2-jquery autocompleter tag also couldn't fulfill my second option(B) as it adds an _widget in it's name field
How can i fulfill both option in my case? Thanks in advance
If you mean submit any value that was not originally in the autocompleter list then <sj:autocompleter> tag has forceValidOption attribute for that. See this issue for more information http://code.google.com/p/struts2-jquery/issues/detail?id=587.
I am currently building a website containing lots of links to different sections of my website (also known as navigation). Lets call those links and their corresponding pages link1, page1 , link2, page2, link3, page3 etc.
The general code for them is this:
Link1
Link2
Link3
I want the user to click each link to move to the corresponding webpage and it works as supposed to. The problem is that I want the links to do nothing when the user is on the same page as the link they clicked (meaning it will only reload the page). Let me make this clear by using an example:
Current use: User is on page1. User clicks on link1. The browser will reload page1.
Desired use: User is on page1. User clicks on link1. The browser will do nothing.
TL;DR Essentially I am searching for an if clause. I have read there is no if clause in HTML simply because it's a markup language but what is another way to implement this? Thanks for your help.
The best answer I have found without the need to use JQuery or JS after munching through SO is this, answer made by Matt Crinklaw-Vogt:
Add a /#!. This will prevent the scrolling to the top and will also prevent the page reloading.
Code:
Link1
Original answer:
How do I stop a web page from scrolling to the top when a link is clicked that triggers JavaScript?
I'm not sure I like it, but you could use an empty bookmark to do this...
Link1
If you aren't on page1, it will load page1, but once you are there, it won't do anything.
Link2
OR
<a onclick = "return false;">Link2</a>
That cancels out the load.
On page load, you could use JS as follows
Link1
JS:
document.getElementById("link1").setAttribute("href", "#");
You can use javascript to compare the current url to the anchor link, and if they're the same, prevent the default click event. Using jquery:
var url = window.location.pathname,
urlRegExp = new RegExp(url.replace(/\/$/,'') + "$");
$('a').each(function(){
if(urlRegExp.test(this.href.replace(/\/$/,''))) {
$(this).click(function(event) {
event.preventDefault();
});
}
});
I have a html which has some textboxes and a list. I then added paging for my list but whenever I try to click on the next page for list, it reloads the entire page which then results to an error because the page requires an id that becomes null when the paging is cliked. How do I resolve this? I'm using MVC and razor(cshtml).
provide required id in url so that you can get it on other page
for eg.
http:://localhost/abc.html?id=xyz
How can I set into a script tag that a jquery mobile page, must have a behaviour like a dialog beside add to the main div data-role = dialog ?
You can add the data-rel='dialog' attribute in the script using id like
$('#linkToPage2').attr('data-rel','dialog');
Here are the examples
http://jsfiddle.net/q4jrY/6/ and http://jsfiddle.net/reddyprasad321/q4jrY/5/
I have MVC 1.0 app on VS2008.
I have webpage that has a search form fields and then when search button clicked uses
Ajax.BeginForm to load results in a div. Works great!
But the results have a pager that just uses an anchor with href passing in page index to controller action.
Of course the same action that is used when the search button is clicked.
So what happens is the results are displayed in new page by themselves. Because the links
are not called using Ajax.
So how can I structure my views and actions so that when a link is clicked in the pager
that the form is submitted to the action as well as the page index for the results??
Do you understand me??
Malcolm
I think I understand what you are saying.
Currently, you're using Ajax to dynamically update your results to a div. Kewl.
The trick here is to make sure each 'page' in the pager has a similar javascript function defined on the onclick event. This way, the pager doesn't do a 'postback' to the server, but the javascript method is ran ... which calls some ajax.
here's some sample html...
<a href="#" onclick="DoPagedSearch(1)>1</a> |
<a href="#" onclick="DoPagedSearch(2)>2</a> .. etc
does this make sence? make sure the pager is NOT inside a form AND notice the '#' characters? that makes sure that when u click on the text, it doesn't try and goto another HTML page, elsewhere.
Do you know how to wire up any javascript to an html element? How do u create the html code for the pager?
try that and keep us posted.
Use jquery to have the page anchors make an ajax call to the controller. Return the results as JSON or xhtml or whatever format makes you feel happy and use that to replace the content of the div, or build up and replace the contents if JSON.
If you haven't dug into jquery, I highly recommend it. The documentation is rather excellent. Let me provide you a few useful links for this:
JSON.net serializer
jQuery Documentation
fair example of using jquery for paging
The example uses an rss feed (xml) as the source, but It should get you going.