Access selectItems component from javaScript

Hi,
In the source below I want to access a selectItems component inside of a selectOneRadio from javaScript. I can access the selectOneRadion as in the code below but I can not the selectItems. Anyone who has an idea?
<afh:script text='
function showValue() {
var test=document.getElementById ("form1:radio1").value;
alert(test);
/>
<af:selectOneRadio label="Label 1" id="radio1" >
<f:selectItems value="1" id="radio2" />
</af:selectOneRadio>
thanks in advance

Hi,
for a select item the code is
2nd value of a list
================================================
<input type="button" name="click" onClick="alert(document.form1.select.options[1].value)">
2nd label in a list
====================================================
<input type="button" name="click" onClick="alert(document.form1.select.options[1].text)">
selected value
==========================================
onClick="alert(document.form1.select.value)"
where
<form name="form1" method="post" action="">
  <select name="select" size="1">
    <option value="1" selected>A</option>
    <option value="2">B</option>
    <option value="3">C</option>
  </select>
  <input type="button" name="click" onClick="alert(document.form1.select.value)">
</form>
Frank

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.

  • 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

  • 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

  • Access page item from Javascript

    I have searched the forum, and based on my findings this is what I've done so far:
    I have a page item where the Google Map key is stored. I want to access it from Javascript so that I can call the Google map with the key. (Note: The key can't be hardcoded as it will be pulled from DB according to the environment/url the app is running on. e.g. - dev, test, production.)
    Here's a javascript code block:
    <script>
       var google_key = $x('P1_GOOGLE_KEY').value;
       var l_url = "http://maps.google.com/maps?file=api&amp;v=2&amp;key=" +
                   google_key +
                   "&sensor=false";
    </script>I have tried, $v('P1_GOOGLE_KEY') , $x('P1_GOOGLE_KEY') , &P1_GOOGLE_KEY. and none of them work.
    How do I access a page item from Javascript?
    Thx!
    Marc

    Marc,
    I am going to take a shot in the dark, but are you referencing this item outside of a function in your head tag? So basically it tries to reference the item on load? If so this is not going to work because the item does not exist yet. If you are using jQuery change your code to look like:
    $(document).ready(function(){
       var google_key = $x('P1_GOOGLE_KEY').value;
       var l_url = "http://maps.google.com/maps?file=api&amp;v=2&amp;key=" +
                   google_key +
                   "&sensor=false";
    });This will tell the javascript to fire after everything has fully loaded. If you are not using jQuery then you can use a little javascript snippet from here to add a ready event to your page. or you can copy paste this into a script tag.
    (function () {
      var ie = !!(window.attachEvent && !window.opera);
      var wk = /webkit\/(\d+)/i.test(navigator.userAgent) && (RegExp.$1 < 525);
      var fn = [];
      var run = function () { for (var i = 0; i < fn.length; i++) fn(); };
    var d = document;
    d.ready = function (f) {
    if (!ie && !wk && d.addEventListener)
    return d.addEventListener('DOMContentLoaded', f, false);
    if (fn.push(f) > 1) return;
    if (ie)
    (function () {
    try { d.documentElement.doScroll('left'); run(); }
    catch (err) { setTimeout(arguments.callee, 0); }
    else if (wk)
    var t = setInterval(function () {
    if (/^(loaded|complete)$/.test(d.readyState))
    clearInterval(t), run();
    }, 0);
    document.ready(function (){
    var google_key = $x('P1_GOOGLE_KEY').value;
    var l_url = "http://maps.google.com/maps?file=api&amp;v=2&amp;key=" +
    google_key +
    "&sensor=false";
    Good Luck,
    Tyson Jouglet

  • 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 Java object from Javascript

    Hi
    I'm trying to invoke a Java object from Javascript (scriptengine and all that).
    I want to add scripting features to a GeneXus Java generated app... and I have very basic skills on java too. Sorry for that ;o).
    This is the java code to pass "params" to the scriptengine:
    engine.put("remoteHandle",remoteHandle);
    engine.put("context", context); The remoteHandle (int) and context (com.genexus.ModelContext) pass trough all the gx-java generated programs.
    This javascript works fine:
    importClass(Packages.uftestjs);
    new uftestjs(remoteHandle).execute( ) ;The remoteHandle conversion is ok (javascript-number to int). The context is optional.
    But if I want to pass context:
    importClass(Packages.uftestjs);
    new uftestjs(remoteHandle, context).execute( ) ;Fails with this:
    "javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: Java constructor for 'uftestjs' with arguments 'number,javax.script.SimpleScriptContext' not found."
    Obviously, no conversion is possible with context (javax.script.SimpleScriptContext to com.genexus.ModelContext).
    There is some way to reference de original context, by the object Id??? or something like that???
    Thanks in advance for any replies!!!
    Greetings from Chile. (I hope you can understand my english!)

    Hi
    Well, since this topic is about java programming I think the place is right here.
    (I use some tricks to embed java statements in genexus objects...)
    I will try to get some help at Artech (GX) on how to build something... to get the conversion needed.
    But they are not focussed on support this kind of questions.
    Anyway, I want to know: do I can to reference an object by the objId?
    I want to code something like this:
    com.genexus.ModelContext context =
                     (com.genexus.ModelContex)getTheObjectFromTheJVM(theObjectId);(powered by google translator, ha!)

  • Accessing pageFlowScope Map from javascript

    I have the following use case
    Model Layer Method - returns a comma-separated string
    Bean Method - Accesses this model layer method and assigns the comma separated string to a pageFlowScope variable (lets say #{pageFlowScope.temp})
    Jsff -
    <af:resource>
    alert('${pageFlowScope.temp}');
    </af:resource>
    What I've been encountering
    1) Lets say the Model layer method return "A,B,C"
    2) The alert is consistent (i.e. in the alert, I get "A,B,C")
    3) In the same session, the model layer method now returns "D,E,F"
    4) The alert is consistent (i.e. in the alert, I get "D,E,F")
    5) In the same session, the model layer method now returns "A,B,C" again
    6) The alert continues to be "D,E,F"
    Basically, unless the return value from model layer changes to something that has not been encountered till that point in time, the alert sticks with the latest value even though the pageFlowScope var changes behind the scene.
    Looks like something to do with caching.
    Also, my af:resource tag is encompassed in a container component (af:panelFormLayout) which means it shouldn't be cached
    Can anyone explain this behavior and how I can always keep my javascript variable consistent with the pageFlowScope var?

    Hi,
    always make sure yo mention the JDeveloper version. Apparently you use JDeveloper 11g R2 and JSF 2 as otherwise using EL in this form is not possible. Anyway, don't rely on people guessing.
    I am wondering why you read the JS from the page flow scope instead of using teh ExtendedRenderKitService to invoke JS on the client
    //Apache Trinidad Class
    ExtendedRenderKitService service = Service.getRenderKitService(FacesContext.getCurrentInstance(), ExtendedRenderKitService.class);
    service.addScript(FacesContext.getCurrentInstance(), "alert('hello world');");For more complex JS string compositions, use the StringBuffer class (which also is better to use if you want to add dynamic data read from a model)
    +"af:resource tag is encompassed in a container component (af:panelFormLayout) which means it shouldn't be cached"+
    No guarantee that this is not cached unless you partially refresh the surrounding component. Still then, your EL uses "$" which is an immediate call upon JSF compile time whereas PPR is deferred. Using the extended renderkit service is the better way of solving your coding issue
    Frank

  • How do you access parent component from a child in Flex 4?

    Suppose I have a Component A (as a Spark Group) that generates an event, eventX.  Inside Component A, I add Component B (also a Spark Group) that wants to add itself as an event listener for eventX.  How do I access Component A from Component B to register for the event?
    For reference, this relationship should be similar to the MVC pattern where Component B is the view, and Component A is the model and controller.
    If I were implementing this in ActionScript, I'd have no problem coding this.  However, I am using flex, and am still trying to figure out how the FLEX API works.

    GordonSmith wrote:
    B could "reach up" to A using the parentDocument property. Or you could set a reference-to-A onto B.
    Gordon Smith
    Adobe Flex SDK Team
    B could "reach up" to A using the parentDocument property
    Would you mind explaining that?
    set a reference-to-A onto B.
    That is something I am trying to avoid.  I do not want to create tightly coupled code.
    Here is a generic form of the code I am using.  Feel free to tell me what I'm doing wrong in your explanation of how B can "reach up" to A.  Thanks!
    Component A
    <?xml version="1.0" encoding="utf-8"?>
    <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx" width="837" height="733"
                     creationComplete="componentA_creationCompleteHandler(event)"
                     xmlns:components="components.*">
         <fx:Script>
              <![CDATA[
                   import mx.events.FlexEvent;
                   public static const STATE_CHANGED:String = "stateChanged";
                   private var currentModelState:String;
                   protected function componentA_creationCompleteHandler(event:FlexEvent):void
                        changeModelState("second");
                   public function changeModelState(newState:String):void
                        if (newState != currentModelState)
                             currentModelState = newState;
                        dispatchEvent(new Event(IP_Dragon.STATE_CHANGED));
                   public function getModelState():String
                        return currentModelState;
              ]]>
         </fx:Script>
         <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
         </fx:Declarations>
         <components:Component_B id="b" x="0" y="0"/>
    </s:Group>
    Component B
    <?xml version="1.0" encoding="utf-8"?>
    <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               xmlns:components="components.*"
               width="837" height="733" contentBackgroundAlpha="0.0" currentState="first"
               creationComplete="componentB_creationCompleteHandler(event)">
         <fx:Script>
              <![CDATA[
                   import mx.events.FlexEvent;
                   protected function componentB_creationCompleteHandler(event:FlexEvent):void
                        currentState = parent.getModelState;
                        parent.addEventListener(Component_A.STATE_CHANGED, modelStateListener);
                   private function modelStateListener (e:Event):void
                        currentState = parent.getModelState();
              ]]>
         </fx:Script>
         <s:states>
              <s:State name="first"/>
              <s:State name="second"/>
              <s:State name="third"/>
         </s:states>
         <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
         </fx:Declarations>
         <components:Component_C includeIn="first" x="220" y="275"/>
         <components:Component_D includeIn="second" x="2" y="0"/>
         <components:Component_E includeIn="third" x="0" y="8"/>
    </s:Group>
    For the record, I know this code does not work.  It has to do with the parent calls in Component B.  Comment out those lines, and the code will compile.

  • Accessing OID API from Javascript

    Hi,
    is there a way to access OID API directly from the client side ? using javascript ? Thanks.
    To help you understanding what I intend to do : I need to display a hyperlink but this hyperlink will be dynamic based on the "location" of the current user. This "location" can be found by querying OID.
    Thanks.
    Jeff

    Hi
    You don't need client side scripting, neither XMLHTTPRequest. Just write a small PL/SQL procedure on the serveur that will create the link you want based on the current user/location retrieved from OID, then call it for instance with a dynamic page
    In a dynamic page, write
    begin
    portal.my_package..my_proc;
    end;
    and my_proc on the server would do something like :
    declare
    lc_url long;
    begin
    -- retrieve into lc_url the oid info you need for current user, may be using additionnal wwctx_api library
    htp.p('<a href="http://my_serveur/' || lc_url || ">link</a>');
    end;
    Loko

  • Access private variables from javascript

    Hi.
    How can i access my objects and varibles, in my java code from my javascript.

    Try displaying the value before you assign it.
    If you wanna display the value of a text field called textCallClass, this is the javascript code:
    alert(document.getElementById("form1:textCallClass").value);
    And if you wanna display a field called uniqueNum from a page called
    SchemeHolders, this is the javacsript code:
    alert(#{SchemeHolders.uniqueNum});
    You have ro have a public function called getUniqueNum in SchemeHolders.java. And ensure the case is exactly like mine is.
    That does work fine in my programs, if you have any other problems, post the error message.

  • Accessing Flash params from JavaScript

    Folks,
    I am starting out on Flex/Flash so if I am confusing
    terminology please let me know.
    I have a web page with video section (like in YouTube) using
    Flash and I have a button outside that section, on the regular html
    part of the page. When I click that button I want to somehow go to
    the Flash code playing the video and extract the elapsed time that
    the video has played for e.g. if the video has played for 2 min and
    18 secs I want to get that back and display in an html label.
    From the research I have so far I find only the events going
    out of Flex/ActionScript but I couldn't find a way to have a
    JavaScript call come in and grab that information. Any thoughts on
    how I can do that or if I should be posting this somewhere else? I
    am using Rails so if there is anything pertinent to that that will
    be helpful.
    Thanks,
    Sanjay.

    Look into ExternalInterface. That will do wht you want.
    Tracy

  • Calling a method from another class or accessing a component from another

    Hi all
    im trying to make a find/replace dialog box
    my main application form has a jtextpane and when i open up the find and replace dialog box it has two textboxes (find and replace)
    now i have the code to do the finding on my jtextpane but how do i call that code to do the find method?
    I have tried having the code in my main application class but then how do i call that method from my dialog box class?
    ive also tried having the code in my dialog box class, but then how to i tell it to work on my jtextpane which is in my main ap class?

    well if someone had been nice enough to provide me
    with a tutorial i wouldnt have gotten into this
    muddle, no need to be rude is there!I'm not rude. And you also wouldn't have gotten into the muddle if you searched yourself. This site provides many very good tutorials about all kinds of stuff.
    http://java.sun.com/docs/books/tutorial/java/javaOO/classes.htmlAmong other things, it mentions that "static" defines everything that belongs to a class, as opposed to an object.

  • Access java from javascript in firefox

    Hi,
    I am trying to access java method from javascript.
    It works fine with ie, but firefox somehow brings up the error
    saying the method defined in java is not a function.
    I am calling like.
    document.applets["myapp"].soundAlarm();
    I have put MAYSCRIPT in the applet tag.
    still not works.
    Does anyone have idea ?
    Thanks

    Try with
    document.myapp.soundAlarm();I assume that the name attribute of the APPLET is myapp.
    Note the MAYSCRIPT is useless in your context. MAYSCRIPT is used when from Java you need to access the JSObject.
    See http://www.rgagnon.com/topics/java-js.html for examples.
    Bye.

  • Access ATG REST webservices from javascript..?

    Hi All,
    Can we access ATG REST web services from Javascript/jQuery..? If yes, then how..?
    Thanks,
    Vishnu

    Hi Nitin, I'm able to access /atg/dynamo/Configuration component's properties using REST services from following code -
    */atg/rest/security/restSecurityConfiguration.xml*
    <resource component="/rest/bean/atg/dynamo/Configuration">
         <default-acl value="[email protected]:read,write,execute"/>
         <property name="httpPort" secure="false"/>
    </resource>
    client Java code :
    public class RestClientRequest {
         public static void main(String[] args) {
              RestSession mSession = RestSession.createSession("localhost", 8180, "[email protected]", "chinna");
              mSession.setUseHttpsForLogin(false);
              try{
                   String loginStatus = mSession.login();
                   if(loginStatus == null || "null".equals(loginStatus)){
                        mSession=null;
                        System.out.println("Login failed");
                   else{
    RestResult result = RestComponentHelper.getPropertyValue("/atg/dynamo/Configuration", "httpPort", null, mSession);
    String test = result.readInputStream();
    System.out.println("\n\n"+result.readInputStream());
    but getting exception when i try to get repository item using the below code
    <rest-security>
    <resource component="/rest/repository/atg/commerce/catalog/ProductCatalog">
    <default-acl>[email protected]:read,write,execute"</default-acl>
    </resource>
    </rest-security>
    Client Java code:
    public class RestClientRequest {
         public static void main(String[] args) {
              RestSession mSession = RestSession.createSession("localhost", 8180, "[email protected]", "chinna");
              mSession.setUseHttpsForLogin(false);
              try{
                   String loginStatus = mSession.login();
                   if(loginStatus == null || "null".equals(loginStatus)){
                        mSession=null;
                        System.out.println("Login failed");
                   else{
    RestResult result = RestResult result = RestRepositoryHelper.getItems("/atg/commerce/catalog/ProductCatalog", "product", null, mSession);
    String test = result.readInputStream();
    System.out.println("\n\n"+result.readInputStream());
    Exception :
    Login successful
    Login Status : ATG3990000
    atg.rest.client.RestClientException: java.io.IOException: Unauthorized Server returned HTTP response code: 401 for URL: http://localhost:8180/rest/repository/atg/commerce/catalog/ProductCatalog/product
         at atg.rest.client.RestSession.createHttpRequest(RestSession.java:755)
         at atg.rest.client.RestSession.createHttpRequest(RestSession.java:722)
         at atg.rest.client.RestRepositoryHelper.getItems(RestRepositoryHelper.java:188)
         at in.vcarve.RestClientRequest.main(RestClientRequest.java:26)
    Caused by: java.io.IOException: Unauthorized Server returned HTTP response code: 401 for URL: http://localhost:8180/rest/repository/atg/commerce/catalog/ProductCatalog/product
         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
         at atg.rest.client.RestSession.createHttpRequest(RestSession.java:745)
         ... 3 more
    Thanks,
    Vishnu

Maybe you are looking for

  • Hotswap monitor/migrate settings?

    I'm moving from current G5 to Mac pro (installing everything anew not migrating) but only have one monitor. Is it okay to hotswap 20" monitor between them? What about transferring monitor settings? Thanks Mickey

  • Dispute case logs

    Is it possible to report off of the dispute case logs?

  • Calling SQL Loader from SQL Plus

    Hi everyone, I currently use both SQL Loader and SQL Plus to load data and to then carry out certain DML tasks and to reinstate indexes. That all works fine but of course I need to be present to start and to monitor the various scripts. What I would

  • How to bypass Emulator for Bluetooth

    Hi, I have a bluetooth device installed on my computer. i have made a project on JDK WTK2.2 When ever i run the application, it runs using the emulator. I want to know if there is any way to by pass the emulator and actually use my bluetooth hardware

  • Keynote - Select Sidebar

    I'm trying to write a script to paste a new master slide into a selection of Keynote slideshows and then make that the master of all slides in the show. My problem is that I can't seem to set the focus to the sidebar. Here is the test code I'm trying