Struts/UIX/JavaScript Child Windows

I have seen an example of using JavaScript to execute a Struts action mapping that is implemented using UIX. I would like to know if this will work in UIX.
HC_doOpenRemote('<html:rewrite forward="item"/>');
This function would be a simple JavaScript function that would cause a child window to be opened and cause the forward to the Struts action item to be executed resulting in the page being displayed.
Is this possible in UIX? If so, please outline the steps to do it.
By the way I got this example out of the book Struts In Action by Ted Husted.

Thanks Adam for the example. The "event" part of the code helped me to do what I needed. (By the way, if there is a more direct way to do this let me know.)
The issue for me is that the server does not know when a child window page is opened and this causes the blackhole as far as Struts is concerned. Working with Struts events is important because it provides easy integration with BC4J through the BC4JRequestProcessor.
So your example suggested that I should implement an UIX page that strictly handles events that are recieved from a page that is opening the child window.
Each event is named differently and makes a call to a Struts event. (The UIX event handler is the only place that UIX can deal with Struts events.)
Here is some example code:
The main.uix page has the following links:
<link text="Open UIX page (events only), transfer control through Struts event. #1">
<!-- Let's send a request to open a window with an initial event -->
<boundAttribute name="onClick">
<concat>
<fixed text="openWindow(self, '"/>
<ctrl:pageURL name="/pages/transferwindow" event="GoToRealPage1"/>
<fixed text="');return false"/>
</concat>
</boundAttribute>
</link>
<link text="Open UIX page (events only), transfer control through Struts event. #2">
<!-- Let's send a request to open a window with an initial event -->
<boundAttribute name="onClick">
<concat>
<fixed text="openWindow(self, '"/>
<ctrl:pageURL name="/pages/transferwindow" event="GoToRealPage2"/>
<fixed text="');return false"/>
</concat>
</boundAttribute>
</link>
The transfer.uix page only handles UIX events passed in from JavaScript:
<?xml version="1.0" encoding="windows-1252"?>
<page xmlns="http://xmlns.oracle.com/uix/controller"
xmlns:ctrl="http://xmlns.oracle.com/uix/controller"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:struts="http://xmlns.oracle.com/uix/struts">
<content>
<!--
This is a UIX page that is used only to transfer control to a Struts
event. This is important to Struts/UIX applications that use child
windows since the Struts controller is on the server side and child
windows are launched on the client side.
-->
</content>
<handlers>
<!-- Add EventHandlers (<event> elements) here -->
<event name="GoToRealPage1">
<struts:action path="/realchild1.do"/>
</event>
<event name="GoToRealPage2">
<struts:action path="/realchild2.do"/>
</event>
</handlers>
</page>
And then the struts-config.xml:
<action path="/realchild1"
type="org.apache.struts.actions.ForwardAction"
parameter="/pages/realwindow1.uix">
</action>
<action path="/realchild2"
type="org.apache.struts.actions.ForwardAction"
parameter="/pages/realwindow2.uix">
</action>

