Accessing a arraylist in javascript
Hi
can anyone tell me how to access araraylist
<table class="tableborder">
<tr class="subtablerow2"><td class="boldtext">Total Marks : <bean:write name="courseCriteriaForm" property="totalMarks"/> </td>
<td class="boldtext">Passing Marks : <bean:write name="courseCriteriaForm"property="passingMarks"/></td>
</tr>
</table>
<table class="tableborder">
<logic:iterate id="StudentListmarks" name="courseCriteriaForm" property="StudentListmarks" >
<tr>
<td>
<bean:write name="StudentListmarks" property="userinfo_id"/>
</td>
<td>
<bean:write name="StudentListmarks" property="firstname"/>
</td>
<td>
<bean:write name="StudentListmarks" property="lastname"/>
</td>
<td>
<html:text name="StudentListmarks" property="marks" indexed="true" />
</td>
<td>
<html:text name="StudentListmarks" property="remarks" indexed="true"/>
</td>
</tr>
</logic:iterate>
</table>
<div align="center"><html:submit styleClass="button" onclick=" return validate(this.form,StudentListmarks);"/><html:cancel styleClass="button" /></div>
here is my javascript:
function validate(form,myarraylist){
alert("in the function........");
for(var i=0;i<myarraylist.lenght;i++){
alert("here....");
return false;
can any1 help me in validating marks by javascript
a) Use formatting to display code
b) dont use things like any1 , Why should people bother to help you if your question isent important enoigh to type 2 letters more ?
c) As far as i know JavaScript does not have a build in ArrayList object
Similar Messages
-
How can I access xml document from javascript whithin a JSP page
how can I access xml document from javascript whithin a JSP page?
I have a JSP that receives an XML document from a JavaBean, so I can access it within the entire JSP, but I need to access it from the javascript inside the JSP... and I have no idea how i can do this.
Thanks in advance!The solution would only work on MS IE browsers, as other browsers do not support an XML DOM.
It can be done, but you would be stuck with using the Microsoft broswer. If that is acceptable, I have some example code, and a book recommendation. -
How to pass java arraylist into javascript arrays
Hi, i have declare an arraylist
ArrayList list1 = new ArrayList();Inside the arraylist, there are elements. Now, i wan to pass the elements in the java arraylist into javascript arrays but i encounter javascript errors.
This is how i code.
var arr1 = new Array();
<%
for ( int x =0; x<list1.size(); x++)
%>
arr1[<%=x%>] = <%=(String)list1.get(x)%>;
<%
%>how do i solve this problem?
Thanks for the guidance in advanceJTech wrote:
Hi,
Use Quotes around string value ( arr1[indexposition] = "stringvalue";), when assign to javascript array as below.
arr1[<%=x%>] = "<%=(String)list1.get(x)%>"; Regards,
Ram.Hi Ram,
How about using arr1 = <%=list.toArray()%> ??? Is this possible? I tried it but was not working on my IDE. Do you have any solutions for this??
Regards,
Thiagu -
Accessing java classes from javascript
Hi,
I have the following javascript function
function testjava {
var myString = new java.lang.String("Hello world"); // line 1
alert("len:"+myString.length()); // line 2
}It gives me a error at line 1 saying "'java' is undefined" in IE browser 5.5 sp2. But, both the lines execute correctly in netscape 6.
Can someone please help..
Thanks,
Vijay.It seems that IE 5.5 doesn't support accessing java classes in JavaScript, so try to install IE 6 to see if it works or maybe, you doesn't have installed propertly support for JVM in IE.
-
Access Custom Attributes in JavaScript and in Transactions
Hello,
I try to work with custom attributes. I've problems accessing the values in JavaScript and in transactions, but it works fine within .irpt pages.
What's the trick?
For a custom attribute called PLANT, can I write something like this in JavaScript?
var p = ;
Is there a way to access custom attributes in the Link Editor of an Action Block?
Kind Regards,
MatthiasHi Matthias,
it is not possible to integrate that kind of MII variables in JavaScript like you discribed before.
You are right that this kind of expression is possible in the .irpt file. The reason why it is working in the .irpt
but not in the .js is, that the MII script parser is only replacing in HTML content. Everywhere you have
scripting the parser will not replace the {...} markings (since the curly brackets also show start/end of functions aso.).
Variables to JavaScript
The easiest Way to get those variables is to create hidden fields in the .irpt file that you can access via JavaScript.
For example:
<input type="hidden" id="hidden_plant" value="{PLANT}" />
This will be parsed to (e.g.)
<input type="hidden" id="hidden_plant" value="Karlsruhe/DE" />
Now you can access this value in JavaScript via:
document.getElementById( "hidden_plant" ).value;
Variables to Transactions
To parse custom variables to a transaction you first have to specify corresponding transaction variables in the
transaction itself. After saving the transaction you can map those variables to Parameters in the Xacute-Query-Editor.
Including this transaction to your webpage you can simply assign the required value to the corresponding parameter.
For example if you mapped the Plant variable of the transaction to Param.1 you can specify the information in the .irpt
like:
<applet id="trx_test" ....>
<... />
<param name="Param.1" value="{PLANT}" />
</applet>
Another possibility is to set the value dynamically via JavaScript if you use:
document.getElementById( "trx_test" ).getQueryObject().setParam( 1, "Karlsruhe/DE" );
Native access to user variables via the BLE is not possible (as far as I know).
I hope this is what you wanted to hear?
Best Regards
Sebastian
Edited by: Sebastian Holzschuh on Jun 10, 2008 12:16 PM -
Access embedded reader with javascript
For a project I'm looking for a way to display pdf files within a webbrowser. I have IE8+ with acrobat reader available to me, so i can display any given pdf. But i would like to be able to change pages, jump to bookmarks with javascript functions in my html page.
So in other words: does acrobat reader have somesort of api through which i can access my document using javascript?Post the query in the forum for Acrobat SDK.
-
Access to Data from Javascript
I have a propertie call it "country" in my "Data View" and I need access its value from javascript code to use in a IF sentence.
I try thinks such as "xfa.node.getAttribute("country")" but doens't work.
How can I access it?
Thanks.You can try like this:-
if(country.rawValue == "IN")
xfa.host.messageBox ("You selected India"); // This will display a pop-up
else
xfa.host.messageBox ("You selected some other country");
Chintan -
Help needed on accessing an arraylist
Hello
I have declared an arrayList globally as follows:
ArrayList itemList = new ArrayList();I have then wrote a method to test if a user's session is new, if so set the arrayList into the session using setAttribute. The code then gets the attribute from the session and stores it in the variable listFromSession. This is also set into the session. The code is below:
//ItemList itemList;
if (ca.isNew()){
//itemList = new ArrayList();
ca.setAttribute("itemlist", itemList);
ArrayList listFromSession = (ArrayList)ca.getAttribute("itemList");
listFromSession.add(c);
ca.setAttribute("itemList", listFromSession);I have then tried to retrieve elements from the arrayList. Code is below, but im not sure if im trying to access the arrayList as you would a normal array:
ArrayList listFromSession = (ArrayList)ca.getAttribute("itemList");
for (int i = 0; i < listFromSession.length; i++){
int amt = listFromSession.getprodQuant(i);
int id = listFromSession.getStockID(i);
String name = listFromSession.getprodName(i);
float price = listFromSession.getprodPrice(i);
float totalPrice = amt * price;
out.println("<TD>" + id + "</TD>");
out.println("<TD>" + name + "</TD>");
out.println("<TD>" + amt + "</TD>");
out.println("<TD>" + price + "</TD>");
out.println("<TD>" + totalprice + "</TD>");
}For example, i did originally have int amt = listFromSession(i).getprodQaunt; and so forth but that threw the same error: cannot find symbol getProdQuant even when I put code it in the example above.
Basically the compiler cannot find the get methods nor the variable length(), ive tried size() but it dosn't like that either
Can anyone help?
ThanksCan anyone understand as to why my arraylist cannot be accesssed or return the elements?
Is it because the initialization is outside of the method that is accessing the list?
package cart;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Enumeration;
import cart.CartItem;
public class CartSession extends HttpServlet
private HttpSession ca = null;
private int numProducts = 0;
ArrayList itemList = new ArrayList();
ArrayList listFromSession = new ArrayList();
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
response.setContentType("text/html");
PrintWriter out = response.getWriter();
int currentProduct = Integer.parseInt(request.getParameter("stock"));
String currentName = request.getParameter("name");
float currentPrice = Float.parseFloat(request.getParameter("price"));
String am = request.getParameter("Amount");
if (am == null) am = "1";
int currentAmount = Integer.parseInt(am);
cart.CartItem c = new cart.CartItem(currentProduct, currentName, currentPrice, currentAmount);
ca = request.getSession();
//ItemList itemList;
if (ca.isNew()){
//itemList = new ArrayList();
ca.setAttribute("itemlist", itemList);
ArrayList listFromSession = (ArrayList)ca.getAttribute("itemList");
listFromSession.add(c);
ca.setAttribute("itemList", listFromSession);
ca.setAttribute("currentProd", c);
sendPage(response);
private void sendPage(HttpServletResponse reply) throws IOException
reply.setContentType("text/HTML");
PrintWriter out = reply.getWriter();
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE></TITLE>");
out.println("<HEAD>");
out.println("<BODY><H1>Your Shopping Cart</H1>");
out.println("<CENTER>");
out.println("<BR><BR><BR>");
//cart.removeAttribute("currentProd");
out.println("<TABLE BGCOLOR=Aqua BORDER=2>");
out.println("<TR>");
out.println("<TH>Stock ID</TH>");
out.println("<TH>Product</TH>");
out.println("<TH>Quantity</TH>");
out.println("<TH>Unit price</TH>");
out.println("<TH>Total price</TH>");
out.println("</TR>");
ArrayList listFromSession = (ArrayList)ca.getAttribute("itemList");
for (int i = 0; i < listFromSession.length; i++){
int amt = listFromSession.getprodQuant(i);
int id = listFromSession.getStockID(i);
String name = listFromSession.getprodName(i);
float price = listFromSession.getprodPrice(i);
float totalPrice = amt * price;
out.println("<TD>" + id + "</TD>");
out.println("<TD>" + name + "</TD>");
out.println("<TD>" + amt + "</TD>");
out.println("<TD>" + price + "</TD>");
out.println("<TD>" + totalprice + "</TD>");
//See if user wants more items
out.println("<FORM METHOD=POST ACTION='paymentform.html'>");
out.println("Would you like to<BR>");
out.println("<INPUT TYPE=SUBMIT VALUE=\" Add more items \">");
out.println("<FORM METHOD=POST ACTION='paymentform.html' \">");
out.println("<INPUT TYPE=SUBMIT VALUE=\" Check Out \">");
out.println("</TABLE>");
out.println("</FORM>");
out.println("</CENTER>");
out.println("</BODY>");
out.println("</HTML>");
out.flush();
{code} -
PPC Mini running 10.4.11 unable to access urls based on Javascript, get "Javascript void" at bottom of window.. Software up to date. Cannot find where to verify if JavaScript turned off.
I guess I verified this in following earlier IIIasss recommendations (whom I will respond to in detail after this).
I have used Firefox (cookies deleted after each session) successfully with this site (Zinni Optical), but something has changed over the last year and a half and, to my knowledge it isn't on my end. When I get response at all, and try to navigate to "My Favorites, etc., and nothing happens for a while, I try to refresh, only to get a "stopped" message with a blank screen.
Tried Safari and Internet Explorer browsers (all I presently have installed) without succerss. May go back to TenFourFox (which had it's own wierdness over time, which is why I uninstalled it. Don't know latest versions compatible with 10.4.11 of Safari (but Software update is satisfied I'm up to date) or Internet Explorer.
I'm out in the sticks using a Verizon (Novatel) MiFi in a metal building, and so require a Wilson external antenna, liightening arrestor, signal amplifier and inside rebroadcast antenna to boost cell phone signal from one to four bars. Hope I get similar boost for wireless-Airport connection, understand that is different frequency, but also boosted.
The site for the bank I do WebBillpay with has had a minor change...no longer do I get the option to sign off (six months to a year ago), otherwise, fine. -
Problem with accessing Signed Applet from javascript method
Hi,
I am facing the following problem while accessing Signed Applet from javascript method.
java.security.AccessControlException: access denied (java.io.FilePermission c:/temp.txt read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at FileTest.testPerm(FileTest.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin.javascript.invoke.JSInvoke.invoke(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin.javascript.JSClassLoader.invoke(Unknown Source)
at sun.plugin.com.MethodDispatcher.invoke(Unknown Source)
at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
at sun.plugin.com.DispatchImpl$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin.com.DispatchImpl.invoke(Unknown Source)
I am using jdk1.5 for my development...
Can anyone help to resolve this security issue. Urgent...
Thanks in advance.Hey thanks. I wasn't able to get it to work with that sample but I did find this very similar code that does allow javascript to call JFileChooser in an applets public method.
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction()
public Object run(){
//do your special code here
return null; //return whatever you want
It seems a bit tempermental in that if you don't select a file quickly, it will hang the browser....no perfect solution but I'm going in the right direction.
Thanks,
Scott -
Accessing c4 Variables in Javascript
How do you pass a Captivate 4 variable (User or System) in Javascript when the published .SWF is embedded in another tool like Lectora or Flash?
In Captivate, you can set a value into a Lectora variable (VARmyLectoraVariable.set('myvalue');, but I don't know how to access the Captivate variable.
When run from Captivate, this works:
Captivate.GetVariable('CaptivateVariable');
But when the published .swf from Captivate is inserted into Lectora and run, I get a JavaScript error ('Captivate' is undefined).
How do you reference the Captivate variable in JavaScript when the .swf is not embedded in the Captivate project html file?
Thank you!http://pipwerks.com/journal/2009/06/07/introducing-the-captivatecontroller/
check this out -
Problem with access JSF applet using javascript
Can someone help me!
I'm using a applet in jsf page, and i'm trying to access this applet using a javascript.
Here is the applet code
<jsp:plugin code="DoAction.class" codebase="." height="400" hspace="10" jreversion="1.5" type="applet" vspace="50" width="100" name="myApp"/>
Here is the javascript
function printReturn()
var a = document.myApp.returnString();
alert(a);
"returnString" is the method in applet which simply return a string
But it doesn't work, it works well when i'm using this applet in JSF
<applet code="DoAction.class" width="100" height="50" name="myApp" ></applet>
Unfortunately it's depricated!
Please tell me what is the solution....Thank You for replying.
I'm trying to call applet method using JavaScript.
It works when i'm using below apllet tag.
<applet code="DoAction.class" width="100" height="50" name="myApp" ></applet>
But it's deprecated
It doesn't work for below applet tag
<jsp:plugin code="DoAction.class" codebase="." height="400" hspace="10" jreversion="1.5" type="applet" vspace="50" width="100" name="myApp"/>
This is my javascript
<script type="text/javascript">
function setSearch()
var a = document.myApp.returnString();
alert(a);
</script> -
Access Java Array in Javascript function
Hi, could someone please help me, I have an array that gets populated in java code and I need to see it in a javascript function.
Here's what I have so far:
//In java class for AvgCostChart.jsp
private String[] month;
public String[] getMonth()
{//code to populate
return month;}
Then in my javascript onLoad function I try to access it. I know how to access the values one at a time like this.
var month1='#{AvgCostChart.month[0]}';
But how do I pass this to a function.
I tried assigning to to another array to loop through the values like this:
var myArr = new Array();
myArr'#{AvgCostChart.month}';
alert (myArr[0]);
But that does not work, any one done this before.
I've also tried saving it in the session and then accessing it but can't get that to work either.
Any help will be greatly appreciated.Hi,
Please go through the following thread:
http://swforum.sun.com/jive/thread.jspa?forumID=123&threadID=60147
Hope this helps
Cheers
Girish -
Accessing Context Data with JavaScript in Adobe Form
Hi,
does anybody know, how to access a context element with javascript in an adobe form, because I have to decide which elements will be shown at the form, depending on one context value.
Thank you for your help!
Kind regards, Patrick.Hi,
First of all your WD context is mapped to the data view in the form. You can only access via scripting what is mapped to the data view and you get the values that the PDF currently has stored. The WD context and the data values in the context might differ (eg. due to editing).
Use scripting like xfa.resolveNode("xfa.dataset.data.<path.to.the.node>") to get a reference to the data node.
Then you can use the "value" property to access the data value.
Regards
Juergen Hauser -
Accessing HTMLB checkbox in javascript
Hi,
I have the following scenario:
1) jsp "main.jsp" has a checkbox with id="chkBoxId"
2) In this "main.jsp" at the end, there is a jsp include
including another jsp "buttons.jsp" - which contains a
SUBMIT button.
3) On this SUBMIT button, I am calling a javascript
function "check()" in the "onClientClick" attribute.
4) In this "check()" function I want to access the
checkBox (present in "main.jsp")
Now when I try doing this using the following code in the check() function, it gives me a "Undefined is null or not an object".
function check(chkBoxId) {
var funcName = htmlb_formid+"_getHtmlbElementId";
func = window[funcName];
var chkBox1 = eval(func(chkBoxId));
// The checkbox is obtained
if (chkBox1)
alert("Not Checked");
Plzz help me !!!
regards,
JitendraHI,
U can write the javascript function in the header tag or create a .js file in which u write the javascript code.
the javascript code can be like
function ValidateForm()
if(document.form1.s_material.value=="")
alert("enter material");
return false;
return true;
where form1 is id of form and s_material is iD of input field.
In your coding for button onClientClick like :
<htmlb:button id="s_but_submit"
width="20"
onClick="submit"
onClientClick="if(!ValidateForm(this))htmlbevent.cancelSubmit=true;"
Regards,
Siddhartha
Maybe you are looking for
-
FIX: Ipod cannot be synced. An unknown error occurred (-48)
Hey everybody, I just wanted to share with you a solution that my friend and I have used to eliminate the "iPod cannot be synced. An unknown error occurred (-48)" error. I have a iPod Photo 60 gig that has not had this error before....until 3 days ag
-
Change the Deadline -latest end from step before or other WF
Hi, I have the following situation. We create a wait event step with a lasted end calculated previously. The problem is that the values for calculate changes after the wait step is created, so we need to change the lasted end too. How this lastest en
-
HT1349 how can i open the ipad , the slide key on the screen not working.?
how can i open the ipad , the slide key on the sreen not working ?
-
Listing possible events from event source (or DLL)
Does anyone know of a replacement for MOM 2005 resource kit tool mpwizard, which could dig out what sort of events COULD be written to event viewer logs. Not interested about a tool that could parse the existing event logs, but specifically one that
-
Cannot import .mov files generated by Toast
Hi All, I have a strange issue : I had old HI8 tapes that I got transferred on DVDs (VOB files). I then converted these files in HD DV with Toast 10, which generated AIC (Apple Intermediate Codec) files encapsulated in mov that I can perfectly read w