Changing states from within a component

Let's say that I have a TileList that is rendering data in a
VBox. Eventually the TileList fills up and starts scrolling. I want
to change states when clicking on item in the TileList.
I don't want to place the click-attribute in the TileList,
because it will change states when I am scrolling the list without
actually selecting anything.
I want to say click="currentState='state2'" inside the VBox,
but that does not work because state2 is at the root level, and I
don't know how to get to the root-level (in lack of a better word)
from withing the component.
This is not the proper syntax, so misunderstand me the right
way here... Is there an equivallence to
click="currentState='_root.state2'" in mxml?
Thanks for any suggestions or best practices. I want the easy
way out.
This is the general structure...
<mx:Application>
<mx:states>
<mx:State id="state1"/>
<mx:State id="state2"/>
<mx:State id="state3"/>
</mx:states>
<mx:TileList dataprovider="{...}">
<mx:itemRenderer>
<mx:component>
<mx:VBox id="ClickThisBoxToChangeStates">
<mx:Image/>
<mx:Label/>
</mx:Vbox>
</mx:component>
</mx:itemRenderer>
</mx:TileList>
</mx:Application>

Your assumption is right.
It doesn't work because there is no state2-state defined
within the mx:component.
In the documentation about changing states it says that I can
go from application level and change states within a component;
like this: click="currentState='mycomponent.anotherstate'" but not
how I can change a state at application level from within a state.
When I try, it says (at runtime) that the state is not defined.
So I don't know why <mx:VBox
click="currentState='state2'"/> doesn't work.
I apprechiate your expertese a lot.

