Show a custom component on button click in a view stack`

Hello folks
I have a view stack in which i have some custom components.
Now there is one custom component in which there is one button. On the button click, i want to show another custom component but i dont know how to do it. Should i write the inline mxml click event in custom component?? If yes then how??
Currently i am doing it as
click="{customcomponent}"

As you know, ViewStack  has containers, lilke VBox for its views.
Assuming one of your views VBox has an id of myVBox, and that VBox has the Button that when clicked will display the component, just have the component in the view already, but you can make it invisible with visible=false and includeInLayout=false, and then upon button click set those two variables to true.
You will probably want a show handler for the view VBox to make those properties false each time that view is displayed.
Here is some simple sample code.
If this post answers your question or helps, please mark it as such.
---------- MySimpleComponent.mxml ----------
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
  width="100%" height="100%" horizontalAlign="center">
  <mx:Label text="My Custom Component"/>
</mx:VBox>
---------- MainApp.mxml  ----------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  xmlns:comp="*" horizontalAlign="center" verticalAlign="middle">
  <mx:Script>
    <![CDATA[
    ]]>
  </mx:Script>
  <mx:LinkBar dataProvider="{vs}"/>
  <mx:ViewStack id="vs" width="100%" height="100%">
    <mx:VBox label="view1" width="100%" height="100%"
      horizontalAlign="center">
      <mx:Label text="View One"/>
    </mx:VBox>
    <mx:VBox label="view2"  width="100%" height="100%"
      show="myComp.visible=false;myComp.includeInLayout=true;"
      horizontalAlign="center">
      <mx:Label text="View Two"/>
      <mx:Button label="Make myComp Visible" click="myComp.visible=true;myComp.includeInLayout=true;"/>
      <comp:MySimpleComponent id="myComp" visible="false" includeInLayout="false"/>
    </mx:VBox>
  </mx:ViewStack>
</mx:Application>

Similar Messages

  • Flex 4 custom component with children inserted directly into view stack

    I give up. Hopefully I am just missing something easy, but I feel like I am pulling teeth trying to get this to work. All I want is a custom 'wizard' component whose children are placed within a ViewStack and beneath the ViewStack there is a next and back button. Here are some code excerpts to illustrate my approach:
    WizardGroup.as:
    [SkinPart(required="true")]
    public var nextBt:Button = new Button();
    [SkinPart(required="true")]
    public var backBt:Button = new Button();
    [SkinPart(required="true")]
    public var stack:ViewStackSpark = new ViewStackSpark();
    WizardGroupSkin.mxml:
    <s:VGroup width="100%" height="100%"
              paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10">
         <container:ViewStackSpark id="stack" width="100%" height="100%">
              <s:Group id="contentGroup" width="100%" height="100%" minWidth="0" minHeight="0"/>
         </container:ViewStackSpark>
         <s:HGroup horizontalAlign="right" width="100%">
              <s:Button id="nextBt" label="Next" enabled="{hostComponent.permitNext}" enabled.last="false"/>
              <s:Button id="backBt" label="Back" enabled="{hostComponent.permitBack}" enabled.first="false"/>
         </s:HGroup>
    </s:VGroup>
    While this comes very close to working, the major problem is that the children of the WizardGroup component are not added as children of the viewstack. Instead, they are added as children of the contentGroup. So the viewstack will always only have one child: contentGroup.
    I also tried the approach of binding the contents of the view stack to the children of contentGroup, but with Spark containers, there is no way to access an array of children or array of elements (ie, there is no contentGroup.getChildren() or contentGroup.getElements()).  Finally, I tried making the id of the ViewStackSpark "contentGroup" but since the ViewStackSpark inherits from BorderContainer, Flex complains at runtime that it can't cast the BorderContainer to Group.
    Help would be greatly appreciated.
    Thanks everyone.
    Josh

    I finally figured it out. The trick is to set the default property of the WizardGroup to a public member array I am calling "content"
    [DefaultProperty("content")]
    public class WizardGroup extends TitleWindow
        [SkinPart(required="true")]
        public var nextBt:Button = new Button();
        [SkinPart(required="true")]
        public var backBt:Button = new Button();
        [Bindable]
        public var content:Array;
    And then within the skin, bind the content of the viewstack to the hostComponent's content array:
            <s:VGroup width="100%" height="100%"
                      paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10">
                <container:ViewStackSpark id="stack" width="100%" height="100%" content="{hostComponent.content}"/>
                <s:HGroup horizontalAlign="right" width="100%">
                    <s:Button id="nextBt" label="Next" enabled="{hostComponent.permitNext}" enabled.last="false"/>
                    <s:Button id="backBt" label="Back" enabled="{hostComponent.permitBack}" enabled.first="false"/>
                </s:HGroup>
            </s:VGroup>

  • Show the custom popup window on clicking the people name in sharepoint people search result

    Show the custom popup window on clicking the people name in sharepoint people search result
    We are doing the below code to open a popup but while clicking on name link its postback the page and not opening the popup in first click but opening in second click.The same issue occurs while navigate to second page using pagination
    The below code used to show name in item template
    <button id="NameFieldLink" class="temp" style="font-size: 12px;text-decoration:none;color:#0072c6;border:0px solid #fff;background:transparent;margin-left: 1px;height: 15px;padding: 0 10px 17px 0px;text-align: left;cursor:pointer;font-family:
    Arial, Helvetica, sans-serif;" title="">_#= DisName =#_</button> 
    The below jquery code used to open popup in control search template
    ctx.OnPostRender = []; 
    ctx.OnPostRender.push(function () {
    $(".temp").on("click", function(event)
    event.preventDefault();
    $('#fadeout').show();
    $('#pop1').find('.tab-content-people').html($(this).closest('.emp-card').find('.pop-content').html());
    $('#pop1').show();
    return false;

    I believe the issue is that you are not actually searching against the result source you made in step #1.
    It's not enough to make a result source, you have to tell the search results web part to use it.
    Try this:
    1. Go to the Pages library of Search Center
    2. Create a new Search Results page
    3. Edit the page, then edit the search results web part
    4. Change the source for the search results web part to your source
    5. Add the page to your Search Center navigation
    6. Run the search on that page
    Scot
    Author,
    Microsoft SharePoint 2013 App Development
    Author,
    Professional Business Connectivity Services
    Author,
    Inside SharePoint 2013
    Blog, www.shillier.com
    Twitter, @ScotHillier
    SharePoint Trainer, Critical Path Training

  • Hide/Show a graph based on button click .

    I have to show a graph based on the values selected in the shuttle . The graph should be drawn only when a button( "Show graph") is clicked . My question is
    1) If the set the button's action to submit, it resets and empties the selected values in the shuttle . How do I prevent that ?
    2) How do I make the graph appear and disappear based on the button click ( Like a toggle button ) ?
    3) As I can draw the graph only from the values selected in the shuttle , the query parsing fails . However , the graph displays when the shuttle get populated with selected values . Is there a way to get around that .
    Thanks for your help .

    There is nothing wrong with your code, so I'd look elsewhere for the problem. Is this a direct copy of what you have on your page?
    :P1_COMBO1 in ('Option 1', 'Option 2')
    And
    :P1_COMBO2 = 'Option Combo 2'And the page item values are exactly as you have in the quoted strings? You might run the page in debug and confirm the page item values are exact.
    Edited by: Bob37 on Dec 6, 2011 2:18 PM

  • Sharepoint 2010 Custom Visual Webpart button click event firing on page refresh

    I have developed a Visual Webpart to create a list in SP using vs2010 and  the button click event I have written the list create method. If I click the button list is created successfully.  And I refresh the page again list is creating(Again button
    click event is triggering).please help me to solve the issue.
     protected void Button1_Click(object sender,
    EventArgs e)
                SPWeb web
    = SPContext.Current.Web;
                //SPList list=web.Lists["Auto"];
                SPList list
    = web.Lists[DropDownList2.SelectedItem.Text];
                if
    (string.IsNullOrEmpty(TextBox1.Text)
    || string.IsNullOrEmpty(DropDownList1.Text))
    Label4.Text =
    "Fields Are Empty";
                else
    if (DropDownList1.SelectedItem.Text
    == "Single line of Text")
                    list.Fields.Add(TextBox1.Text,
    SPFieldType.Text,
    true);
    SPView viewname = list.Views["All Items"];
                    viewname.ViewFields.Add(TextBox1.Text);
    //viewname.Update();
                    list.Update();
    Label4.Text =
    "Field Created Successfully";
    TextBox1.Text =
    string.Empty;
    // Label4.Text = string.Empty;

    Hi,
    This is because the request is sent to the server when you refresh the page.
    A workaround for this is that we can “provide a refresh link that redirects to the same page (or if you have some action causing the refresh programmatically, you could just
    redirect to the page after that, with Response.Redirect)
    so that page is requested by the browser (with GET method, default with hyperlinks)”.
    More information:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/45648b39-1229-405c-ac9e-60eb82905982/click-event-getting-fired-on-page-refresh
    Or we can use the Session to save a value which used as a flag for us to check whether it is a page refresh and perform accordingly.
    http://www.codeproject.com/Articles/28099/Refresh-Page-Issue-in-ASP-Net
    http://www.codeproject.com/Articles/10240/Detecting-Page-Refresh
    Thanks
    Patrick Liang
    TechNet Community Support

  • Cappture search button click of a view criteria

    Hi is it possible to capture the click of a view criteria "Search filter". Search button click?
    Also, is it possible to have teh default of a view criteria to be set at "ALL" or "ANY"

    To listen to the search button's click, you can use the ADF JavaScript API. The AF:Query compoment will raise an event of type "query" when the search button is clicked.
    See the first code snippet in the post below:
    http://myadfnotebook.blogspot.com/2011/09/loading-screen-spinner-pop-up-v20.html
    -Jeevan

  • How to Show new Form when play button click?

    Hai all,
    i have 3 file. the first is quiz.as that contain two button. play and invite friend.quiz.fla. and quizapp.***. when i click play button i want to show the quiz that store in quizapp.as. int the quiz.as i have the mouse event that call quiapp.but when i run i got an error:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at QuizApp/createButtons()
        at QuizApp()
        at Quiz/playQuiz()
    in createButtons(), i create three button next,prev and finish.
    whereas, in my quiz.fla library i have drag the button into my library but the error show nuul object reference for the button that i have created. can you help me to give some advice or sample code??

    Can you please elaborate more as the problem is not quite clear.
    However if you have the button instances placed on the stage already check if you have tick the "automatically declare stage instances" in your publish settings.
    Attach your code in a zip on this forum may be we can solve it then.
    P.S. :- Also you can access these buttons available in stage only in the document class.

  • Show/ Hide region based on button click

    Hi,
    I have two report regions. When I press generate report button then, one region has to be displayed.
    I have an item "select list with submit " and if select some value from the LOV in the select list then the second region has to be displayed. Over all only one region has to be displayed at a time.
    Thanks in advance.

    See this thread for a possible answer: Hide/Show Region With Javascript
    Thank you,
    Tony Miller
    Webster, TX

  • Removing inputtext component by button click

    Hi,
    I m able to add input text component dynamically by the following code.
    public String cb1_action() {
    // Add event code here...
    System.out.println("in cb1_action3 - 1");
    UIComponent button;
    button = findComponentInRoot("cb1");
    RichPanelGroupLayout pgl;
    pgl = (RichPanelGroupLayout)button.getParent();
    List<UIComponent> children;
    children = pgl.getChildren();
    RichInputText it;
    it = new RichInputText();
    it.setLabel("New textbox " + (children.size() ));
    children.add(it);
    AdfFacesContext.getCurrentInstance().addPartialTarget(pgl);
    System.out.println("in cb1_action3 - 1 done");
    return null;
    but how to remove the same inputtext field/component dynamically???

    Hi,
    Try to remove the component from the
    List<Component> childs = (List<Component>)pgl.getChildren();
    childs.remove(inputText);//pass the component
    AdfFacesContext.getCurrentInstance().addPartialTarget(pgl);

  • How to listen for actionContent button click event in View

    Hello,
    Doing this:
    FlexGlobals.topLevelApplication.addEventListener('actionContentClick',showOptions);
    Results in calling showOptions() as many times as the view was showed. The handler sticks and each time I enter a view in the creationComplete hander for it I add the same listener over and over again.
    How should this be done?
    1. FlexGlobals.topLevelApplication is the right object to listen to?
    2. I can remove the listener on view deactivate, but I am not sure if that will be called each time the view goes away.
    3. Can I check if an object already has a listener and which is it?
    Thank you.

    Thank you, Tom.
    I was complicating things for myself by exposing methods in the main MXML file to add and remove and listen to click events on a button placed in the actionContent, instead of declaring it in MXML for each and adding a listener to it. Views had different actionContent buttons or rather icons for them.
    In regards to hasEvenListener, can I also get the method(s) attached to that? Probably not though.

  • 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

  • Hide/show a form upon button click

    Hi
    I want to show/hide different form upon button clicks. Also I want to clear the data from a form upon button clicks. How can I achecive this? Thanks in advance.

    Hi,
    Create one boolean variable in your datastore. Click of the button should set the value to false and you can bind the same variable to the visibility property so that you can hide and display accordingly. For making the values blank, you can put condition on the detault value formula IF(!<your datastore variable>,"",<value needed>)
    Regards,
    Murtuza

  • Show/hide panels on button click

    Hello,
    I have to show/hides several panels on same palette on some button actions. I am trying to check whether it is possible to add each child panel in different .fr files.
    Just to brief,  On panel I have different icon buttons and on each button I have to show different view in the main panel thus I cannot use tabular dialog. Please help me to find a way to achieve this?
    I tried following code
    I have Created two primary resource panel in TestSample1.fr,TestSample2.fr files respctively.
    My main panel (Palette panel) have two buttons (TestSample1Button,TestSample2Button).
    I want to show/hide these panels on button click in main panel.
    InterfacePtr<IPanelControlData> parentPanelCtrlData(Utils<IPalettePanelUtils>()->QueryPanelByWidgetID(kMainPanelWidgetID) ); // main panel
    if(parentPanelCtrlData)
        InterfacePtr<IControlView>         testSample1PanelPanelView((IControlView*)::CreateObject(::GetDataBase(this),kTestSample1P anelWidgetBoss,IID_ICONTROLVIEW));
        if(testSample1PanelPanelView)
            parentPanelCtrlData->AddWidget(testSample1PanelPanelView);
    I have added above code on TestSample1Button observer.But it is not working.
    is It possible? can anybody help me?

    Yes it is possible.
    I am not sure but following line of code also needed after adding widget .
    testSample1PanelPanelView->ForceRedraw(testSample1PanelPanelView->GetDrawRegion(), kTrue);

  • Custom Component vs. States

    Dear Catalyst team,
    After trying to work around the 15 states limitation by converting them into custom components. I ran into the problem that the pages of those custom components have the tendency to change their apearance relatively to the first page of the custom component. As a result, moving a button element up a bit from the first page to the next will, when running, move the same element up EACH time I click it, moving it out of the screen eventually. Is there a way to anchor the elements in a custom component? Otherwise, by the complex nature of my project, I might run into a dead end. Please let me know if you know of any solution.
    All the best,
    Wulffrunner

    ok, got it:)
    so how about this:
    Can I trigger action sequences outside of the custom component
    using buttons that are in the custom component, and vice-versa?
    Haven't found a way to do this yet...

  • 'loading' symbol on button click

    Hi,
    I have a requirement where user want to see 'loading' icon (the circle that rotates in center of window when backend operation is in process) below a search button.
    Is there any way to have this 'loading' icon at the place we want on screen?
    Please help.
    Thanks & Regards,
    Amey

    Hi,
    To my knowledge, this is not possible in a direct way.
    However, you could use the following workaround:
    - export a portal theme, unzip, and extract the image from ur.zip under common/loading
    - store this image in the mime folder of your WD component, and embed this image at the preferred position in your view, showing and hiding upon a button click
    Hope this helps!
    Robin van het Hof

Maybe you are looking for