I am working on struts framework in java and I have a jsp which has a select box. Onchange of this select box I am displaying some values in a second select box. The first select box is displaying the Hindi characters properly. I select some value and the onchange function is called and it goes to ajax and gets the values in second select box. THe second select box is displaying question marks.The follwing is the jsp code
District(ज़िला)
Municipality(नगर)
<html:select property="municipalitycode" bundle="utf-8"
styleId="mun_List" style="width:180px;"
onchange="getzones('myajax.do?action=getzones',this);getsections('myajax.do?action=getsections',this);">
<html:option value="">Select</html:option>
<html:optionsCollection property="municipalities" />
</html:select>
</tr>
Onchange of district, I get muncipalities.
Please help?
Character encoding can be quite tricky, make sure you haven't missed out on anything.
Refer the link below:
http://balusc.blogspot.com/2009/05/unicode-how-to-get-characters-right.html
Related
I have the following code in edit.jsp
<%
while (rs.next())
{
%>
<tr>
<TD><%=rs.getString(1)%></TD> //for text box name
<TD><%=rs.getString(2)%></TD> //for text box address
<TD><%=rs.getString(3)%></TD> //for text box origin
<td> <img src="images/editdetail.png"></td>
</tr>
while clicking the image/editdetail.png i am redirecting the page to create.jsp, where i have three text boxes("name", "address" and "origin").
how to get the getString value also getting displayed in the text box when i click the png image, so that i can edit the details.
You could pass this as params as TJ mentioned. But if you think its kinda insecure, because the details are present in the URL, you could save the details as an object in the session. using session.setAttribute().
In the create.jsp, read the object against the key and populate the text boxes accordingly.
A usecase similar to your's is illustrated in this example : http://www.jsptut.com/sessions.jsp
I believe, the create.jsp will submit the detials to another JSP. say... submit_details.jsp
in submit_details.jsp, after processing the details, do remember to remove the attribute from the session.
I am trying to click on some button (which becomes enabled after all of the fields are fill in):
<div class="savCancelContainer">
<input type="button"
value="Save"
translatekey="ACTVITY_DETAILS_SAVE_BUTTON"
class="translate" id="submitActivityDetails"
style="background-color: rgb(0, 125, 195);">
The programmers of the web-page have changed it for some reason, and now my code is no longer working correctly (the button doesn't get clicked on):
driver.findElement(By.id("submitActivityDetails")).click();
I also tried finding it by xpath, with no success.
Is there any way to click the button using the Id and Value attributes together?
Any other ideas?
Similar pages and dialogs are still working fine...
You need to create a xpath which will contain both the attribute:
//input[#id='submitActivityDetails'][#value='Save']
And Click event can be triggered in the following way:
driver.findElement(By.xpath("//input[#id='submitActivityDetails'][#value='Save']")).click();
Lemme know if it helps!
Additionally you can use css seelctor to perform that action too.
[id='submitActivityDetails'][value='Save']
i have a question about using request.getParameter(), i knew that it can use to post the value using request.getParameter, Is it necessary match request.getParameter and <input>???
My original code in HTML:
<INPUT type=submit name="submit" value="download">
In JSP:
String start = request.getParameter("submit");
Now I want to change a button and use div
div name="submit"id="submit" class="btnStyleFunc"
onclick="document.body.style.cursor='wait';this.disabled='true';
document.getElementById('form').submit();">
But it doesn't work, anyone can help me ?
Now i use the method below, but another problem is raised...the action does not stop...
String start = request.getParameter("submit1");
<input type=hidden name=submit1 value=download>
<div class="btnStyleFunc" onclick="document.body.style.cursor='wait';
this.disabled='true';document.getElementById('form').submit();">
Does anyone know what the problem is ?
A clicked submit button is a successful form control and its name/value pair will be submitted to the server in the form data.
If you submit a form with JavaScript, there is no clicked submit button, so it won't appear in the data. A div cannot have a name and is not a form control anyway — it isn't a submit button, even if it triggers JavaScript that submits the form.
Using a div with JavaScript also breaks the form for:
Anyone not using a mouse/trackpad/etc to navigate the page (a div won't get the focus when tabbing through interactive elements)
Anyone with JavaScript disabled
Anyone using a screen reader in forms mode (div elements are not form controls).
Use a real submit button instead.
Running Java/Selenium 2.3 (and 4) using Firefox Driver on centos
Trying to test against a site that has form with a text type, with an onchange. Tried to insert the text using the sendkeys, and then changing focus by doing a select/click on another term in the form. Tried to do a fireevent as well. (Doesn't appear to be supported in the 2.3 sel)
Searched the net as well with no luck.
Basically, trying to get a solution to how to do an insert into a textbox for selenium/firefox driver, so the inserted text actually appears in the textarea, which means the onchange event gets fired.
The test html is::
<td rowspan='4' nowrap='nowrap' valign='top' align='left'>
<DIV id='win0divCLASS_SRCH_WRK2_SUBJECT$69$'><input type='text' name='CLASS_SRCH_WRK2_SUBJECT$69$' id='CLASS_SRCH_WRK2_SUBJECT$69$' tabindex='31' value="" class='PSEDITBOX' style='width:60px; ' maxlength='8' onchange="addchg_win0(this);oChange_win0=this;" />
</DIV></td>
The test code is::
driver.findElement(By.name("CLASS_SRCH_WRK2_SUBJECT$69$"))
.sendKeys("ACG");
driver.findElement(By.name("CLASS_SRCH_WRK2_SUBJECT$69$"))
.sendKeys("");
Select sCourse= new Select(driver.findElement(By.id("CLASS_SRCH_WRK2_ACAD_CAREER")));
sCourse.selectByValue("");
The test sets the textelement, and then sets the select/option of a select item, which should trigger the change in focus. I also tried to clear, and reset the text, thinking that might trigger the onchange..
A solution to this would help a lot of people who've been looking for the same thing!!
Thanks
Have you tried doing a tab after sendKeys?
You can do a
driver.findElement(By.name("CLASS_SRCH_WRK2_SUBJECT$69$"))
.sendKeys("\t");
I had a similar problem (though my trigger was onBlur). I called the blur() method directly. In your case it would be
driver.findElement(By.name("CLASS_SRCH_WRK2_SUBJECT$69$")).sendKeys("ACG");
((JavascriptExecutor)driver).executeScript( "$('[name=\"CLASS_SRCH_WRK2_SUBJECT$69$\"]' ).blur() );
You might need a different function other than blur().
I have a combobox with an option "other". user can select an entry from the list or select option "other". if they select "other" a text box will disply below to enter a new account number. see the code below:
<td>1. Account Number<span class="bodyCopy"><font color="#ff0000"> * </font></span>:
<html:select name="reDataForm" property="Member.accountNumber" styleClass="formContent"
style="width:80px" onchange="showfield(this.options[this.selectedIndex].value)">
<html:options collection="<%= WorkConstants.NewDropdowns.PACCT %>" property="value" labelProperty="label" styleClass="formContent"/>
</html:select>
<div id="div1"></div>
It works fine. But when the page refreshes, the text box disappears as no code to keep it there.
1)how do I keep the text box if the use was selected "Other" and entered a new account number in the text box ? OR if we can add the text box value into the dropdown list, that will also work.
2) Also how to set the text box value into the same variable Member.accountNumber ?
please help me !!!!
Use a little bit of javascript on an onLoad event to check if other is selected, and display the text box
You can't submit the value as the same name as the select box. instead, submit as a second name and process accordingly in your ActionForm on the serverside.