Call managed bean function using javascript

Any one help me how to call managed bean function through Javascript onload() event.

What do you want to do after all? Isn't the constructor/initblock of the bean sufficient? Which JSF version/implementation are you using?

Similar Messages

  • Calling managed bean method using ajax on jsp page loading

    Hello,
    I am using jsf1.1 i want to call managed bean method when page gets loaded using ajax.
    Thanks
    K.Ramu

    Use an ajaxical JSF framework, for example Ajax4jsf (part of RichFaces).
    But why don´t you just use the constructor of the bean class to do some stuff prior to page loading?

  • How to call a bean method through javascript?

    Hi,
    i want to call a bean method using the javascript.
    thansk in advance.

    hi
    i want to call a backing bean method thought javscript on the button click.
    i am inplementing addition of textbox at runtime.i wrote method and i am calling that on the button click.but the textbox is not created.
    the code is bleow
    public String doAction() {
         tryStuff1();
    return "samplejsf";
    public void tryStuff1()
    System.out.println("Enter the trystuff method");
         FacesContext facesContext = FacesContext.getCurrentInstance();
    UIViewRoot uIViewRoot = facesContext.getViewRoot();
    Application application = facesContext.getApplication();
    UIComponent formComp=uIViewRoot.findComponent("subbody:form1");
    HtmlPanelGrid grid= new HtmlPanelGrid();
    grid.setId("panelgrid2");
    grid.setColumns(2);
    grid.setBorder(2);
    //UIComponent panelGridComp=formComp.findComponent("subbody:panelgrid1");
    //UIComponent panelGroupComp=panelGridComp.findComponent("panelgroup2");
         HtmlOutputText output = new HtmlOutputText();
    output.setValue("dynamic jsf text2");
    System.out.println("hello output text2");
    output.setRendered(true);
    grid.getChildren().add(output);
    HtmlInputText input = new HtmlInputText();
    input.setSize(40);
    input.setValueBinding("value", (ValueBinding) application.createValueBinding("#{sample.text2}"));
    input.setRendered(true);
    grid.getChildren().add(input);
    System.out.println("hello output text1");
    grid.setRendered(true);
    formComp.getChildren().add(grid);
    System.out.println("hello output text3:");
    formComp.getRendersChildren();
    formComp.setRendered(true);
    public boolean getRendersChildren() {
         return true;
    jsp code is
    <h:form id="form1">
    <h:panelGrid columns="2" binding="#{sample.formElements}">
    </h:panelGrid>
    <h:panelGrid id="panelgrid1" columns="1">
    <h:panelGroup id="panelgroup1">
    <h:outputText value="hardcoded jsf text1"/>
    <h:inputText value="#{sample.text1}"/>
    </h:panelGroup>
    </h:panelGrid>
    <h:commandButton id="add" action="#{sample.doAction}" value="add" type="SUBMIT"/>
    </h:form>
    when i click on the button its going into the method and diaplying s.o.p but the text box is not updated to the page.
    why is it so.
    i thought there may be a problem in calling the method directly thru button. i want to try thru javascript calling the bean method.
    why is the page not updated.
    can u help me out
    thanks in advance
    sree

  • To call a bean function to set a property value with hx:ajaxRefreshRequest

    I have an input box
    I need to output some text onto an output box,When the input box value changes
    I am using Ibm jsf implementation and RSA 7.0,JSF 1.1 implementation
    I know how to call a bean property's setter method using this hx:refresh submit and associated behaviours and target actions.
    As explained in this tutorial
    http://www.ibm.com/developerworks/rational/library/06/1205_kats_rad2/
    But my aim is to call a bean function other than the setter method,because i could do some business logic there and give output.This is possible via setters too,but i believe thats a poor programming practice.
    Hope ppl have got a clear picture of my problem.
    Help me in this.

    You can use any jsf implementation you want, I suggested you only the steps to accomplish the task but I don't know the components you are using...
    You can also accomplish the task without Ajax at all using "classic" http requests but it will be very frustrating for your users...
    Catch client side event (input value change) -> fire an action that update the model -> update presentation layer with up to date model values

  • Call objective c Method using javascript

    how can i call objective c mehod using javascript..........

    If the JavaScript is running in a browser or UIWebView on iOS, you cannot. Allowing direct access to the native API would be a huge security vulnerability.
    As an alternative, there are development frameworks such as PhoneGap that allow developers to access some native iOS features (such as Contacts, Camera) from JavaScript by using a runtime that includes a foreign function interface. The app must be deployed to the device, bundled with the runtime.

  • How to call a bean method from javascript event

    Hi,
    I could not find material on how to call a bean method from javascript, any help would be appreciated.
    Ralph

    Hi,
    Basically, I would like to call a method that I have written in the page java bean, or in the session bean, or application bean, or an external bean, from the javascript events (mouseover, on click, etc...) of a ui jsf component. I.e., I would like to take an action when a user clicks in a column in a datatable.
    Cheers,
    Ralph

  • How to use call a binding action using Javascript ?

    Hi adf people,
    JDev : 11.1.1.4.0
    How to submit the binding action using the Javascript ?

    what do u mean by submitting the binding action..???
    for javascript you can either use
    af:clientlistener to call javascript
    af:serverlistener to call from javascript to managed bean
    http://download.oracle.com/docs/cd/E12839_01/apirefs.1111/e12419/tagdoc/af_clientListener.html
    http://download.oracle.com/docs/cd/E15523_01/apirefs.1111/e12419/tagdoc/af_serverListener.html
    please tell us if you need any more information.. or explain your question properly..

  • Rendered Property calling managed bean Multiple Times

    Hi
    We have a problem within a command button in a jspx, which includes a rendered tag which references a managed bean method via EL.
    e.g.
    rendered="#{PERUserInfo.trainee}"
    When I debug the jspx, the PERUserInfo.trainee method is called 4 times instead of once.
    We have noticed similar findings when using managed bean methods via the rendered property. i.e. calls getters multiple times.
    Any idea why this is happening?
    We are using JDeveloper v10.1.3, JHS v10.1.3 SU1.
    All comments appreciated.
    Cheers
    Denis

    Denis,
    There can be many reasons why your bean method is called multiple times; but I would consider this perfectly normal in any JSF application considering all the lifecycles and (possible) Partial Page Rendering that happens.
    The question is, by the way, more appropriate on the JDeveloper forum since it is not directly related to JHeadstart itself.
    Hope this helps,
    Evert-Jan de Bruin

  • Howto call a Javabean function from javascript

    Hi,
    I want to fill some properties from an object which can be chosen from a selection box. When an object is chosen, I want to fill the propertie fields of the chosen object. How can I do this? Can I call from a 'onChange' a javabean function? or do I have to call a javascript function which calls a javabean function?
    Thanks in advance..
    Hugo Hendriks

    Actually, in a way you can call a bean method from a javascript function. But it's not really the bean method that is called for but the value it should have returned at the server side.
    Take a look at this example:
    <%@ page language="java"
    %>
    // list is a Vector containing a collection of "set & get-beans" retrieved through a db query
    <jsp:useBean id="list" class="java.util.Vector" scope="request" />
    <%
    Iterator itr = list.iterator();
    MyBean mb = new MyBean();
    %>
    <head>
    <script>
    var limit = <%=list.size()%>;
    function fillTextArea(theButton){
    for(a=0;a<limit;a++){
    <%
    while(itr.hasNext()){
    mb = (MyBean)itr.next();
    %>
    if(this.name=="bt1")
    document.theForm.ta.value += "<%=mb.getValue1()%>";
    else
    document.theForm.ta.value += "<%=mb.getValue2()%>";
    <%
    %>
    </script>
    </head>
    <body>
    <form name="theForm">
    <textarea name="ta" cols="50" rows="20"></textarea>
    <br>
    <br>
    <input type="button" name="bt1" value="click me" onclick="javascript:fillTextArea(this)">
    <input type="button" name="bt2" value="...or me" onclick="javascript:fillTextArea(this)">
    </form>
    </body>
    </html>
    The result of this will be a javascript function containing code for each element in the vector but that will be accessable in the client side.
    Of course this could render in large jsp pages being returned if the list vector is large, but sometimes this could be preferred against making a new servlet request each time.
    /Rickard

  • How can I call a web service using JAVAscript in LCD

    hi guys,
         I know it can call a WSDL in LCD, but I have not any WSDL web service , and I have a REST web service ,how can I call this REST web service in LCD? I checked some documents and found nothing...if it's possible that it can call a REST web service using JAVAScript code, I mean I can program some code to call this web service ?
    thanks,
    Jesse

    Hi Jesse,
    You can do GET, PUT and POST using FormCalc, so you should be able to access a REST web service. 
    There is a example of accessing a RSS feed in this thread, http://forums.adobe.com/message/5695433#5695433
    Regards
    Bruce

  • How can i call a bean methos using h:commandlink or h:commandButton?

    Hi
    i want to call a methos in the bean class throught h:commandbutton action
    my code is
    <h:commandLink action="#{sample.tryStuff1}" immediate="true" rendered="true">
    <h:outputText value="add" />
    </h:commandLink>
    <h:commandButton id="ad"
    action="#{sample.tryStuff1}"
    immediate="true"
    value="add"
    type="SUBMIT"/>
    what does immediat do here
    i am trying both ways but its not calling the methosd.
    what am i doing wrong?
    my config file
    <managed-bean>
    <description>sample</description>
    <managed-bean-name>sample</managed-bean-name>
    <managed-bean-class>com.actsys.web.sample</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    please help
    thansk in advance

    have you tried the following?
    <h:commandLink value="add" action="#{sample.tryStuff1}"  />Also, it might be good to know if you are actually getting to the action method tryStruff1, what does sys.out show if you have it in the first line of the action method?
    If you are getting to the action method, then there is probably an issue with your navigation handler.

  • Urgent - can't set managed bean value using a form, getting null

    I have a form with a bean -- unbelievably, I can't get the values entered into the form by the user to get stored into the bean. Everything is null... I've looked at a zillion examples, posts and compared etc...yet still can't see what is missing.
    Here's part of a trace :
    [cc]Dec-31 01:25:02 ApplicationImpl - Created bean resourceBean successfully
    [cc]Dec-31 01:25:02 ApplicationImpl - Storing resourceBean in scope request
    [cc]Dec-31 01:25:02 VariableResolverImpl - resolveVariable: Resolved variable:id=null name=null
    [cc]Dec-31 01:25:02 ValueBindingImpl - getValue Result:id=null name=null
    [cc]Dec-31 01:25:02 ValueBindingImpl - -->Returning id=null name=null
    If you have any ideas, please let me know--it seems just as I solve one JSF issue, I run into another on unexpectedly simple things.
    Here's the ResourceBean.java, the bean-config.xml and my jsp.
    package com.intalio.qa.tcm.view.beans;
    import java.util.Map;
    import javax.faces.context.FacesContext;
    import javax.faces.model.SelectItem;
    import org.apache.log4j.Logger;
    import com.intalio.qa.exceptions.DuplicateIdException;
    import com.intalio.qa.tcm.model.Resource;
    import com.intalio.qa.tcm.view.builders.ResourceBuilder;
    import com.intalio.qa.tcm.view.util.FacesUtils;
    * Resource backing bean.
    public class ResourceBean extends RootBean {
         * Class logger
         public static final Logger LOG =
              Logger.getLogger(ResourceBean.class);
    * The Resource id
         private String id = null;
         * The Resource name
         private String name = null;
    * Description
    private String description= null;
         * the resource type id associated with the Resource
         private String resourceTypeId= null;
         private static SelectItem[] resourceTypeIds = new SelectItem[] {
              new SelectItem("External Software"),
              new SelectItem("Hardware"),
              new SelectItem("Intalio Product Software"),
              new SelectItem("Machine - Dual CPU"),
              new SelectItem("Machine - CPU Single"),
              new SelectItem("Memory - UNIX"),
              new SelectItem("Memory - Windows") };
    * @return Returns the resourceTypeIds.
    public SelectItem[] getResourceTypeIds() {
    return resourceTypeIds;
    * @param resourceTypeIds The resourceTypeIds to set.
    public void setResourceTypeIds(SelectItem[] typeIds) {
    resourceTypeIds = typeIds;
         * Default constructor.
         public ResourceBean() {
    super();
    init();
         * Initializes ResourceBean.
         * @see RootBean#init()
         protected void init() {
         /*True, but I'd strongly recommend instead using:
    FacesContext fContext = FacesContext.getCurrentInstance();
    Map requestParams = fContext.getExternalContext().getRequestParameterMap();
    String companyId = (String) requestParams.get("companyID");
    The getRequest(), getSession(), and getContext() methods of ExternalContext should only be used as a last resort.*/
         * Backing bean action to update Resource.
         * @return the navigation result
         public String updateAction() {
              LOG.info("updateAction is invoked");
              try {
                   Resource Resource = ResourceBuilder.createResource(this);
                   LOG.info("ResourceId = " + Resource.getId());
              //     viewServicesManager.getResourceService().updateResource(Resource);
              } catch (Exception e) {
                   String msg = "Could not update Resource";
                   LOG.error(msg, e);
                   FacesUtils.addErrorMessage(msg + ": Internal Error.");
                   return ActionResult.FAILURE;
              LOG.info("Resource with id of " + id + " was updated successfully.");
              return ActionResult.SUCCESS;
         * Backing bean action to create a new Resource.
         * @return the navigation result
         public String addAction() {
              try {
                   Resource resource = ResourceBuilder.createResource(this);
    LOG.info("resource created: " + resource.getName() + " with typeId = " + resource.getResourceTypeId());
                   viewServicesManager.getResourceService().saveResource(resource);
              } catch (DuplicateIdException de) {
                   String msg = "This id already exists";
                   LOG.info(msg);
                   FacesUtils.addErrorMessage(msg);
                   return ActionResult.RETRY;
              } catch (Exception e) {
                   String msg = "Could not save Resource";
                   LOG.error(msg, e);
                   FacesUtils.addErrorMessage(msg + ": Internal Error");
                   return ActionResult.FAILURE;
              String msg = "Resource with id of " + id + " was created successfully.";
              LOG.info(msg);
              return ActionResult.SUCCESS;
         * Backing bean action to delete Resource.
         * @return the navigation result
         public String deleteAction() {
              LOG.info("deleteAction is invoked");
              try {
         //          Resource Resource = ResourceBuilder.createResource(this);
         //          viewServicesManager.getResourceService().deleteResource(Resource);
                   //remove the ResourceList inside the cache
    //               FacesUtils.resetManagedBean(BeanNames.RESOURCE_LIST_BEAN);
              } catch (Exception e) {
                   String msg = "Could not delete Resource. ";
                   LOG.error(msg, e);
                   FacesUtils.addErrorMessage(null, msg + "Internal Error.");
                   return ActionResult.FAILURE;
              String msg = "Resource with id of " + id + " was deleted successfully.";
              LOG.info(msg);
              FacesUtils.addInfoMessage(msg);
              return ActionResult.SUCCESS;
         public String getId() {
              return id;
         * Invoked by the JSF managed bean facility.
         * <p>
         * The id is from the request parameter.
         * If the id is not null, by using the id as the key,
         * the Resource bean is initialized.
         * @param newQueryId the query id from request parameter
         public void setId(String newId) {
              LOG.info("setId " + newId);
              id = newId;
         public String getName() {
              return name;
         public void setName(String newName) {
              name = newName;
         public String getDescription() {
              return description;
         public void setDescription(String newDescription) {
              description = newDescription;
         public String getResourceTypeId() {
              return resourceTypeId;
         public void setResourceTypeId(String newResourceTypeId) {
              resourceTypeId = newResourceTypeId;
         public String toString() {
              return "id=" + id + " name=" + name;
         <!-- view -->
         <managed-bean>
              <description>
                   Managed bean
              </description>
              <managed-bean-name>applicationBean</managed-bean-name>
              <managed-bean-class>
                   com.intalio.qa.tcm.view.beans.ApplicationBean
              </managed-bean-class>
              <managed-bean-scope>application</managed-bean-scope>
              <managed-property>
                   <property-name>viewServicesManager</property-name>
                   <value>#{viewServicesManagerBean}</value>
              </managed-property>
              </managed-bean>
         <managed-bean>
              <description>
                   View service manager impl for business services
              </description>
              <managed-bean-name>viewServicesManagerBean</managed-bean-name>
              <managed-bean-class>
                   com.intalio.qa.tcm.view.beans.ViewServicesManagerBean</managed-bean-class>
              <managed-bean-scope>application</managed-bean-scope>
         </managed-bean>
         <managed-bean>
              <description>
                   Backing bean that contains product information.
              </description>
              <managed-bean-name>resourceBean</managed-bean-name>
              <managed-bean-class>
                   com.intalio.qa.tcm.view.beans.ResourceBean
              </managed-bean-class>
              <managed-bean-scope>request</managed-bean-scope>
              <managed-property>
                   <property-name>viewServicesManager</property-name>
                   <value>#{viewServicesManagerBean}</value>
              </managed-property>
         </managed-bean>
    </faces-config>
    <f:view>
         <h:form id="createResourceForm" target="dataFrame">
              <h:outputText value="#{applicationBean.dummyVariable}" rendered="true" />
              <div align="center">
              <head>
              <link href="../../css/stylesheet.css" rel="stylesheet" type="text/css">
              <FONT color="#191970" size="4" face="Arial">Resources View</FONT>
              </head>
              <table style="margin-top: 2%" width="35%" cellpadding="10">
                   <div align="left">
                   <FONT color="#191970" size="3" face="Arial">Update Resources </FONT>
                   </div>
                   <tr>
                        <td align="center" valign="top" align="center" style="" bgcolor="white" />
                        <table>
                             <tbody>
                                  <tr>
                                       <td align="left" styleClass="header" width="100" />
                                       <td align="left" width="450" />
                                  </tr>
                                  <tr>
                                       <td align="right" width="100"><h:outputText value="Id" /></td>
                                       <td align="left" width="450"><h:inputText value="#{resourceBean.id}" id="id"/> <h:message for="id" styleClass="errorMessage" /></td>
                                  </tr>
                                  <tr>
                                       <td align="right" width="100"><h:outputText value="Name" /></td>
                                       <td align="left" width="450"><h:inputText value="#{resourceBean.name}" id="name" /> <h:message for="name" styleClass="errorMessage" /></td>
                                  </tr>
                                  <tr>
                                       <!--td align="right" width="100" valign="bottom"><h:outputText value="Type" /></td>
                                       <td align="left" width="550"><h:selectOneMenu>
                                            <f:selectItems value="#{resourceBean.resourceTypeIds}" />
                                       </h:selectOneMenu> <h:outputText value="#{resourceBean.resourceTypeId}" id="dresourceTypeId" /> <h:message for="resourceTypeId" styleClass="errorMessage" />
                                       </td>
                                  </tr>
                                  <tr>
                                       <td align="right" width="100" valign="bottom"><h:outputText value="Description" /></td>
                                       <td align="left" width="450"><h:inputText value="#{resourceBean.description}" id="description" size="96" /> <h:message for="description" styleClass="errorMessage" /></td>
                                  </tr>
                             </tbody>
                        </table>
         </h:form>
         </td>
         <!-- END DATA FORM -->
         <!-- BEGIN COMMANDS -->
         <td width="30%" align="left" valign="top"><h:form id="buttonCommandsForm">
              <h:panelGroup id="buttons">
                   <h:panelGrid columns="1" cellspacing="1" cellpadding="2" border="0" bgcolor="white">
                        <h:commandButton value="Add" style="height:21px; width:51px;font-size:8pt; font-color: black;" action="#{resourceBean.addAction}">
                        </h:commandButton>
                        <h:commandButton id="deleteCB" value="Delete" style="height:21px; width:51px;font-size:8pt" action="#{resourceBean.deleteAction}">
                        </h:commandButton>
                        <h:commandButton id="spaceFillerButton" style="height:21px; width:51px;font-size:8pt;background-color: #ffffff;color: #ffffff;border: 0px;">
                        </h:commandButton>
                        <h:commandButton id="saveCB" value="Save" style="height:21px; width:51px;font-size:8pt" action="#{resourceBean.saveAction}">
                        </h:commandButton>
                        <h:commandButton id="updateCB" value="Update" style="height:21px; width:51px;font-size:8pt" action="#{resourceBean.updateAction}">
                        </h:commandButton>
                   </h:panelGrid>
              </h:panelGroup>
         </h:form> <!-- end buttons --></td>
         </tr>
         </table>
         <HR align="center" size="2" width="60%" />
         <!-- data table -->
         </div>
    </f:view>
    THANKS.
    -L

    I solved this.
    Since I was testing the action code only, I didn't define a navigation entry corresponding to the action string returned for this button:
    <h:commandButton value="Add" style="height:21px; width:51px;font-size:8pt; font-color: black;" action="#{resourceBean.addAction}">
    </h:commandButton>After I added a nav definition, it worked. I don't know why at this point. I suspect a key step in the lifecycle was pre-empted...someone else can probably explain why. If I get a chance to research it after I'm done with my project, I'll update this post.
    Thanks.
    -L

  • Calling JSP bean function on button OnClick

    Hi-
    A NewBie question....
    I have a .jsp page and supporting .java bean.
    I registed the bean in .jsp page using <jsp:useBean ...>
    I want to fire a function defined in that bean on the click of a button which is defined in the .jsp page
    So I am doing something like this... seems like not the correct way to do since it fires this script all the time, not just when the button is clicked.
    <input name='click1' type='Submit' value='Click1' onClick='<% testBean.click1Clicked (); %>'/>
    Thanks for your help.

    Hi Kishor-
    Thanks for the reply.
    I realize that might be the case, as u explained in your two points.
    so now I have created a hidden input field and use it's value as a way to communicate between javascript and jsp. and in bean's function I check the value of this hidden field, which will be set by the OnClick's javascript and then proceed accordingly.
    Is this the correct way to accomplish what I am trying to?
    Thanks again

  • How to call a codebehind function from javascript

    Hi, i need some help calling a function in my .ascx.cs of a visualwebpart for SP2013 from JS.
    The idea is to execute a function when a datepicker date is selected
    <script type="text/javascript" src="../_layouts/15/jQuery/jquery.min.js"></script>
    <script type="text/javascript" src="../_layouts/15/jQuery/bootstrap.min.js"></script>
    <script type="text/javascript" src="../_layouts/15/jQuery/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript">
    $(function () {
    $('#datetimepicker4').datetimepicker()
    .on('changeDate', function callWebMethod() {
    $.ajax({
    type: "POST",
    url: "Visualizador.ascx/Testing",
    data: "{}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (data) {
    alert("OK");
    error: function (jqXHR, textStatus, errorThrown) {
    alert("Error");
    </script>
    The problem is that it always return the "Error" alert.
    The functions name is "Testing" (in Visualizador.ascx.cs), the project name is "BuscadorCumple" and the VisualWebPart is "Visualizador"
    I´ve tried with the PageMethods but i can´t add a ScriptManager because the MasterPage of the site has already one, and only one ScriptManager is allowed. So if i could set the EnablePageMethods to true it would be great (to use the PageMethods), or just
    try to fix the js function from above.
    THANKS IN ADVANCE
    ------------------------------------------------Update----------------------------------------------
    Here is the method i´m using to test it, inside Visualizador.ascx.cs
    [WebMethod]
    public static void Testing()
    Response.Write("<script>alert('HW')</script>");

    Methiod should be like this
    [WebMethod]
      public static
    string GetData()
        string str="hi";   
    return str;
    Calling is like this
    $.ajax({
    type: "POST",
    url: "PageName.aspx/MethodName(GetData)",
    data: "{}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(msg) {
    // Do something.

  • Cannot call CS SDK function from javascript

    Hi!
    I'm trying it in Illustrator. I'm trying to call the actionscript code from ExtendScript.
    I read this two articles: http://forums.adobe.com/thread/634947?tstart=0 and http://cookbooks.adobe.com/post_Communicating_between_JavaScript_and_the_CS_SDK_us-17383.h tml
    They all propose the same technique, like var jsxInterface:HostObject = HostObject.getRoot( HostObject.extensions[ 0 ] )
    I'm using the external script (not an embedded one) I added my script to manifest file:
    <ScriptPath>./script.jsx</ScriptPath>
    And then trying to call jsxInterface.init( this ) which is defined in my jsx file. But with no luck. I just got an exception.
    It seems like  jsxInterface.init is not defined after all (of course, I defined it in .jsx file)
    Is there a way to call a CS SDK function from external ExtendScript script in Illustrator? Or a way to pass "this" object
    to javascript for a later access?
    Thank you!

    Hi Anastasiy,
    Weird!
    It looks like it does not work during a creationComplete event.
    If you change your code to intitialize in a function, and call that function outside the creationComplete event, it works fine. Like so:
    ExtendScript:
    function initializeJSX(){
      try
        alert('SUCCESS! foregroundColor object = '+app.foregroundColor);  } catch(e)
        alert('ERROR: '+e.description);
    MXML:
    <?xml version="1.0" encoding="utf-8"?>
    <csxs:CSXSWindowedApplication
        xmlns:mx="http://www.adobe.com/2006/mxml"
        xmlns:csxs="com.adobe.csxs.core.*"
        layout="absolute" historyManagementEnabled="false"
        creationComplete="initApplication(event)">
        <mx:Script>
            <![CDATA[
                [  Embed (source=  "../assets/test.jsx" , mimeType=  "application/octet-stream" )]
                private static var _testJSX:Class;
                [Bindable]
                private var hostName:String = HostObject.mainExtension;
                private var jsxManager: HostObject;
                private function initApplication( e: Event ):void
                    jsxManager = HostObject.getRoot(HostObject['extensions'][0]);
                    jsxManager.eval( new _testJSX().toString() );
            ]]>
        </mx:Script>
        <mx:VBox height="100%" width="100%" verticalAlign="middle" horizontalAlign="center">
            <mx:Button label="Run PS code" click="jsxManager.initializeJSX()" enabled="{hostName.indexOf('photoshop') > -1}"/>
        </mx:VBox>
    </csxs:CSXSWindowedApplication>
    I presume you can get what you what by calling the function via a timer or some other event...
    Harbs

Maybe you are looking for

  • How to change default 10.0.1.1 address

    I have a sticky problem i have been unable to figure out. The VPN service from my company uses the exact same IP address as the default Airport base station IP. This is a problem because the I cannot connect to the VPN server with it like this. The c

  • NHL app not working

    I have gamecenter live and for some reason on the Apple TV app it won't connect. It allows me to see what games are playing but when I try to watch a game it says that I must wither login or restore, if I hit restore it says I can't connect to iTunes

  • Passing values to report and prompting.

    I have a multivalue parameter that I pass a list of values to based on permissions. I still need the person running the report to be ablle to pick and choose what they want to see on the report.  When I pass the values to the parameter it turns off p

  • Is there a template for gst

    I'm using numbers mostly on iPad i could use my iMac if needed,is there a template designed for gst

  • HT204370 can I download onto SD card and play movie in the "in car" dvd players (which have a SD port)

    I have a new in car dvd player (one in the head rests). It says that you can put movies on a SD card and play them rather than using DVD's. In itunes, can I download movies onto an SD card?