Similar Messages

  • Change base view state from a custom component

    I'm pretty new to flex and I'm having a small issue in change the view state from a component.
    My Application have 2 custom components called userlogin and main menu. In the main application page I have userlogin component in one state and the main menu component in another. I'm trying to change the state if the login in successful from user login to main menu. I have the following function written inside the login component.
    private function IsUserLoggedIn(evt:ResultEvent):void
                    if (evt.result.islogin.toString() == "true")
                        currentState = "MainMenu";
                    else
                        Alert.show("Login failed, please try again.", "Login Failed");
    This code worked when I had all the controls in the main page. But then I created components and included them in to components and now when the login is success, its giving the following error.
    ArgumentError: Undefined state 'MainMenu'.
        at mx.core::UIComponent/getState()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UI Component.as:9908]
        at mx.core::UIComponent/findCommonBaseState()[E:\dev\4.0.0\frameworks\projects\framework\src \mx\core\UIComponent.as:9928]
        at mx.core::UIComponent/commitCurrentState()[E:\dev\4.0.0\frameworks\projects\framework\src\ mx\core\UIComponent.as:9750]
        at mx.core::UIComponent/setCurrentState()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\ core\UIComponent.as:9701]
        at mx.core::UIComponent/set currentState()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:6087 ]
        at components::UserLoginForm/__btnSubmit_click()[C:\Projects\WarrantyAutomation\src\componen ts\UserLoginForm.mxml:60]
    I'm sure this has something to do with accessing the states from a custom component, but I do not know how to change the state to the main menu. Please help me with this. Any help is greatly appriciated.

    Hi dasun1981,
    private function IsUserLoggedIn(evt:ResultEvent):void
                    if (evt.result.islogin.toString() == "true")
                        currentState = "MainMenu";
                    else
                        Alert.show("Login failed, please try again.", "Login Failed");
    If I am right the above function is in your userlogin component and the two components "userlogincomponent" and "maincomponent" are in main application file and the states were also defined in main application file.
    But in the function above the currentState refers to the state of the userlogin component and not the main application ...but the states are defined in main application file...that's the reason why the exception was thrown...
    Instead you replace the line in the above function with the below line:
    Application.application.currentState = "MainMenu";
    Please mark it as answer if it helped you.
    Thanks,
    Bhasker Chari

  • Creating a button that leads back into the main Pages/States from a custom component

    Hello Y'all! isnt F.C. awesome!
    BUT... just cant get a button that leads from a custom component ive made back into the main bulk of pages and states ive created to work.
    it runs a bit like this:
    Main title page...
                            Photography...
                                                 Nature (on which theres a Custom Component which when clicked leads to...)
                                                            20 different custom component states each with different pics, linked via buttons
    from each of which id love a button that led back to Photography, exiting the custom component
    ive tried the basics:      Add interaction.. when clicked.. play transition to.. state: Photography
    but to no avail
    any ideas? im at a loss!
    thanks in advance,
    Tom

    Cross component communications are an issue in Flash Catalyst 1.0. Thankfully, in Flash Catalyst 5.5 the team addressed some of those issues.
    The only idea I have for remove the 'return' button from within the component, then it should be able to get you back to the home state.
    Or, you might be able to wait a few weeks for the new version of Flash Catalyst to ship (or you can play with the older preview release on labs.adobe.com)
    Chris

  • Determining Edit/Display Mode from Within Freestyle Component

    I am new to FPM.  We are running ESS.
    I have enhanced a new Web Dynpro Component onto an Edit page of an OVP (as a Freestyle Component).
    I want the new WDC to behave differently based on the mode I am in.
    How, from within the new WDC, can I tell if I have entered the Edit page in Edit (pencil) or Display mode?
    Thanks...
    ...Mike

    Hello Mike,
    Firstly, welcome to the wonderful world of FPM
    Well, usually with FPM, you have an Edit (or Read-only) button in the top, underneath the title (Identification Region, IDR). This, being standard, has some standard FPM events behind it.
    In your freestyle WD component, you implemented IF_FPM_BUILDING_BLOCK interface, and with it you have some additional methods in your COMPONENT CONTROLLER, such as FLUSH, PROCESS_EVENT, and so on...
    In your PROCESS_EVENT method, you can basically catch all FPM events at application level. Usually you have a big CASE, something like:
    case io_event->mv_event_id.
         when ...
         when 'FPM_EDIT'. "you can find some constants behind CL_FPM_EVENT=>GC... Right now I'm not sure how it's called exactly. But it's advised to use this constants!
              You can write your code here in order to change the behavior, basically, you can do whatever.
              also, it's the same with 'FPM_READ_ONLY'
         when others.
              return.
    endcase.
    I strongly recommend you download the latest version of FPM Cookbook, or the one that is suited with your SAP NW version.
    FPM Developer's Handbook SAP NetWeaver 7.03/7.31 SP4
    Hope I made things a little more clear!
    Tudor

  • Encountering transaction statement from within a PL/SQL block

    Hi All,
    i would like to know what will be the transaction status if we use an commit or a rollback statement inside a PL/SQL procedure called from within an PL/SQL package.
    For example
    BEGIN
    select statement
    insert statement 1
    .... call to <xyz> procedure
    end;
    xyz procedure
    insert statement 2
    commit/rollback
    end of procedure
    will the insert statement 1 be commited/rollbacked when the session encounters the transaction statement inside the procedure.

    Welcome to the forum!
    Unless the procedure xyz is an autonomous transaction, then yes Insert statement 1 will be committed.

  • Cross-component: Call method of using component from within used component?

    Hi,
    I began diving into cross-component programming.
    Meanwhile after having digged into some scenarios some questions came up to my mind that I am not able to answer myself. I would appreciate your help here!
    Say we have to components.  Comp A uses Comp B (hence, B is a component usage in A)
    1) How to make them communicate not on a data level (via context binding) but on a process level, thus...
    a) can I call A's method from within B? How is the approach on a general level? - as B can be used from totally different components (like A, A1, A2 ...)
    b) perhaps the only way to do this is by firing events? If so, how can I react in A when an event in B (marked as interface event) gets fired? As it seems they do not get registered within A directly...
    I guess the question seems to be a bit tricky. Nevertheless, I think there will be plenty of you out there who used to asked them the same questions before and came up with an approach. Would be nice to hear from you.
    Best wishes,
    Marc @sap1

    Hi,
    thanks for your reply!
    Indeed, I think the nature of WDA would be just to somehow map the context from the used component to the other back and forth.
    Nevertheless, what if I would like to invoke a method of the using component from inside the used component.
    One sample for this requirement could be e.g.:
    Component B offers a tree item and a send/verify button.
    Component A uses B and has some restraints regarding what the selection should look like.
    The user taps the button in B (at runtime in the view container of A), the context gets updated in A and B and in Component A the verifyWithOwnConstraints() method gets called (through B).
    Thanks again,
    Marc

  • JTabbedPane switching from within added component

    Hey guys,
    Anyone know how/if its possible to change between JTabbedPanes
    by using a button within a component added to one of the Panes?
    Class A has a JtabbedPane in it
    and Class B extends JPanel and is added to the TabbedPane
    as a Component
    Is there anyway to have a buttonclick in class b to switch to
    another tab in the parent class?

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class AddingATab
        public static void main(String[] args)
            BasicGUI gui = new BasicGUI();
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(gui.getUIChanger(), "North");
            f.getContentPane().add(gui.getMainUI());
            f.setSize(400,400);
            f.setVisible(true);
    class BasicGUI
        JTabbedPane tabbedPane;
        public BasicGUI()
            tabbedPane = new JTabbedPane();
        public JTabbedPane getMainUI()
            JPanel
                redPanel = new JPanel(),
                bluePanel = new JPanel();
            redPanel.setBackground(Color.red);
            bluePanel.setBackground(Color.blue);
            tabbedPane.addTab("red", redPanel);
            tabbedPane.addTab("blue", bluePanel);
            return tabbedPane;
        public JPanel getUIChanger()
            JButton add = new JButton("add tab");
            add.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    String nextTab = "tab " + String.valueOf(tabbedPane.getTabCount()+1);
                    tabbedPane.addTab(nextTab, new AddOnPanel(tabbedPane));
            JPanel panel = new JPanel();
            panel.add(add);
            return panel;
    class AddOnPanel extends JPanel
        JTabbedPane tabbedPane;
        public AddOnPanel(JTabbedPane tp)
            tabbedPane = tp;
            addNavButtons();
        private void addNavButtons()
            int numberTabs = tabbedPane.getTabCount();
            JButton[] buttons = new JButton[numberTabs];
            ActionListener l = new ActionListener()
                public void actionPerformed(ActionEvent e)
                    JButton button = (JButton)e.getSource();
                    int index = tabbedPane.indexOfTab(button.getActionCommand());
                    tabbedPane.setSelectedIndex(index);
            for(int i = 0; i < buttons.length; i++)
                String ac = tabbedPane.getTitleAt(i);
                buttons[i] = new JButton(ac);
                buttons.setActionCommand(ac);
    buttons[i].addActionListener(l);
    add(buttons[i]);

  • Changing annotations from within MS Access via VBA

    I’m developing code (VBA) within MS Access to communicate with acrobat adobe. The purpose of this code is to change a particular annotation’s text and backcolor (for now). However, when I run the code the annotation property changes but it is not displayed properly. Only after I move annotation slightly then it gets refreshed (from within adobe pro). Is there a method I need to call before pddoc.save in order for it to save it correctly i.e. something similar to repaint in MS access ?
    Dim pdDoc As Acrobat.AcroPDDoc
    Dim pdPage As Acrobat.AcroPDPage
    Dim pdAnnot As Acrobat.AcroPDAnnot
    Set pdDoc = CreateObject("AcroExch.PDDoc")
    pdDoc.Open ("c:\Temp\Test.pdf")
    Set pdPage = pdDoc.AcquirePage(0) ' only have one page
    Set pdAnnot = pdPage.GetAnnot(1) ' grab the first annotation,
    pdAnnot.SetContents ("text goes here")
    pdAnnot.SetColor (255) ' make it red
    pdDoc.Save 1, "c:\Temp\Test.pdf"
    pdDoc.Close
    Set pdDoc = Nothing
    BTW it works fine when the pdf is open while running the code.

    Sure. You can call dbms_output.get_line to get the next line of output.
    Justin

  • Creating form element from within a component

    Hi all,
    I am trying to create a form element within a component
    function which is then called from a .cfm page which has the cfform
    tags. I keep getting a context validation error for the form
    element tag. Here is some sample code:
    <cfcomponent name="yourComponent">
    <cffunction name="createTag" returntype="string"
    access="public">
    <cfsavecontent variable="returnContent">
    <cfselect name="thisSelect">
    <option value="0">Value 1</option>
    </cfselect>
    </cfsaveconten>
    <cfreturn returnContent>
    </cffunction>
    </cfcomponent>
    And in the .cfm page:
    <cfform>
    <cfinvoke component="yourComponent" method="createTag"
    returnVariable="returnContent"/>
    <cfoutput>#returnContent#</cfoutput>
    </cfform>
    The error occurs in the function and it says the cfselect
    must be within a cfform. I tried the function without the save
    content and just set the output="yes" but the same error occurs.
    Any help appreciated in how to get around this. Just putting
    the code in the .cfm is not an option for this.
    Any help appreciated.
    Jim

    quote:
    Originally posted by:
    jim1234
    Thanks for the reply. Yes, that works. So it looks like it
    has to do with the function call.
    After some further investigation, I found out that a regular
    <select> works, it's just the <cfselect> that does not.
    ColdFusion wants it directly within the <cfform> tag.
    Something does not make sense. If the cfsavecontent worked in
    the cfm file, there is no reason for it not to work in a cfc.
    If you want to persue this, the next troubleshooting step is
    to copy the function to your cfm file and see if it works. I
    suspect that you are trying something simple as a proof of concept.

  • Flex List ItemRenderer : Change States from parent ?

    Hai there,
    So i created a list that uses an arrayCollection as dataProvider and an itemRenderer with 2 states : LabelState and ProgressState, the labelState is the start state and shows a Filename, the progressState is the state i need to change to when i press a "Start Upload" Button.
    This is the itemrenderer :
    <?xml version="1.0" encoding="utf-8"?>
    <s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    autoDrawBackground="true" currentState="LabelState" width="800">
    <s:states>
    <s:State name="LabelState" />
    <s:State name="ProgressState" />
    </s:states>
    <fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <fx:Script>
    <![CDATA[
    public function changeState():void
    trace("changing state for " + label_field.text);
    this.currentState = "ProgressState";
    trace(this.currentState);
    ]]>
    </fx:Script>
    <s:Label name="label_field" paddingLeft="10" maxHeight="40" paddingTop="10" paddingBottom="10" id="label_field" width="800" color="#333333" includeIn="LabelState" text="{data.label}"/>
    <mx:ProgressBar id="progress_field" left="3" top="3" bottom="3" mode="manual" chromeColor="#0096FF" includeIn="ProgressState" textAlign="center" labelPlacement="center" maximum="100" color="#FFFFFF" right="3"/>
    </s:ItemRenderer>
    This is the code for the List :
    <s:List keyUp="lst_selected_files_keyUpHandler(event)" skinClass="styles.skins.ListSkinNoHorizontal"
    borderVisible="false"
    contentBackgroundColor="#c9c9c9" contentBackgroundAlpha="1"
    id="lst_selected_files"
    width="100%" height="100%"
    alternatingItemColors="[#EAEAEA,#FAFAFA]" color="#000000"
    itemRenderer="components.ProgressLabel" dataProvider="{arr_items}" />
    <components:RemoveBar nr_of_items="{arr_items.length}" id="cmp_removeBar" hermesRYA="cmp_removeBar_hermesRYAHandler(event)" bottom="-35" width="100%" height="35" />
    This is the function that changes the states for the current "to be uploaded file":
    protected function uploadNextFile():void
    if(uploadingFile!=null) uploadingFile==null;
    popup = null;
    popup = new ProgressPanel();
    lst_selected_files.selectedIndex = currentUploadNr;
    current_progressItem = lst_selected_files.dataGroup.getElementAt(currentUploadNr) as ProgressLabel;
    current_progressItem.changeState();
    lst_selected_files.validateNow();
    For some reason the states change ... but the elements aren't visually updated, ... meaning that i still see the label and the progressbar isn't visible :/
    anyone ?

    This seems to work for me:
    <s:Application
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:mx="library://ns.adobe.com/flex/mx" >
        <s:controlBarContent>
            <s:Button label="test" click="(list1.dataGroup.getElementAt(0) as Object).test()" />
        </s:controlBarContent>
        <s:List id="list1">
            <s:dataProvider>
                <s:ArrayList>
                    <fx:Array>
                        [0,1,2]
                    </fx:Array>
                </s:ArrayList>
            </s:dataProvider>
            <s:itemRenderer>
                <fx:Component>
                    <s:ItemRenderer>
                        <fx:Script>
                            <![CDATA[
                                public function test():void {
                                    currentState = 'state2';
                            ]]>
                        </fx:Script>
                        <s:states>
                            <s:State name="state1" />
                            <s:State name="state2" />
                        </s:states>
                        <s:Rect width="50" height="50">
                           <s:fill>
                               <s:SolidColor color.state1="red" color.state2="green" />
                           </s:fill>
                        </s:Rect>
                        <mx:ProgressBar includeIn="state2" />
                    </s:ItemRenderer>
                </fx:Component>
            </s:itemRenderer>
        </s:List>
    </s:Application>
    You will probably want to override getCurrentRendererState() to do this properly tho.  This post demonstrates how to use DataRenderer instead if you would rather: http://flexponential.com/2010/02/07/using-datarenderer-to-add-custom-states-to-a-spark-lis t-renderer/
    In general you shouldn't interact with the renderers of a List directly (via getElementAt), but rather by changing the data in the List and building an ItemRenderer that reacts to those changes.  So it would be better if you did something like list1.dataProvider.getItemAt(0).changeState = true and then in your renderer override the data setter to change the state if that variable is set.

  • Can I change Filename from within Lightroom?

    I am in the Trial Period with Lightroom, having just used it for two days. I assume that one must be able to change a photo's filename from within Lightroom, but I surely can't see how to do it, having looked in the Help file and through all the menus.
    Here's what I'm trying to do. When I take photos, I create a descriptive filename that tells me what's in the image. Then I import a big batch. What I want to do is to create slideshows from those images in a different order from the importing order: maybe it's slide 23, then 15, then 10, etc. I was hoping to do this by sticking sort numbers on the front of the filenames (changing the filenames), and then sorting on the filenames to create the desired slideshow sequence.
    But, I can't find a way to change the filename within LR. If I do it outside LR, then I lose whatever work I've already done on the images.
    Am I overlooking some obvious better way to do this?
    Thanks
    Bob Chapman
    I'm running LR 1.2, Windows XP, 2 GB RAM, big disks.

    Even easier, select the image or images and press F2 to rename.<br /><br /><[email protected]> wrote in message <br />news:[email protected]..<br />> Hi Bob,<br />><br />> To change the filename for an individual file select the file from grid <br />> view and look over at the Metadata panel on the right side of the screen. <br />> Click on the filename in the metadata panel and it should change <br />> appearance to show that it can now be edited. Type Away!<br />><br />> BTW, If you are planning to make the slideshow using the LR Slideshow <br />> module, the easiest way (for me at least) is to put the slides that are <br />> going into the ss into a Collection. (Yep, time to read up on collections <br />> :) Then you can manually order the slides however you want, select them <br />> all, and use the ss Module to create the ss.<br />><br />> Enjoy!

  • Change State from Completed to Approved

    Hi All,
    I have a requirement to change the approval task state from Completed to Approved. I am using the standard approval process.
    Please let me know if anyone has done this before.
    Cheers
    Kunal Jain

    Hi,
    Have you tried in the tab " process task assignment" of process task configuration. For the particular task, you need to map " Completed" to approved by double clicking the field mapped to completed. It will give you a list of task names, you need to change it to " approved".
    I hope u have solved your problem already.
    All the best,
    Manila
    Edited by: user2070855 on Mar 14, 2011 6:12 AM

  • Maximize window state from within portlet faces hyperlink?

    Does anyone know how to implement/force window state from a hyperlink? I want to maximize the portlet window when any hyperlink is clicked from within the default view mode. The javax portlet api tags allow you to set this attribute like <portlet:actionURL windowState="maximized"/>. Is there a similar way to do this from within Creator's use of jsf? Or, am I going to have to do this within the class files? Thanks much

    Yes, does anyone know how to maximize a portlet? Thanks.

  • How can I include a javaScript files from within jsf component

    Is there any way using which I can include javascript files from my jsf component. Because otherwise I have to write all the javascript commands using writer.write which is very tedious rather than this I just want to include the javascript file which contains all the functions required. Also I want that this file should be included only once irrespective of the number of components included.
    Thanx in advance

    This doesn't depend on JSF. You need to include a script tag, like:
    <script src="/path/script.js"
    language="JavaScript" type="text/javascript"></script>
    If you want to include this only once, make a file included into every page, into which you can put other resources to be included along with this script.
    HTH,
    rs.

  • I can't call up a URL from within a component?

    Hi all. Hope you can help.
    I have a flash site that contains a component. The component
    is for a scroll bar that shows image slices of my work. The image
    slices are buttons that when clicked should call up a seperate web
    (URL) window to display the work. However when clicked the button
    doesn't work. The button im using is on (release) {getURL
    ("work.htm")} this is fom the browser/network submenu in the global
    functions menu. I think that I should be looking in the components
    menu but have no idea what function or code to use.
    Any advice would be massively helpful.
    Cheers
    Rob

    The images are added within the component as buttons. I don't
    know how to check wether the button is accessable or not? IF you
    could advise on this that would be really good. I don't think its
    tracing anything.
    Basically just want it to open a javascript URL window.
    Cheers in advance
    Rob

Maybe you are looking for