Similar Messages

  • Communicating between the parent and child windows in Struts

    Hey,
    I would like to know what is the best way to communicate between the child and parent windows on a struts based web application. For example i have a struts based jsp page. I call a child window from this page. On the child window i select few values and they have to be shown on the parent. What is the best way to achieve this in struts.
    Thanks
    in advance.
    KM

    The only way to do this without Javascript is to have the child window have a form and the form has a target defined as the name of the parent window (how to name it without using frames or having it open from another window, I'm not sure), and when you submit the form, it'll submit to the parent window/frame and you can process that form on the server and return the same parent page with the selected values.
    Otherwise, you need Javascript to set form values to "window.opener" from the child window.
    Either way, it's not really a Struts thing, technically.

  • REPRODUCABLE crash: javascript closing of child window

    I can consistently crash Safari (2.0.2) when closing a child window through javascript. All other browsers operate as expected. An example of this can be found here:
    http://www.kevinvaughan.org/testpopup.html
    Click the test popup link, and click cancel or ok. Sometimes Safari crashes on the first window close, sometimes it takes 20 times of bringing up the window, but it always crashes in the process of closing the child window.
    Has anyone else experienced similar problems?

    It seems clear to me at least that last batch of upgrades (I suspect QT 7.03) have altered something in Safari's DNA. I have frequent crashes when opening or closing windows, moving within websites, etc. It is not an issue related to 10.4 because I have 10.3.9 and have same problems. If you disable javascript, viola, crashing ceases, along with much compatibility/usability. I see little indication that Apple regards this as a problem, but Safari has become useless to me and apparently many others. I await their fix or somebody else's wise suggestions.

  • Using Struts, On submit button in child window, its opening new window.

    We are developing a project using Struts and BC4J. I am opening a child window(window.showmodaldialog) from main window using struts action. Actually Child window is a search kind of page. User will enter the search criteria and press the sumbit button. I want to display the search result in the same window using datatable when jboevent="submit". But its opening new window and displaying the result in that. However in <html:form>, Even I tried the target="_self".
    I am not sure wether the associated action in the <html:form> is forcing to open a new window.
    Similar kind of thing I am able to achieve in other similar search page, it its not a child window.
    Please let me know what I am missing.
    Thanks,
    Arvind

    So you want the search window to submit back to itself so you see the search field and a result list..?
    In pure Struts terms either using "_self" or the name of the popup window in the <html:form> tag will do the trick
    You need to make sure that the inital window that you created as the popup search window has a name in the first place - can you specify this with showModalDialog()?
    BTW isn't showModalDialog an IE only feature...

  • Reading child window contents using Javascript

    Hi Friends,
    is it possibel to read the contents of the child window opened from a javascript.for example am opening a window using Window.open function in javascript, after opening the window can i read the contents ?If so how can anyone help in this.
    Thanks
    Vishy

    Am sorry , but there are courteous ways to say this.
    Anywya never mind .SOrry if i have taken more traffic
    with this irrelevant questionI'm not trying to be rude. I'm just suggesting that you'll get better replies on a JavaScript forum.

  • Accessing variables from Child window from the parent window

    Hi All,
    I am in the process of integration of payment gateway, here I am opening payment gateway page as a new window, and after payment is done then I need access one variable which is hidden variable ...any ideas

    Have a hidden field/js variable in the parent page. Add a Javascript function in parent page which would take a value as parameter and set in the parent page hidden field/js variable. In the child window, you can invoke the method from script block as window.opener.setValue(document.getElementById('CHILD_WINDOW_HIDDEN_FIELD_ID').value)
    For Javascript related questions, please visit Javascript forums.

  • Session expiration issue with parent and child window

    Hi,
    We have two applications (App1 - Implemented using JSF, Spring and Hibernate and App2 -Implemented using Spring MVC, Spring JDBC).
    I have implemented 'Test Access Content' functionality in App1.
    First admin user (Role- Manager) needs to login to App1
    As part of 'Test Access Content' functionality, he enters URL with encrypted key and click 'Test Access' button.
    It opens new window (implemented using java script - window.open) and hits spring controller of App2.
    In spring controller of App2, I am decrypting the key to get user details. After that i am setting user details in session, constructing final URL to display actual content.
    Problem is parent window maintains session till child window renders response. Once child window renders response, parent window loosing session.
    So, if i click any button in parent window after child window renders response, it displays login page as there is no session for parent window.
    Please note that App1 and App2 are sharing same domain. only context paths are different for both apps (app1 and app2).
    Any suggestions on this issue are much appreciated. Please let us know if you have any questions.

    Hi,
    When you open a child window from parent window then you can access child data in the parent window through javascript.
    We have a main web page. There are quite many links on it from which >user can open new web pages but the data is saved when the submit >button on the main page is clicked. Also data that user entered on the >other sub pages is not displayed in the main window.
    1 is this a case of parent and child window.case 1 When you are submitting the main page you need to run javascript function and get data from child windows and save that to database or session. next time when you are displaying the main window you need to query session or database to display the child window data in the main window.
    Case 2> closing child window and you need data in the parent. This can be done in two ways.
    1> When you are closing the child window populate some variables of the main window using javasript.
    2> Save the values in the database or session and refresh the main window and extract data from database or session
    Where should the data be saved that user enetered on the sub pages as the data is not shown in the main page - should it be stored in the session?It is design decision. You can store data in either session or database when you are closing the child window. But ifyou are saving the data on the main page then you can populate main page with child windows data using javascript. Save the data t database when main window data is saved. Depends on business requirements.
    In short if you are saving child windows data in session or database then you need to refresh main screen to pull that data otherwise populate main screen using javascript.
    I hope i answered your questions :) best of luck

  • Question about struts inside javascript variable

    Hi, actually i'm using a struts + javascript to create HTML code that i use inside a popup window...
    My (working) code is:
              idoc="";
              /* var cols = parent.document.getElementById('rowA').getElementsByTagName('THEAD')[0].getElementsByTagName('TH'); */
              var idoc='<html:form styleId="InsertNewItem" action="/nw/insertnewitem.do?target='+parent.newPop.action+'">';
              idoc+='<TABLE><TBODY>';
              var hiddenForm = getParentObj('hidden_data_form');
              var cols = hiddenForm.getElementsByTagName('INPUT');
              var test;
              test="cippa";
              for(k = 0; k < cols.length; k++) {     
                   if(cols[k].id.substring(0,3) == "hh_")
                        idoc += "<TR><TD>";
                        idoc += cols[k].id.substring(3);
                        idoc += "</TD><TD>";
                        idoc += '<html:text property="'+cols[k].id+'" value=""/>';
                        idoc += "</TD></TR>";
              idoc+='</TBODY></TABLE>';
              idoc+='</html:form>';
              var towr = document.getElementById("subwin_body");
              towr.innerHTML = idoc;
    The problem is when i try to add a <html:select> to the code, more precisely i added just before the end of the table these lines:
              idoc += "<TR><TD>Ditta:";
              idoc += "</TD><TD>";
              idoc += '<html:select property="ditta_id">';
              idoc += '<html:options collection="sel_ditta_list" labelProperty="label" property="value"/>';
              idoc += '</html:select>';
              idoc += "</TD></TR>";          
    ... but i cannot get it to work because struts seems to make some mistake with quotes and in javascript console window i get this error:
    Error: unterminated string literal
    File source: http://localhost:8180/nw/jsp/insertNewItemOperatore.jsp
    Row: 121, Column: 10
    Source Code:
    idoc += '<option value="1">1</option>
    (note the missing ending single-quote)
    I can't understand why because with <html:text> field the same "trick" works fine... any ideas?
    Thanks in advance
    Luca
    Message was edited by:
    spallared

    can you post all of your source code for the .jsp and then try running the page and once it fails do a View Source and then paste in all the generated code so that we can look at that as well.
    i'm not totally positive but i have a pretty good feeling what is going wrong. the struts optionsCollection tag will render a bunch of <option> elements but print a newline after each one, which means you probably end up with something like
    var whatever = '<option ...>.........<option>
    <option ...>.........<option>
    <option ...>.........<option>
    <option ...>.........<option>';
    correct? if so, that is not valid javascript.
    Message was edited by:
    den2681

  • Calling a Function in the Parent Window from the Child Window

    QUESTION: How do I call a function resident in the parent
    window from a child window?
    BACKGROUND
    I have a JavaScript function resident in the parent window
    that reformats information obtained from the Date object and writes
    the result to the parent window using the document.write( ) method.
    I would like to call this function from the child window and have
    it write to the child window instead. Is this possible? If not,
    must I rewrite the entire function and nest it in the below code?
    If so, what is the proper form of nesting?
    CODE: The code that creates and fills the child window is
    provided below. The highlighted area indicates where I would like
    to enter the information from the function resident in the parent
    window. I have tried every imaginable permutation of code that I
    can imagine and nearly destroyed my parent document in the process.
    I am very happy that I had a back-up copy!
    function openCitationWindow() {
    ciDow = window.open("", "", "width=450, height=175, top=300,
    left=300");
    ciDow.document.write("A proper way to cite a passage of text
    on this page:<br /><br />Stegemann, R. A. 2000.
    <cite>Imagine: Bridging a Historical Gap</cite>. " +
    document.title + ". [<a href='" + location.href + "'
    target='_blank'>online book</a>] &lt;" + location.href
    + "&gt; (");
    MISSING CODE;
    ciDow.document.write(").<br /><br /><input
    type='button' value='Close Window' onclick='window.close()'>");
    ciDow.focus();

    Never mind - I was doing something very stupid and wasn't
    calling the function as a method of a movie clip. I was simply
    calling checkTarget(event) rather than
    event.currentTarget.checkTarget(event); which seems to work.

  • Calling a function in child window from parent window

    Hi,
    How can I call a method in child window from parent window in adobe air using javascript. In the following example I need to call mytest() function in
    child.html from parent.html file.
    Thanks,
    ASM
    //parent.html
    <HTML><HEAD>
    <script>
    var initOptions = new air.NativeWindowInitOptions();
    initOptions.type = air.NativeWindowType.NORMAL;
    initOptions.systemChrome = air.NativeWindowSystemChrome.STANDARD;
    var bounds = new air.Rectangle(300, 300, 600, 500);
    var html2 = air.HTMLLoader.createRootWindow(false, initOptions, false, bounds);
    var urlReq2 = new air.URLRequest("child.html");
    html2.load(urlReq2);
    html2.stage.nativeWindow.activate();
    html2.window.mytest();       //NOT WORKING
    </script>
    </HEAD><body></body></HTML> 
    // child.html
    <HTML><HEAD>
    <script>
    function mytest()
      air.trace("in child window");
    </script>
    </HEAD> <body></body></HTML>

    I suspect your problem is that the child window hasn't been created by the time you call the function in the parent.Loading the content is an asynchronous processes -- AIR doesn't stop executing your code until the window has finished loading child.html. So, you will need to add an eventlistener to html2 and call the function from there:
    html2.addEventListener( "complete", onChildLoaded );
    function onChildLoaded( event )
         html2.window.mytest();

  • How to parse parameter from child window to parent window in JSP

    I have two JSP i.e. course1.jsp and course2.jsp. I would want to find out how I could parse the parameter/value from child window to the parent window when the child window get closed.
    What I am trying to do is actually a file upload process. The child windows will open for user to upload the file, and when close, the file name will be parse into the parent form for database update. Is this something possible at all? or is there any other better approaches.
    Thank you.
    These are the two files:
    --------course1.jsp ------------
    Attach File <p>
    <FORM name="courseForm" action="course2.jsp" method="post" enctype="multipart/form-data">
    <TABLE cellSpacing=1 cellPadding=3 border=0 WIDTH=500>
    <TR >
    <TD>
    <input type="text" NAME="f_file_name" size="30" VALUE="this value should be taken from child windows">
    get file name
    <p>
         <INPUT class="buttons" TYPE="submit" NAME="submit" VALUE="Submit">
    </TD>
    </TR>
    </TABLE>
    </FORM>
    ---- course2.jsp -------
    <%
    String filename = "this is the string needs to go back to parent windows when I click on close";
    %>
    <p>
    close

    In course2.jsp, you have to write some javascript code to reload the parent window document to reload the document with an added parameter. But, instead of doing this, you can also do simple thing; in course2.jsp, you can reference course1.jsp controls via javascript object, "parent". On closing event of course2, you can write:
    parent.courseForm.f_file_name.text = '<%=filename%>' ;
    window.close() ;
    But for this to work, you must open your course2.jsp document thru window.open() function instead of simple hyper link (as you did thru ).
    So, modify the hyperlink line like below:
    get file name
    Hope it helps.

  • Communicating from child window to parent window

    I'm been trying to communicate a child page with a parent page using window.opener, but I can't make it work. This is an example of what I've been working on (from child to parent). Any idea?
    <$-HTML>
    <$-HEAD>
    <$-TITLE>
    Ventana hija
    <$-/TITLE>
    <$-SCRIPT Language="javascript">
    function cerrar() {
         alert(window.opener.document.url())
         window.opener.frmPadre.field1.Value = document.frmHijo.field1.value;
         window.opener.frmPadre.field2.Value = document.frmHijo.field2.value;
         window.opener.frmPadre.field3.Value = document.frmHijo.field3.value;
         document.frmHijo.valor.value = document.frmHijo.field1.value;
         window.opener.frmPadre.btnSubmit.focus();
    <$-/script>
    <$-/HEAD>
    <$-BODY>
    <$-form name = frmHijo>
    <$-input type = text name = field1><$-br>
    <$-input type = text name = field2><$-br>
    <$-input type = text name = field3>
    <$-input type = button name = btnSubmit Value = "DEVOLVER" onClick = cerrar()>
    <$-/form>
    <$-/BODY><$-/HTML>
    The parent window hast a form name frmPadre with those 3 fields.

    Javascript is not java, but here are a couple of tips for debugging:
    You can use the browser address bar to alert stuff
    ie : put this into the address bar of your browser and see what happens: javascript:alert("Hello world")
    I would recommend you progress like this - slowly building up the link until you find where you go wrong.
    In this case, I think you missed out a "document"
    javascript:alert(window.opener)
    javascript:alert(window.opener.frmPadre)
    javascript:alert(window.opener.document.frmPadre)
    javascript:alert(window.opener.frmPadre.field1)
    Also just as a tip, cross browser scripting is a lot easier to maintain if you limit your self to calling FUNCTIONS in other windows.
    ie rather than setting the values in the other windows textfields, call a function (with parameters) which does it.
    eg in this case it might be:
    window.opener.setPadreFields(document.frmHijo.field1.value, document.frmHijo.field2.value, document.frmHijo.field3.value)
    The function would take the parameters and put them in the appropriate place on the form.
    Doing it this way decouples the pages a little - you only interact with the other page via the function (single point of entry) and if you modify the page in the future (eg change the name of a field) it is much easier to find everywhere you need to do this.
    Hope this helps,
    evnafets

  • Problem in Passing the value from child window to Parent window.

    Hi Frenz,
    I have a requirement like this. i have to pass a value from child window to parent window to one test field. That text field is not a normal text field.
    It was created like the following as SQL query.
    select
    ''LNo,
    apex_item.text(25,'',0,15,
    'style="width:100px;" onblur="javascript:showUpsell(this.value);" onkeypress="javascript:validateKeyPress(event,this.value,this.id);" onkeyup="javascript:this.value=this.value.toUpperCase();" id="P37_ITEMNO"') ItemNo
    Now i want to pass a value to the Item no from child window.
    i wrote the java script like this,
    opener.document.forms[0].f25.value="100";
    It was not working..Any suggestions for that..
    Thanks in advance

    Dear Baaju,
    How do you redirect your control from Child to Parent window.
    If you use a button to do this, then you can set this value in the branching of page.
    Rana

  • Parent child window functionality using CFM

    In .cfm page I am trying to implement the following
    functionality
    I got a parent window contains a button.
    On button click a child window should get open.
    This child Window should get embed in that parent window
    (like MDI application)
    1)i.e While minimizing the parent window this child window
    should also get minimized
    2)While closing the parent window this child window should
    also get closed
    3) We should also be able to close the child window alone.
    4) If you double click on the title bar of the child window
    it should get maximized
    5) Again double click on the title bar of the child window it
    should get minimized.
    I tried with <embed> tag but it seems its for audio ,
    flash kind files.
    If we can use <embed> tag means whats should be the
    value of the "Type" attribute.
    waiting for your valuable information

    Window handlers and controls are generally a function of the
    browser and not really manipulatable using ColdFusion, as it runs
    on server-side only, not client-side. JavaScript would be more the
    thing to play with in this regard, although I don't think there is
    an "onClose" event handler.
    HOWEVER!
    All browsers have a security feature that prevents pop-up
    child windows from "hijacking" their parents window behaviors,
    including resizing, moving, changing the toolbars, closing, etc.
    This security feature cannot be bypassed, and is an integral
    hard-coded aspect of all modern browsers. I suspect that what you
    are looking to do may be impossible due to this one fact, unless
    someone knows a bypass.

  • Want to use popup child window

    Hi everybody.....
    In my page i have a button. on clicking this button another window is opened which contain only a single textarea and a button. I want to get the text (written in the text area) when user click on that button of the new window i come back to original window with that text information. how can i do this? i know that with DOM i can do in my jsp. but how? Can anybody know this?
    - Jignesh

    window.opener will give you a reference to the parent window.
    My preferred method is to write a javascript function inside the parent window which is called by the child window, rather than the child window directly accessing fields/properties on the main window.
      // in child.jsp
      var value = document.forms[0].txtInput.value;
      window.opener.callBackFunction(value)
      // in parent.jsp
      function callBackFunction(text){
        // do something with this text value

Maybe you are looking for

  • How do I update to photoshop camera raw 8.6 in PhotoshopCC

    When I try to edit a lightroom file in PhotoshopCC I get a message This version of lightroom may requiire the photoshop camera Raw plugin version 8.6 for full compatibility. Please update using Photoshop help menu. When I use photoshop help and click

  • Quick Time Player URL?

    I am new to using my I-Mac and am trying to access a radio station in Mali but am unable to do so. Unfortunately, it tells me I have an invalid URL. If anyone can shed some light on this for me and how to either establish a new URL or fix it so that

  • Oracle text contains and mixed queries

    Trying to optimize the following sql statement using oracle text.  When postal code is given, I would like to limit the contains to only filter the smaller subset.  Both of these queries produce the same results in the same amount of time with practi

  • DB size for HA replication

    Do you have any recommendation on the db file size for the HA replication? Let say I have 2TB of bekeley DB size. How long does it replicate to the slave? When a new node is added to the group, how long is to replicate 2TB of data? Also If I want to

  • I am having problems with Captivate 5.5 FITB q's.

    In preview, the 'incorrect' response appears despite the selected answers from the drop down menu being 'checked' as correct and being selected.  In addition, the learner does not see the word 'select' in the blank box - is this significant?  Any hel