I want to create a jsp page that dynamically remove and add form input like in the picture.
when i click add the form will add new form but if click minus sign the form will be removed.
I don't know how to do it, since i am poor on javascript and jquery. can you help me ?
Related
I have a JavaScript code embedded in a Java method to retrieve properties of any element clicked upon in a web page.
That is, I navigate to a specific URL by creating an instance of Selenium WebDriver from my Java application and click on an object in the page that gets loaded. After the single click on the object, a HTML page opens listing the name, type, id, class name etc. associated to that object as a radio button group. I select one option from the list and click on OK. What I wanted to know is, can I push the selected data from the HTML back onto my Java application on the click event on the HTML?
Any help appreciated! Thanks! :)
WebElement interface of selenium Webdriver gives a method
getAttribute which provides value of a given attribute of the desired html element.
I hope this method is what you are looking for.
USAGE:
String field_value;
field_value = driver.findElement(By.xpath("xpath Locator")).getAttribute("attribute name")
The information which you want to get should be in any of the attribute associated to that element.
Similarly if you want all attributes associated with the element in one go you can use something like this :
((JavascriptExecutor)driver).executeScript("return arguments[0].attributes);", element);
The above will give you a comma separated list of all attributes on which you can apply your coding logic to separate them and get the corresponding values using loops.
I have a JSP page which contains a Form and also a Table .When i click on print button only table should be get printed .please help me out.
One of the way to achieve this to open another tab which will only contain that table you want to print. Then on document.load of that pop-up call the JavaScript function window.print()
This will open print window from there you can print the contents of pop-up.
You can use the window event of javascript just call this event when you press the button
window.print();
In my project(working on Spring and hibernate) i need to keep around 22 HTML dropdown for a form, each dropdown have around 30,000+ entries every dropdown fetching data from database because of this page loading getting delayed (40+ sec) now i wanted to replace dropdown to similar function one, now i thought to keep autocomplete text box, now i wanted to know major performance issues in HTML Dropdown and autocomplete textbox or any suggestion or any alternative for this Thanks in advance.
I think use of autocomplete text box is more beneficial than dropdown.
In case of dropdown, data is loaded at once so it get delayed.
In this case only one request is made to database.
In case of autocomplete text box,data will load in exactly required text box.
So loading time for jsp reduces sharply.
(a) For autocomplete text box,there is no need of using any kind of plugin, as one can manage it easily.
(b) Use simple json format for providing input to text box using ajax.
(c) Define condition on text box for firing ajax request for showing text like..
want to get text after typing 3 characters etc...
You can also use jquery chosen plugin.
You can have normal select box with the jquery chosen plugin applied to that particular select box.
Refer http://davidwalsh.name/jquery-chosen
In form I use PageableListView to iterate TextFields. But when I submit form it only validate current page of PageableListView. Also when I back to eg. Page 1 all values I filled disappear.
When I change PageableListView to standard ListView all works fine – validation and submitting.
I set in ListView: setReuseItems(true).
How validate all items in PageableListView?
You can only validate items that are in the form, on the screen. If you wish to validate stuff on the first page, I think you need a (ajax)FormSubmittingBehavior on the paging controls, so your form is submitted each time you navigate to another page.
If you submit the data, it will also be stored if there are no validation errors.
In my ApplicationResource.properties file, I can things like "welcome.message="Welcome""
and I would generate that in my jsp page with...
<h3><bean:message key="welcome.message"/></h3>
But say for example, I have a lot of html to generate, such as a list and list items for that secion...
How would I do that?
Nothing to stop you from giving the entire HTML code in the property file. For example if you want the text to appear bold you can do <B>Bold Text</B> So for your select box you can put the entire set of HTML tags in a property and set it where you want to set it.
As for dynamic content you can get a list of your objects in the action class and then use the struts UI tags to create the list or whatever you want.