No response due to long running Action classes

Hi,
I have a small issue in my application.
Please help providing the solution for the following problematic scenario faced in my application.
My project is generally a report generation project,
arch used: our-own architecture(similar to struts)
Server: deployed in tomcat server..
On clicking a button from X.jsp, it triggers the action with the request = REQ1
so in my configuration Xml file it checks for it and executes the corresponding Action classes and it should display the Presentation(Jsp)
What happens is , the action class execution is taking more than 10 min, becaz of which i am getting blank screen.
From the action to jsp , it is executing without any error, which i could see in the log files..
Actions taken:
improved the performance of the query, but cudnt reduce much time..
session time is 180min, and connection timeout set to an hr. - No change- It seems this doesnt have to do anything with this.
my Observance:
I guess, as per arch, it is executing till jsp, but it seems that HttpRequest is getting timedout becaz of long running actions.
Please help to find the cause and approach method to resolve this issue.
Note: no issues to wait till 10min.. but need to get the values (reports) in the screeen..
Thanks in advance.....

It sounds like either the server or perhaps a firewall is timing out after 5 minutes or so. If you can examine the log files for each such machine in the network, you might find that one is reporting a timeout. If this is the case, you can change the timeout to something greater than 5 minutes, but this is not advisable. Other applications should rightfully timeout if they 'hang' for more than 5 minutes or so and you don't want to interfere with that. One possible solution is to look up something like 'jsp keepalive' to see how to get the JSP page to periodically send a message to the server to keep the session alive using something like AJAX. I tried this and I couldn't find anything that worked. Another thing you can do is do performance tuning to speed things up, or only fetch a small subset of data for the user at a time by filtering (example: instead of returning the entire telephone book, have the user select A to Z for last name and only return the last name that begins with that letter. Another possibility is to cache the data and read from the cache. Then, periodically, refresh the cache from the database at say, midnight every night. Those are the only ideas I have.

Similar Messages

  • No display due to long running Actions

    Hi,
    I have a small issue in my application.
    Please help providing the solution for the following problematic scenario faced in my application.
    My project is generally a report generation project,
    arch used: our-own architecture(similar to struts)
    Server: deployed in tomcat server..
    On clicking a button from X.jsp, it triggers the action with the request = REQ1
    so in my configuration Xml file it checks for it and executes the corresponding Action classes and it should display the Presentation(Jsp)
    What happens is , the action class execution is taking more than 10 min, becaz of which i am getting blank screen.
    From the action to jsp , it is executing without any error, which i could see in the log files..
    Actions taken:
    improved the performance of the query, but cudnt reduce much time..
    session time is 180min, and connection timeout set to an hr. - No change- It seems this doesnt have to do anything with this.
    my Observance:
    I guess, as per arch, it is executing till jsp, but it seems that HttpRequest is getting timedout becaz of long running actions.
    Please help to find the cause and approach method to resolve this issue.
    Note: no issues to wait till 10min.. but need to get the values (reports) in the screeen..
    Thanks in advance.....

    Design is inappropriate.
    Long running processes, and specifically reports, shouldn't rely on session connections.
    Instead the following should be done.
    - Process initiation (user request), post a task request to a task request queue. Return a unique identifier to requestor.
    - Separate process processes tasks in the task queue.
    - Requestor (such as a gui) periodically polls using the indentifier to see if the task is complete.
    - When the task is complete the requestor asks for the results (GUI displays them.)
    The problem with extending timeouts is that there are valid error scenarios where long timeouts will mean resources not returned to the system for long periods of time when they should have been.
    Per your current solution there is probably some other timeout somewhere. Could be several. The JSP forum might be a better place to ask where all of the possible timeouts could be.

  • Can't access icloud due to long running script

    keep getting this error message when logging on to icloud to access my email:
    can't access icloud due to long running script
    And if I do get logged into icloud and try to open the email application I can't open my email or any other applicationii.
    HELP

    Welcome to the Apple Community.
    Delete your mail account from Mail preferences and set it up again using the Mail Server Information.
    Some users have apparently encountered issues using this information in pre-Lion set ups (I haven't), Roger Wilmut has kindly provided instructions for those who find themselves with this problem.
    Entering iCloud email settings manually in Snow Leopard or Leopard
    Entering iCloud email settings manually in Tiger

  • Online redo logs fill-up due to long running SCM processes

    DB2 v9.7
    AIX v6.1 P570
    Running Standard SAP Code
    Going live with SCM system running SNP/DP GATP how can we avoid having our online redo logs fill-up due to long running processes (i.e., CTM. Process Chains, BOP, DP Runs) Need to know SAP Best Practice regarding this -
    Per our developers, BOP jobs performs commit when everything is processed and update table in one go at end, Hence not possible to perform commit regularly. Actually they will have to run BOP for 3200 material with 98000 sales order items.
    But after just running BOP for 40 material with 22000 sales orders line items we are getting DBIF_RSQL_SQL_ERROR + CX_SY_OPEN_SQL_DB dumps
    Any assistance on this would be helpful...
    Thanks -

    Fred
    Check OSS notes for this error. The BOP compponent has a steady stream of corrections developed by SAP especially in older releases.
    Also make sure your Livecache Build is consistent with SCM Release/ Patch level.
    Rishi Menon

  • Site is not responding due to long running script

    Hi
    I followed below mentioned URL  for dynamic menus and I did this in my custom master page instead of content editor WebPart. And it is working fine as expected but when browsing the ViewallSiteContent and SiteSettings pages I am getting notification
    in IE as "site is not responding due to long running scripts" and for other web pages I am not getting this error.
    http://spjsblog.com/2011/11/06/superfish-drop-down-menu-buildt-from-a-sharepoint-list/#comment-204701
    I am using SharePoint Server 2010 enterprise edition and IE 9 .
    Actually I uploaded .Js scripts in document library and referred those in custom master page. If I commented those scripts  in master page  file I am not getting any long scripting error.
    can any one help me here.
    Thanks

    Hello Satsum,
    Have you tried to debug the javascript in your your custom master page with for instance Internet Explorer Developer toolbar or Firebug?
    - Dennis | Netherlands | Blog |
    Twitter

  • Cannot access my acount due to long running scripr what is this how do i stop it.   help please

    Please help i cannnot access my i cloud account due to long running script..... what is this ....... how can i get rid of it?

    Go to Settings>General>TIme&Date and make sure it is set to automatic and time zone is correct.
    - Go to Settings>wifi and change the DNS to Google's 8.8.8.8

  • Flash player update causing IE browsing delays due to long running script

    Hi
    Can anyone help with this problem please: Flash player update causing IE browsing delays due to long running script. When I go to Google accounts or google anayltics long running script sometimes stops the loading of the google sites and the message appreas
    long running script preventing loading
    What in the name of God is this
    PP

    Hi Mokhtar,
    Thanks for your reply.
    I referred the scripts as below I master page and added .Js files in layouts directory inder 1033 folder.
    <SharePoint:ScriptLink ID="jQuery164" runat="server" Name="jquery-1.6.4.js" LoadAfterUI="true" OnDemand="false"/>
       <SharePoint:ScriptLink ID="SPUtility1" runat="server" Name="spjs-utility.js" LoadAfterUI="true" OnDemand="false"/>
       <SharePoint:ScriptLink ID="SuperFish" runat="server" Name="superfish.js" LoadAfterUI="true" OnDemand="false"/>
       <SharePoint:ScriptLink ID="SuperFishSP" runat="server" Name="SuperfishForSharePoint.js" LoadAfterUI="true" OnDemand="false"/>
    still the issue is not resolved.
    Is there any changes I've to do

  • Icloud calendar not opening due to long running scripts

    I just updated my icloud calendar to integrate with outlook.  Now I cannot open my calendar.  I get the message <icloud not responding to long-running script>
    Please advise.

    Hi Mokhtar,
    Thanks for your reply.
    I referred the scripts as below I master page and added .Js files in layouts directory inder 1033 folder.
    <SharePoint:ScriptLink ID="jQuery164" runat="server" Name="jquery-1.6.4.js" LoadAfterUI="true" OnDemand="false"/>
       <SharePoint:ScriptLink ID="SPUtility1" runat="server" Name="spjs-utility.js" LoadAfterUI="true" OnDemand="false"/>
       <SharePoint:ScriptLink ID="SuperFish" runat="server" Name="superfish.js" LoadAfterUI="true" OnDemand="false"/>
       <SharePoint:ScriptLink ID="SuperFishSP" runat="server" Name="SuperfishForSharePoint.js" LoadAfterUI="true" OnDemand="false"/>
    still the issue is not resolved.
    Is there any changes I've to do

  • Why do i have a long running script and how to get rid of it ????

    My computor stalls with twc not responding due to long running script. Just rebooted  back to factory default.

    mrswalt wrote:
    It doesn't say what script. But when I go to shut down there is a window icon on screen BUT DOES NOT say which window.
    Plus just bought a hp deskjet 2540 printer that will not print. HP info person is of NO help.
    This will be hard since we have no scripts for myself or others to look at to backtrack where the problem is coming from?
    I am a Volunteer to help others on here-not a HP employee.
    Replies aren't online 24/7 because of Time Zone differences.
    Remember in this Day and Age of Computing the Internet is Knowledge at your fingertips if you choose understand it. -2015-

  • Error in running juit test case for struts2 action class

    Hi,
    I am getting error when i am running my junit test case for struts2 action class. Here is the code.
    public class RoleMasterNewActionTest extends StrutsTestCase {
         public void setUp() throws Exception {
            super.setUp();
            ObjectFactory.setObjectFactory( new ObjectFactory() );
         public void testDoSomeThing()throws Exception {
              RoleMasterNewAction action = new RoleMasterNewAction();
              assertTrue(action.doSomeThing());
    }I am getting error at testDoSomeThing(). the error is
    2010-04-30 15:07:12,263 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-default.xml]
    2010-04-30 15:07:12,325 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts-plugin.xml]
    2010-04-30 15:07:12,388 INFO [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] - Parsing configuration file [struts.xml]
    2010-04-30 15:07:12,388 WARN [org.apache.struts2.config.Settings] - Settings: Could not parse struts.locale setting, substituting default VM locale
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-Lookup
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-label
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-headings
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-messages
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.comman-setup
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.common-errors
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-label
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-lookup
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-headings
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-jndinames
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.birthCertificate.resources.birth-jndinames
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.birthCertificate.resources.birth-labels
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.birthCertificate.resources.birth-headings
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.admin.resources.admin-alert
    2010-04-30 15:07:12,388 INFO [org.apache.struts2.config.BeanSelectionProvider] - Loading global messages from ipl.comm.resources.form
    2010-04-30 15:07:12,419 INFO [org.apache.struts2.spring.StrutsSpringObjectFactory] - Initializing Struts-Spring integration...
    2010-04-30 15:07:12,419 FATAL [org.apache.struts2.spring.StrutsSpringObjectFactory] - ********** FATAL ERROR STARTING UP STRUTS-SPRING INTEGRATION **********
    Looks like the Spring listener was not configured for your web app!
    Nothing will work until WebApplicationContextUtils returns a valid ApplicationContext.
    You might need to add the following to web.xml:
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>but already i have the listener configuration in my web.xml.
    Thanks in advance..

    I guess it wasn't reading the right web.xml file.
    You may prove it by deleting your web.xml file (don't forget to make a backup), and then run the test again to see whether the error is the same.

  • Request/Response From Long running Service to BPEL

    Hi,
    I have long running web service which I plan to implement as a EJB30 Webservice.
    I need to add support for Async callback Repsonse to the BPEL process calling this ejb service.
    Since jax-ws is not supported by the current version of Oracle I cannot use that.
    Can I use the Java concurrent api in side the EJB and implement the EJB as a stateful EJB with support for WS-Addressing?
    I do not want to use the JMS, becuse of the additional coding of multiple Message beans to send and receive the message.
    What other options do I have here?

    <con:fault xmlns:con="http://www.bea.com/wli/sb/context"> is an osb internal fault and not a soap:Fault
    BPEL process will fault if it receives either a soap:fault or a custom fault defined in the wsdl. so change your proxy service error handling to replace $body to one of these.
    If you don't have reply with failure action, osb will return a soap:Fault ( generated by the system error handler) and bpel will fault , but the error info in $fault will be lost..
    One way to address this is to define a Fault message for the service in the wsdl ( port type will have input, output and fault elements for the operation) and in the osb error handler transform $ fault to the fault message format and do a reply.

  • Ifplugd.action no longer run

    Hi,
    it seems that since upgrading to systemd the ifplugd.action script is no longer run.  As I understand it
    net-auto-wired.service
    should start the ifplugd daemon. The ifplugd.install script says "This package no longer provides a default ifplugd.action script." which to me sounds like it still should run.
    My ultimate aim is to disconnect wireless when ethernet is connected, is there a better way to do this?
    Thanks, Jamie

    Hi,
    it seems that since upgrading to systemd the ifplugd.action script is no longer run.  As I understand it
    net-auto-wired.service
    should start the ifplugd daemon. The ifplugd.install script says "This package no longer provides a default ifplugd.action script." which to me sounds like it still should run.
    My ultimate aim is to disconnect wireless when ethernet is connected, is there a better way to do this?
    Thanks, Jamie

  • How to send List from jsp to action class

    hi,
    i m fetching list from database and showing to jsp as follows:
    user can update that list i need to collect that updated list in next action class but i m not able to do that. can anybody suggest me any solution the code i m using is as follows:
    <html:form action="/myUpdate">
    <table>
    <tr>
         <td>
              <label><input type="text" property="name" name="name" value=""/></label>
         </td>
    </tr>
    <logic:iterate id="address" name="info" property="addressList" indexId="rowindex">
         <tr>
         <td>
         <input type="text" value="" name="address[<bean:write name="rowindex"/>].houseno" />
         </td>
         <td>
         <input type="text" value="" name="address[<bean:write name="rowindex"/>].roadname" />
         </td>
         <td>
         <input type="text" value="" name="address[<bean:write name="rowindex"/>].city" />
         </td>
         <td>
         <input type="text" value="" name="address[<bean:write name="rowindex"/>].state" />
         </td>
         <td>
         <input type="text" value="" name="address[<bean:write name="rowindex"/>].country" />
         </td>
         </tr>
         </logic:iterate>
    <tr>
         <html:submit/>
    </tr>
    </table>
    </html:form>
    here in privious action i m settting bean object in session with name 'info'. it is fetching data and disply it correctly but when i m trying to get this updated data in myUpdate action i m not getting list element.

    --------------- MyBean.java----------------------
    package form;
    import java.util.Iterator;
    import java.util.List;
    import javax.servlet.http.HttpServletRequest;
    import org.apache.log4j.Logger;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
    * @author Sushant.Raut
    public class MyBean extends ActionForm {
         Logger log = Logger.getLogger(this.getClass());
         /* (non-Javadoc)
          * @see org.apache.struts.action.ActionForm#reset(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
         @Override
         public void reset(ActionMapping mapping, HttpServletRequest request) {
              // TODO Auto-generated method stub
              super.reset(mapping, request);
              this.name = "";
         public String toString()
              System.out.println("name : " + this.name );
              for(Iterator<Address> iterator = addressList.iterator(); iterator.hasNext();)
                   Address address = (Address)iterator.next();
                   System.out.println("city : " + address.getCity());
              return null;
         private static final long serialVersionUID = 1L;
         private String name;
         private List<Address> addressList;
          * @return the names
         public MyBean()
              log.info("Bean Construtor is called.");
              System.out.println("MyBean:::::constructor is called.");
         public String getName() {
              log.info("Bean getName() is called");
              return name;
          * @param names the names to set
         public void setName(String name) {
              this.name = name;
              log.info("Bean setName() is called");
          * @return the address
         public List<Address> getAddressList() {
              log.info("Bean getAddressList() is called");
              return addressList;
          * @param address the address to set
         public void setAddressList(List<Address> address) {
              log.info("Bean setAddressList() is called");
              this.addressList = address;
         public Address getAddress(int index)
              log.info("Bean getAddress(int index) is called");
              while(index >= addressList.size())
                   addressList.add(new Address());
              return this.addressList.get(index);
         public void setAddress(int index, Address address)
              log.info("Bean setAddress(int index, Address address)) is called");
              this.addressList.add(index, address);
    }------------- Address.java------------
    package form;
    import javax.servlet.http.HttpServletRequest;
    import org.apache.struts.action.ActionMapping;
    * @author Sushant.Raut
    public class Address {
         private String houseno;
         private String roadname;
         private String city;
         private String state;
         private String country;
         public Address(){}
          * @return the houseno
         public String getHouseno() {
              return houseno;
          * @param houseno the houseno to set
         public void setHouseno(String houseno) {
              this.houseno = houseno;
          * @return the roadname
         public String getRoadname() {
              return roadname;
          * @param roadname the roadname to set
         public void setRoadname(String roadname) {
              this.roadname = roadname;
          * @return the city
         public String getCity() {
              return city;
          * @param city the city to set
         public void setCity(String city) {
              this.city = city;
          * @return the state
         public String getState() {
              return state;
          * @param state the state to set
         public void setState(String state) {
              this.state = state;
          * @return the country
         public String getCountry() {
              return country;
          * @param country the country to set
         public void setCountry(String country) {
              this.country = country;
         public void reset(ActionMapping mapping, HttpServletRequest request)
              this.city = "";
              this.country = "";
              this.houseno = "";
              this.roadname = "";
              this.state = "";
    }------ MyAction.java------
    package action;
    import java.util.ArrayList;
    import java.util.List;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.log4j.Logger;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import form.Address;
    import form.MyBean;
    * @author Sushant.Raut
    public class MyAction extends Action {
         Logger log = Logger.getLogger(this.getClass());
         public ActionForward execute(ActionMapping mapping, ActionForm form,
                   HttpServletRequest request, HttpServletResponse response)throws Exception{
              MyBean myBean = new MyBean();
              log.info("Bean is Initialised.");
              String name = "sushant";
              Address address = new Address();
              address.setCity("city1");
              address.setCountry("India");
              address.setHouseno("1111");
              address.setRoadname("xyz Road");
              address.setState("MH");
              Address address1 = new Address();
              address1.setCity("Hyderabad");
              address1.setCountry("India");
              address1.setHouseno("2222");
              address1.setRoadname("ABC Road");
              address1.setState("AP");
              List<Address> addressSet = new ArrayList<Address>();
              addressSet.add(address);
              addressSet.add(address1);
              myBean.setName(name);
              myBean.setAddressList(addressSet);
              request.getSession().setAttribute("info", myBean);
              log.info("Bean is bound to session.");
              System.out.println("MyBean object is bound to session.");
              System.out.println(myBean);
              return mapping.findForward("success");
    }-------- show.jsp-----------
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
         <html:form action="/myUpdate">
              <table>
                   <tr>
                        <td>
                             <label><html:text property="name" name="info"/></label>
                        </td>
                   </tr>
                   <logic:iterate id="address" name="info" property="addressList" indexId="rowindex">
                        <tr>
                             <td>
                                  <html:text property="houseno" name="address" indexed="true"/>
                             </td>
                             <td>
                                  <html:text property="roadname" name="address" indexed="true"/>
                             </td>
                             <td>
                                  <html:text property="city" name="address" indexed="true"/>
                             </td>
                             <td>
                                  <html:text property="state" name="address" indexed="true"/>
                             </td>
                             <td>
                                  <html:text property="country" name="address" indexed="true"/>
                             </td>
                        </tr>
                   </logic:iterate>
                   <tr>
                        <html:submit title="Submit"/>
                   </tr>
              </table>
         </html:form>
    </body>
    </html>

  • Handle long-running EDT tasks (f.i. TreeModel searching)

    Note: this is a cross-post from SO
    http://stackoverflow.com/questions/9378232/handle-long-running-edt-tasks-f-i-treemodel-searching
    copied below, input highly appreciated :-)
    Cheers
    Jeanette
    Trigger is a recently re-detected SwingX issue (https://java.net/jira/browse/SWINGX-1233): support deep - that is under collapsed nodes as opposed to visible nodes only, which is the current behaviour - node searching.
    "Nichts leichter als das" with all my current exposure to SwingWorker: walk the TreeModel in the background thread and update the ui in process, like shown in a crude snippet below. Fest's EDT checker is happy enough, but then it only checks on repaint (which is nicely happening on the EDT here)
    Only ... strictly speaking, that background thread must be the EDT as it is accessing (by reading) the model. So, the questions are:
    - how to implement the search thread-correctly?
    - or can we live with that risk (heavily documented, of course)
    One possibility for a special case solution would be to have a second (cloned or otherwise "same"-made) model for searching and then find the corresponding matches in the "real" model. That doesn't play overly nicely with a general searching support, as that can't know anything about any particular model, that is can't create a clone even if it wanted. Plus it would have to apply all the view sorting/filtering (in future) ...
    // a crude worker (match hard-coded and directly coupled to the ui)
    public static class SearchWorker extends SwingWorker<Void, File> {
        private Enumeration enumer;
        private JXList list;
        private JXTree tree;
        public SearchWorker(Enumeration enumer, JXList list, JXTree tree) {
            this.enumer = enumer;
            this.list = list;
            this.tree = tree;
        @Override
        protected Void doInBackground() throws Exception {
            int count = 0;
            while (enumer.hasMoreElements()) {
                count++;
                File file = (File) enumer.nextElement();
                if (match(file)) {
                    publish(file);
                if (count > 100){
                    count = 0;
                    Thread.sleep(50);
            return null;
        @Override
        protected void process(List<File> chunks) {
            for (File file : chunks) {
                ((DefaultListModel) list.getModel()).addElement(file);
                TreePath path = createPathToRoot(file);
                tree.addSelectionPath(path);
                tree.scrollPathToVisible(path);
        private TreePath createPathToRoot(File file) {
            boolean result = false;
            List<File> path = new LinkedList<File>();
            while(!result && file != null) {
                result = file.equals(tree.getModel().getRoot());
                path.add(0, file);
                file = file.getParentFile();
            return new TreePath(path.toArray());
        private boolean match(File file) {
            return file.getName().startsWith("c");
    // its usage in terms of SwingX test support
    public void interactiveDeepSearch() {
        final FileSystemModel files = new FileSystemModel(new File("."));
        final JXTree tree = new JXTree(files);
        tree.setCellRenderer(new DefaultTreeRenderer(IconValues.FILE_ICON, StringValues.FILE_NAME));
        final JXList list = new JXList(new DefaultListModel());
        list.setCellRenderer(new DefaultListRenderer(StringValues.FILE_NAME));
        list.setVisibleRowCount(20);
        JXFrame frame = wrapWithScrollingInFrame(tree, "search files");
        frame.add(new JScrollPane(list), BorderLayout.SOUTH);
        Action traverse = new AbstractAction("worker") {
            @Override
            public void actionPerformed(ActionEvent e) {
                setEnabled(false);
                Enumeration fileEnum = new PreorderModelEnumeration(files);
                SwingWorker worker = new SearchWorker(fileEnum, list, tree);
                PropertyChangeListener l = new PropertyChangeListener() {
                    @Override
                    public void propertyChange(PropertyChangeEvent evt) {
                        if (evt.getNewValue() == SwingWorker.StateValue.DONE) {
                            //T.imeOut("search end ");
                            setEnabled(true);
                            ((SwingWorker) evt.getSource()).removePropertyChangeListener(this);
                worker.addPropertyChangeListener(l);
                // T.imeOn("starting search ... ");
                worker.execute();
        addAction(frame, traverse);
        show(frame)
    }

    At the end of the day, it turned out that I asked the wrong question (or right question in a wrong context ;-): the "problem" arose by an assumed solution, the real task to solve is to support a hierarchical search algorithm (right now the AbstractSearchable is heavily skewed on linear search).
    Once that will solved, the next question might be how much a framework can do to support concrete hierarchical searchables. Given the variety of custom implementations of TreeModels, that's most probably possible only for the most simple.
    Some thoughts that came up in the discussions here and the other forums. In a concrete context, first measure if the traversal is slow: most in-memory models are lightning fast to traverse, nothing needs to be done except using the basic support.
    Only if the traversal is the bottleneck (as f.i. in the FileSystemModel implementations of SwingX) additional work is needed:
    - in a truly immutable and unmodifiable TreeModel we might get away with read-only access in a SwingWorker's background thread
    - the unmodifiable precondition is violated in lazy loading/deleting scenarios
    there might be a natural custom data structure which backs the model, which is effectively kind-of "detached" from the actual model which allows synchronization to that backing model (in both traversal and view model)
    - pass the actual search back to the database
    - use an wrapper on top of a given TreeModel which guarantees to access the underlying model on the EDT
    - "fake" background searching: actually do so in small-enough blocks on the EDT (f.i. in a Timer) so that the user doesn't notice any delay
    Whatever the technical option to a slow search, there's the same usability problem to solve: how to present the delay to the end user? And that's an entirely different story, probably even more context/requirement dependent :-)
    Thanks for all the valuable input!
    Jeanette

  • Prgess indicator on long running jobs

    I have an FX application that is directly linked to my database. The program allows all DML operations as well as user defined actions (action commands and various other methods). I have the same application running in Swing, SWT, Canoo ULC and al works just fine. In each of the other front end types, the application automatically displays a busy indicator when a long running job is executed. Now I need this in FX.
    My application is basically a Rich Client framework which allows the same business logic and forms to have different front ends depending on customer requirements. The application is built by customers in a 4GL style development tool. The application is actually built at run time and the data is provided by the user through various services. Because I am building an FX program for a framework, I don't know when the user may execute a long running job when, for example, a button is pressed. I have full control over the retrieval and modification of data but not user interaction. I am therefore looking for a busy indicator that comes automatically when the main thread is waiting.
    Any help would be great!

    Hi guys and thanks for your answers
    I may have stretched the mark with "long running jobs" by these I mean a database query, a price calculation, order process etc. These are standard jobs that are issued on a Rich Client application. Basically I have a screen which will execute a query, and I want to give the user feedback when the query is executing so that he doesn't think that the application has hung. In Swing I have done this by creating my own event queue with a delay timer:
    public class WaitCursorEventQueue extends EventQueue implements DelayTimerCallback
        private final CursorManager cursorManager;
        private final DelayTimer    waitTimer;
        public WaitCursorEventQueue(int delay)
            this.waitTimer = new DelayTimer(this, delay);
            this.cursorManager = new CursorManager(waitTimer);
        public void close()
            waitTimer.quit();
            pop();
        protected void dispatchEvent(AWTEvent event)
            cursorManager.push(event.getSource());
            waitTimer.startTimer();
            try
                super.dispatchEvent(event);
            finally
                waitTimer.stopTimer();
                cursorManager.pop();
        public AWTEvent getNextEvent() throws InterruptedException
            waitTimer.stopTimer(); // started by pop(), this catches modal dialogs
            // closing that do work afterwards
            return super.getNextEvent();
        public void trigger()
            cursorManager.setCursor();
    }I then implemented this into my application like this:
    _eventQueue = new WaitCursorEventQueue(TIMEOUT);
    Toolkit.getDefaultToolkit().getSystemEventQueue().push(_eventQueue);Now each time the application waits for a specific time, the cursor will become a wait timer. This give s the user a visual feedback so that he knows that the application is working and not just hung. By doing this, I do not need to wrap each user callout in a timer. Much easier like this!
    I would like to implement the same in FX.
    Edited by: EntireJ on Dec 15, 2011 12:34 AM

Maybe you are looking for