Graph connectivity problem-adjacency list-connected graph-Theta complexity

I am stuck up on this problem:
I want to find an algorithm of Theta(n+m) complexity, which will examine
if a non-directed graph is connected (synectic).
We assume that the representation of the graph has been made with an
adjacency list with n vertices and m edges.
Thanks in advance.

A BFS or DFS from any node in your graph should be T(n+m) in case of an adjacency list (instead of a adjacency matrix). When the search is finished, compare the number of visited nodes to the total number of nodes in the graph. If they're not equal, the graph is not connected.

Similar Messages

  • Adjacency List implementation of a graph

    Hey everyone,
    I'm starting to code a directed graph using an adjacency list and I'm running into a little trouble. I understand the concepts of the adjacency list structure, but I cant write seem to figure out how to code one. So far I'm using two doubly linked lists for storing the vertices and edges, and each is in its own class (I thought this would come in handy when later coding traversals in the graph). In the graph class, I'm thinking that an array list would work to store the adjacent vertices (each value in the array storing a list of vertices which are adjacent). However, if this is right then I'm not sure what to do with the edges, and how to make each edge know which vertices it is connecting.. In general, I'm looking for comments/advice on this type of graph implementation. Anything will help. Thanks a lot.

    import java.util.*;
    public class AdjacencyListNode
        private Set<Node> successors = new HashSet<Node>();
        public void addSuccessor(Node n) { ... }
        public boolean predecessorOf(Node n) { ... }
    }Of course, if you want multiple edges between nodes or weighted edges then it'll need modifying. You may also want to be able to apply a visitor to the successors.

  • Adjacency List / Adjacency Matrix

    Hello All,
    I am very new to Java programming and looking for some examples:
    1) How I can create an Adjacency List structure consisting of random numbers in a form of Skewed, Uniform, or Two-Tier Distributions.
    2) Create a matrix (two-dimentional array, and this part is easy). The difficult part is how can I create two dimentional array with random number distribution for 1's and 0's (i.e. adjacency matrix) in a form of Skewed, Uniform, or Two-Tier Distributions.
    Thank you!

    If I'm getting this right, I think the 2 problems above are down to one question:
    1) How to create a random number generation method for {Skewed, Uniform, Two-Tier, ...} Distribution?
    One solution I can immediately think of is as follows:
    import static java.lang.Math.*;
    // Cumulative Distribution Function
    public interface CDF {
        // probability by a given x
        double p(double x);
        // x from a given probability p
        double x(double p);
    // Example - Normal Distribution
    public class NormalDistribution implements CDF {
        private double mean, sd;
        public NormalDistribution(double mean, double sd) {
            this.mean = mean;
            this.sd = sd;
        private double phi(double z) {
            double t = 1.0 / (1.0 + 0.2316419 * x);
            return 1.0 - (exp(-z*z / 2.0) / sqrt(2.0 * PI)) * (0.31938153 * t - 0.356563782 * pow(t, 2.0) + 1.781477937 * pow(t, 3.0) - 1.821255978 * pow(t, 4.0) + 1.330274429 * pow(t, 5.0));
        private double inversePhi(double p) {
            double a = p > 0.5 ? 1.0 - p : p;
            double t = sqrt(log(1.0 / (p*p)));
            double t2 = t*t, t3 = t2*t;
            return (p > 0.5 ? 1.0 : -1.0) * (t - (2.515517 + 0.802853 * t + 0.010328 * t2) / (1 + 1.432788 * t + 0.189269 * t2 + 0.001308 * t3));
        public double p(double x) {
            return phi((x - mean) / sd);
        public double x(double p) {
            return inversePhi(p) * sd + mean;
    // RandomNumberGenerator
    public class RNG<T extends CDF> {
        private T dist;
        public RNG(T dist) {
            this.dist = dist;
        public double rand() {
            return x(rand());
    }Thus with the following line:
    RNG NR = new RNG<NormalDistribution>(new NormalDistribution(10.0, 5.0));You'll have NR as a random number generator that will give numbers that are normally distributed.
    Of course if you just need discrete distributions instead of continuous ones, you can make similar definitions using long or int instead of double
    Hope this helps~
    Alex Lam S.L.

  • Problem in list display

    Hi experts,
    i have a problem with list display.
    I want to display the output  like date, time, costcentre, company code ...... But the out put list display is coming as costcentre , username , date , time , company code....even after setting the col positions as 1,2,3, 4
    I have observed in fieldcatalog as costcentre and username from field catalog_merge fm its taking l_fieldcatalog-key = 'X". i made this as l_fieldcatalog-key = '  '. Even though its displaying in the same way.
    Please suggest me is there any way i can solve this issue.

    Hi,
    Check whether you have given any default layout. you can change the default layout and save it as you need.
    Or do the following
    If you are displaying a few fields from a table you can buid the field catalog manually. This will solve your problem.
    <b><REMOVED BY MODERATOR></b>
    Message was edited by:
            Alvaro Tejada Galindo

  • Problem in list display of TCODE F.13

    Hi all,
    Have a look at the below thread
    Problem with List display for TCODE F.13
    Does the same problem exist in your system
    Let me know.
    Thanks

    Hi Neelema,
    You could try this sample code.
    [http://sap-img.com/fu037.htm]
    [http://sap-img.com/abap/sample-alv-heading-in-alv.htm]
    Regards,
    Amit.

  • Problem create List E []

    Hello. Got problems when I try to create one "Array" filled with "List" as type. Tried:
    List<E>[] name = List<E>[size]; (Compilation problem)
    and
    List<E>[] name = (List<E>[])(new Object[size]) (cannot cast object to list)Got any suggestions?

    Hunter78 wrote:
    Thanks. It seems to compile but now I recive "NullPointerException" when I try to add anything into the list. Any idea why?
    Example:
    public void method(E e){
    List<E>[] name = (List<E>[])new List[size];
    List list = name[0];
    list.add(e);     (NullPointerException)
    }edit: using array becouse it�s most naturale when the size is known.Umm... have you ever used arrays of references before? "name" is an array of references, because List is a reference type (everything that is not a primitive type is a reference type). So when you create the array, it is initialized with null references (the default value for references). i.e. the references don't point to any object. So you have no List object to add anything to. It's the same reason why this won't work:
    List foo = null;
    foo.add(e);

  • Sorting singly linked list with minimum time complexity

    Hi ...
    anyone could tell me how can i sort singly linked list with minimum time complexity .... ????
    Regards...

    By MergeSort or QuickSort O(n log n). But then you
    have to first extract the objects in the list,sort
    them, then rebuild the list. But it will still bealot
    faster than by keeping the list linked.Technically, I believe insertion sort is marginally
    faster for small n ( <20 or so).Woohoo! So for 20 out of the possible 2147483648 array
    sizes Insetion is faster!
    Unfortunately, checking for that case probably wastes
    all the time you get from using the faster sort...
    That would depend on the actual distribution off array sizes. So it's an engineering decision.
    Sylvia.

  • ADF: Problem with List and ListOfValues bindings

    In my page I have panelSplitter.
    In first facet I have panelCollection with ADF tree. For the tree definition I have Iterator binding, which contains the elements with no parent and one accessor, which define a recursive master-detail hierarchy. For the tree node I have specified TragetIterator property, that look up second iterator binding, which containes all tree elements (parents and their children).
    In second facet I have panelForm with input fields, based on second iterator binding. So when the user clicks on any node in the tree, it can see and edit in input fields the data for this node.
    In panelCollection I have placed two buttons to create a new node and to delete current node.
    By creation of new node I do the following:
    1) From currently selected node I get the value of one attribute named Code, which is alternate unique key;
    2) From second iterator binding I get the ViewObject, create a new Row and for the "parent" attribute I set the value derived from step 1.
    3) I rerender through PPR tree component and PanelForm with input fields.
    As result I have a new empty node in the tree and empty input fields in second facet, which must be populated and submitted (commited).
    My problem happens after I populate all fields in panelForm, when I commit changes (press Button with Commit action binding) and rerender page content. The exception, which is trown is listed below.
    I want to make the follwing additional remarks:
    1) My primary key in ViewObject is ROWID. I need this attribute to uniquely identify created new rows.
    2) The problem happens only when in panelForm I have field based on Model driven List or ListOfValues binding (<af:selectOneChoice> or <af:inputListOfValues>).
    When I create a new row the ADF BC assign to it one "dummy" ROWID (for example 317499) and after Commit this ROWID is replaced wtih actual ROWID from database. But I don't understand, why after commit of changes on the page the method findByKey of oracle.jbo.server.ViewObjectImpl is called with initial "dummy" ROWID (317499)?
    When there is no field based on List or ListOfValues binding, then there are no calls of findByKey method and there is no such problem.
    And that is the exception:
    2009-7-29 18:04:54 oracle.adf.controller.faces.lifecycle.FacesPageLifecycle addMessage
    WARNING: ADFc: ORA-01410: невалиден ROWID
    oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation. Statement: SELECT OU.CODE, OU.NAME, OU.ABBREVIATION, OU.ORGUNIT_TYPE, OU.PARENT_UNIT, OU.IS_VALID, OU.ROWID FROM ORG_UNITS OU WHERE (OU.ROWID = :1)
         at oracle.jbo.server.BaseSQLBuilderImpl.processException(BaseSQLBuilderImpl.java:3837)
         at oracle.jbo.server.OracleSQLBuilderImpl.processException(OracleSQLBuilderImpl.java:4621)
         at oracle.jbo.server.QueryCollection.buildResultSet(QueryCollection.java:1150)
         at oracle.jbo.server.QueryCollection.executeQuery(QueryCollection.java:762)
         at oracle.jbo.server.ViewObjectImpl.executeQueryForCollection(ViewObjectImpl.java:5681)
         at nsi.isbs.dmc.common.IsbsViewObjectImpl.executeQueryForCollection(IsbsViewObjectImpl.java:56)
         at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:1005)
         at oracle.jbo.server.ViewRowSetImpl.executeQueryForMasters(ViewRowSetImpl.java:1162)
         at oracle.jbo.server.ViewRowSetImpl.executeQueryForMode(ViewRowSetImpl.java:1082)
         at oracle.jbo.server.ViewRowSetImpl.executeQuery(ViewRowSetImpl.java:1076)
         at oracle.jbo.server.ViewObjectImpl.retrieveByKey(ViewObjectImpl.java:13994)
         at oracle.jbo.server.ViewObjectImpl.retrieveByKey(ViewObjectImpl.java:13758)
         at oracle.jbo.server.ViewObjectImpl.retrieveByKey(ViewObjectImpl.java:13752)
         at oracle.jbo.server.ViewRowSetImpl.findByKey(ViewRowSetImpl.java:4891)
         at oracle.jbo.server.ViewRowSetImpl.findByKey(ViewRowSetImpl.java:4679)
         at oracle.jbo.server.ViewRowSetImpl.findByKey(ViewRowSetImpl.java:4673)
         at oracle.jbo.server.ViewObjectImpl.findByKey(ViewObjectImpl.java:9456)
         at oracle.jbo.server.ApplicationModuleImpl.getListBindingName(ApplicationModuleImpl.java:8421)
         at oracle.adf.model.bc4j.DCJboDataControl.getListBindingName(DCJboDataControl.java:2244)
         at oracle.jbo.uicli.binding.JUCtrlListBinding.initDefFromServerBinding(JUCtrlListBinding.java:2366)
         at oracle.jbo.uicli.binding.JUCtrlListBinding.getAttributeDefs(JUCtrlListBinding.java:2327)
         at oracle.jbo.uicli.binding.JUCtrlValueBinding.getAttributeDef(JUCtrlValueBinding.java:497)
         at oracle.jbo.uicli.binding.JUCtrlValueBinding.getAttributeDef(JUCtrlValueBinding.java:487)
         at oracle.jbo.uicli.binding.JUCtrlValueBinding.isInternalAttributeUpdateable(JUCtrlValueBinding.java:3262)
         at oracle.jbo.uicli.binding.JUCtrlValueBinding.isAttributeUpdateable(JUCtrlValueBinding.java:1617)
         at oracle.jbo.uicli.binding.JUCtrlValueBinding.isAttributeUpdateable(JUCtrlValueBinding.java:1695)
         at oracle.jbo.uicli.binding.JUCtrlValueBinding.isUpdateable(JUCtrlValueBinding.java:2512)
         at oracle.jbo.uicli.binding.JUCtrlListBinding.isUpdateable(JUCtrlListBinding.java:3357)
         at oracle.adfinternal.view.faces.model.AdfELResolver._isReadOnly(AdfELResolver.java:85)
         at oracle.adfinternal.view.faces.model.AdfELResolver.isReadOnly(AdfELResolver.java:101)
         at javax.el.CompositeELResolver.isReadOnly(CompositeELResolver.java:353)
         at com.sun.faces.el.FacesCompositeELResolver.isReadOnly(FacesCompositeELResolver.java:113)
         at com.sun.el.parser.AstValue.isReadOnly(AstValue.java:128)
         at com.sun.el.ValueExpressionImpl.isReadOnly(ValueExpressionImpl.java:230)
         at oracle.adfinternal.view.faces.renderkit.rich.EditableValueRenderer.getReadOnly(EditableValueRenderer.java:400)
         at oracle.adfinternal.view.faces.renderkit.rich.EditableValueRenderer.wasSubmitted(EditableValueRenderer.java:341)
         at oracle.adfinternal.view.faces.renderkit.rich.EditableValueRenderer.decodeInternal(EditableValueRenderer.java:113)
         at oracle.adfinternal.view.faces.renderkit.rich.SimpleInputListOfValuesRendererBase.decodeInternal(SimpleInputListOfValuesRendererBase.java:88)
         at oracle.adfinternal.view.faces.renderkit.rich.LabeledInputRenderer.decodeInternal(LabeledInputRenderer.java:55)
         at oracle.adf.view.rich.render.RichRenderer.decode(RichRenderer.java:236)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.__rendererDecode(UIXComponentBase.java:1089)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.decode(UIXComponentBase.java:714)
         at oracle.adf.view.rich.component.UIXInputPopup.processDecodes(UIXInputPopup.java:134)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.decodeChildrenImpl(UIXComponentBase.java:970)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.decodeChildren(UIXComponentBase.java:956)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.processDecodes(UIXComponentBase.java:812)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.decodeChildrenImpl(UIXComponentBase.java:970)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.decodeChildren(UIXComponentBase.java:956)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.processDecodes(UIXComponentBase.java:812)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.decodeChildrenImpl(UIXComponentBase.java:970)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.decodeChildren(UIXComponentBase.java:956)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.processDecodes(UIXComponentBase.java:812)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.decodeChildrenImpl(UIXComponentBase.java:970)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.decodeChildren(UIXComponentBase.java:956)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.processDecodes(UIXComponentBase.java:812)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.decodeChildrenImpl(UIXComponentBase.java:970)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.decodeChildren(UIXComponentBase.java:956)
         at org.apache.myfaces.trinidad.component.UIXComponentBase.processDecodes(UIXComponentBase.java:812)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl$ApplyRequestValuesCallback.invokeContextCallback(LifecycleImpl.java:1113)
         at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:722)
         at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:731)
         at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:731)
         at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:731)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.invokeOnComponent(ContextSwitchingComponent.java:153)
         at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:731)
         at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:731)
         at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:731)
         at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:731)
         at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.invokeOnComponent(ContextSwitchingComponent.java:153)
         at oracle.adf.view.rich.component.fragment.UIXPageTemplate.invokeOnComponent(UIXPageTemplate.java:208)
         at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:731)
         at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:664)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:303)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:175)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:181)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:85)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:279)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._invokeDoFilter(TrinidadFilterImpl.java:239)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:196)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:139)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at oracle.security.jps.wls.JpsWlsFilter$1.run(JpsWlsFilter.java:85)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:257)
         at oracle.security.jps.wls.JpsWlsSubjectResolver.runJaasMode(JpsWlsSubjectResolver.java:250)
         at oracle.security.jps.wls.JpsWlsFilter.doFilter(JpsWlsFilter.java:100)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:65)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(Unknown Source)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused by: java.sql.SQLException: ORA-01410: невалиден ROWID
         at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
         at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:116)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:177)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1034)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
         at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:947)
         at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:891)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1186)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3381)
         at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3425)
         at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1490)
         at oracle.jbo.server.QueryCollection.buildResultSet(QueryCollection.java:1040)
         ... 104 more
    ## Detail 0 ##

    I have resolved my problem. I have changed the type of list binding to be Dynamic List (not Model Driven List).

  • Problem with list and map in GWT

    I have a problem with map and list in GWT. I need to put a map in to a list but GWT does not support ArrayList and HashMap since they are not serialized types.
    Exactly I want to create following list with out using ArrayList and HashMap
    ArrayList<HashMap<String, Object>> map = new ArrayList<HashMap<String,Object>>(); Thank you for new ideas,
    Regards

    If try to use ArrayList then I receive following exception when I make a rpc call.
    Caused by: com.google.gwt.user.client.rpc.SerializationException: Type 'java.util.ArrayList' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized.:

  • Check box rendering problem in List.

    Hi All,
                I am using list component in my app and list component allows multiple selections. I am using an itemrenderer having the checkbox and label in hbox.
    Rendering is working fine. but when I selected three or four items randomly using check boxes in list and If I scroll it vertically (up and down) the selections of check boxes changedto another items. If I keep on doing this finally I will get all the check boxes selected. but I have selected only three check boxes.
                 I wanted get out of this problem. If i selected two or three checkboxes and when scroll it vertically it should remain as it is. Selections should not change... please help on this.. 
                     I am posting the code of Item renderer
    <?xml version="1.0" encoding="utf-8"?>
    <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" horizontalGap="2"
        width="100%" height="100%"
        implements="mx.controls.listClasses.IDropInListItemRenderer"
        initialize="init()"
        verticalScrollPolicy="off"
        horizontalScrollPolicy="off"
        click="handleClick(event)">
        <mx:Metadata>
            [Event(name="checkBoxEvent", type="com.comp.name.ui.events.CheckBoxEvent")]
        </mx:Metadata>
        <mx:Script>
            <![CDATA[
                import mx.controls.List;
                import mx.controls.listClasses.ListData;
                import com.comp.name.ui.events.CheckBoxEvent;
                import com.comp.name.ui.filters.StringUtils;
                import mx.controls.dataGridClasses.DataGridListData;
                import mx.controls.listClasses.BaseListData;
                private var _listData:BaseListData;
                private var _list:List;
                public function init():void
                    this.addEventListener(Event.CHANGE, onChangeEvent);
                public function get listData() : BaseListData
                    return _listData;
                public function set listData( value:BaseListData ) : void
                    _listData = value;
                    if(listData)
                        _list = listData.owner as List
                override public function set data(value:Object):void
                    super.data = value;
                protected function handleClick(event:MouseEvent):void
                    if(check.selected)
                        check.selected = false;
                    else
                        check.selected = true;
                protected function checkBoxSelected(event:Event):void
                    if(data)
                        if(check.selected){
                            dispatchEvent(new CheckBoxEvent(CheckBoxEvent.CHECKBOX_EVENT, data.mx_internal_uid,data as Object, true,true));
                        }else
                            dispatchEvent(new CheckBoxEvent(CheckBoxEvent.CHECKBOX_EVENT, data.mx_internal_uid,data as Object, false,true));
                protected function onChangeEvent(event:Event):void
            ]]>
        </mx:Script>
        <mx:CheckBox id="check" change="checkBoxSelected(event)" click="handleClick(event)"/>
        <mx:Label id="lb" width="100%" height="100%" htmlText="{_list.labelFunction(data)}"/>
    </mx:HBox>
    I have faced this problem in so many times in so many list component..  Please help me on this...

    Can any one please give a reply .. If you dont understand it please let me .. I will give you detailed explanation.. Please it is an urgent requirement..

  • Problem getting list of filenames

    Hi all,
    I have a problem with a servlet:
    I am trying to get a String array of all the filenames in a directory using list(). Is this possible in a servlet? I am using tomcat 5.0.
    this is my code so far:
    ServletContext context = getServletContext();
    URL url = context.getResource("/txt/");
    String loc = url.toString();
    File dir = new File(loc);
    String[] files = dir.list();
    for (int i = 0; i < files.length; i++) {
    System.out.println(files);
    can anyone help?
    rntz

    Looks ok to me.
    Whats the problem?
    A couple of other ways I might suggest:
    1 - try File dir = new File(url)
    As long as it is a file:// url, the above should work.
    2 - use context.getRealPath("/txt");
    String loc = context.getRealPath("/txt");
    File dir = new File(loc);
    Cheers,
    evnafets

  • Problem sorting list with virtual layout = false (and also with true)

    Hi,
    I've a problem sorting a list... or better... I've a problem showing the sorted list ;-)
    I've a list of xml item. The list is shown with an item renderer.
    my needs: a button to refresh data and a button to sort data.
    useVirtualLayout = false
    -> refresh works correctly, sort does not affect the view (even if the list is sorted correctly when printed with trace)
    useVirtualLayout = true
    -> sort works correctly, refresh reverse the list each time I press it (even if the list remain the same when printed with trace)
    does any one have an idea?
    thank you!!
    MXML
    <s:List dataProvider="{xmlListCollection}" width="100%" itemRenderer="myRenderer" minHeight="0" id="test" useVirtualLayout="false" >
    <s:layout>
      <s:VerticalLayout clipAndEnableScrolling="true"/>
    </s:layout>
    </s:List>
    XML example
    <unit sortField1="First Floor" sortField2="7">
      <employee>
        <id>3040684</id>
        <name>PIFFARETTI Vasco</name>
        <birthdate>20.05.1983</birthdate>
        <beginDate>2012-02-25 08:55:00</beginDate>
        <endDate>9999-12-31 00:00:00</endDate>
        <annotation/>
      </employee>
    </unit>

    You can tell when the scroll position has changed by handling the propertyChange event coming from the DataGroup:
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   creationComplete="list1.dataGroup.addEventListener('propertyChange', handle)">
        <fx:Script>
            <![CDATA[
                import mx.events.PropertyChangeEvent;
                private function handle(e:PropertyChangeEvent):void {
                    if (e.property == 'verticalScrollPosition'){
                        trace('vsp changed');               
                    if (e.property == 'horizontalScrollPosition'){
                        trace('hsp changed');               
            ]]>
        </fx:Script>
        <s:List id="list1" width="100" height="50">
            <s:layout>
                <s:VerticalLayout />
            </s:layout>
            <s:dataProvider>
                <s:ArrayList>
                    <fx:String>0</fx:String>
                    <fx:String>1</fx:String>
                    <fx:String>2</fx:String>
                    <fx:String>3</fx:String>
                    <fx:String>4</fx:String>
                    <fx:String>5</fx:String>
                    <fx:String>6</fx:String>
                    <fx:String>7</fx:String>
                </s:ArrayList>
            </s:dataProvider>
        </s:List>
    </s:Application>
    You might also want to read and consider voting for http://bugs.adobe.com/jira/browse/SDK-21357

  • Problem using List of Lists in loop

    I'm working on a test program that will pull in two text files and return a list of the words that are common among in each. I'm running into a logistical problem when trying to add elements of a list to a list of lists, and then clear the primary list for the next iteration of the loop. Here's my code:
    import java.util.*;
    import java.io.*;
    public class IOList {
       private static List<File>();
       public static void main(String[] args) {
          files = new ArrayList<File>();
          Scanner s;
          List<String> words = new ArrayList<String>();
          List<List<String>> allWords = new ArrayList<List<String>>();
          File a = new File(args[0]);
          File b = new File(args[1]);
          files.add(a);
          files.add(b);
          for (File file : files) {
             try {
                s = new Scanner(new BufferedReader(new FileReader(file)));
                while (s.hasNext()) {
                   words.add(s.next());
                int n = words.size();
                allWords.add(words.subList(0, n));
                words.clear();
             } catch(FileNotFoundException e) {
                System.err.println("Could not find file " + file);
                System.exit(1);
          List<String> fileA = allWords.get(0);
          List<String> fileB = allWords.get(1);
          fileA.retainAll(fileB);
          fileB.retainAll(fileA);
          fileA.addAll(fileB);
          int size = fileA.size();
          for (int i = 0; i < size; i++) {
             String str = fileA.get(i - 1);
             System.out.println(str);
    }When I step through this code, netbeans gives me a message:
    words.subList = >"subList" is not a known variable in current context<
    If I use allWords.add(words); instead, the String elements populate to the first List of Strings contained in allWords, and are then removed when I call
    words.clear();in the next step to prep it for the next iteration.
    Can anyone suggest another way to do this while still working with the loop?
    Thanks in advance

    Just to make clear: subList() does not (necessarily)
    create a new list but a view on the original list. If
    that original list is modified, the sublist might
    change and vice versa.subList() never creates a new list, the subList is always backed by the original list. If the original list is modified, the sublist is too, always. If the original list is structurally modified, the result is undefined, so don't do that.
    http://java.sun.com/j2se/1.5.0/docs/api/java/util/List.html#subList(int, int)

  • Problem with listing thumbnails within c:forEach loop

    I'm currently developing a photo gallery application using Struts. In the JSP code listed below I retrieve a list of "photo" beans (succesfully) and I use <html:link> tag as a link to a desired photo. Links for all the listed photos work well.
    The ONLY problem is that all the thumbnails are copies of the last one retrieved in the loop (but they refer to different photos as required). The "/showthumb" servlet (alias for appropriate servlet) inserts the thumbnails into the page using the session scoped "blob". I'm presuming that all the thumbs are result of the last invocation of the servlet and in fact use the last value of the "blob" session scoped variable.
    Does anybody has an idea how to solve this problem and show all the thumbs instead of a copies of the last one in a JSP page ?
    <c:forEach varStatus="status" var="photo" begin="0" items="${glazDB.photos}">
                    <jsp:setProperty name="prevNext" property="add" value="${photo.photoId}"/>
                    <td>
                        <c:remove var="blob"/>
                        <c:set var="blob" value="${photo.thumb}" scope="session" />
                        <c:url var="url" value="\showpicture.do" >
                          <c:param name="pic" value="${status.count}" />
                        </c:url>
                        <html:link page="${url}"><html:img page="/showthumb"/></html:link>
                    </td>
                    <c:if test="${status.count mod 4 == 0}">
                        </tr><tr>
                    </c:if>
            </c:forEach>

    Think about the ordering of things here.
    Your jsp runs, it sends back an HTML page.
    Only when the client sees the HTML page can it start making requests for the images.
    All the <html:img> tag does is put the text for an image tag onto the page to be evaluated later. So your continual setting of the session variable is pretty much useless, as only the last one is in session when you execute the servlet.
    You have to make the request load the image in some other way.
    request each blob seperately via parameters. eg /showthumb?id=xxxx
    Whether you keep all the images in session memory at one time, or you load each individual one is up to you.

  • Problem with list box in table control (Module pool) .

    Hi,
    I'm facing a problem while populating values in List Box..
    While I'm clicking a value from the list box it is not being hold in that box...box got blanked.
    Please help me to solve this.

    process before output.
    module pop_drop_down.
    module pop_drop_down output.
      name1 = 'IO5'.
      REFRESH list1.
      LOOP AT it_zpoitshead INTO wa_zpoitshead.
        value1-key = wa_zpoitshead-createdt.
        value1-key = wa_zpoitshead-its_ebeln.
        APPEND value1 to list1.
      ENDLOOP.
      CLEAR value1.
      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          id                    = name1
          values                = list1
       EXCEPTIONS
         ID_ILLEGAL_NAME       = 1
         OTHERS                = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    endmodule.                 " pop_drop_down  OUTPUT

Maybe you are looking for