Lloyd
Lloyd

Reputation: 29668

Extending Sitecore and using the Sheer UI Issues

How can I display two Sheer UI dialogs in sequence? What I want to do is display an Input dialog and then a Confirm dialog once the Input dialog completes successfully.

Currently, in the Command.Run() method I just have:

        if (!args.IsPostBack) {
               SheerResponse.Input(
                    "Enter the new event date (ISO format YYYY-MM-DD):",
                    "",
                    @"\d{4}\-\d{2}\-\d{2}",
                    "'$Input' is not a valid date.",
                    100
                );

                args.WaitForPostBack();
        } else {
            ...do stuff...
        }

Upvotes: 0

Views: 2015

Answers (2)

Andrew
Andrew

Reputation: 551

In example code we show first one dialog than confirm dialog. Hope this help

    public void Run(ClientPipelineArgs args)
    {
        try
        {
            if (!args.IsPostBack)
            {
                Context.ClientPage.ClientResponse.ShowModalDialog(url.ToString(), true);
                args.WaitForPostBack();
            }
            else if (args.HasResult)
            {
                // Small job confirmation. User decide 'no'
                if (args.Result == "no")
                {
                    return;
                }

                if(args.Result == "result")
                {
                  SheerResponse.Confirm("message");
                  args.WaitForPostBack();
                }
            }
        }
        catch (EndpointNotFoundException ex)
        {
    //something 
        }
    }

Upvotes: 2

Lloyd
Lloyd

Reputation: 29668

It seems I need to get the instance of Command for the command I want to call then call Execute() on this, for example:

    private void CreateEvent(ClientPipelineArgs args)
    {
        var org_lang = Language.Current;
        Language lang = Language.Parse("en-gb");
        Language.Current = lang;
        Database db = Configuration.Factory.GetDatabase(args.Parameters["database"]);
        Item parent = db.GetItem(args.Parameters["id"], lang);

        try {
            // Create command context
            CommandContext command_context = new CommandContext(parent);

            // Get command
            Command command = CommandManager.GetCommand("fairsite:createcampaign");

            // Execute command
            command.Execute(command_context);
        } finally {
            Language.Current = org_lang;
        }
    }

Upvotes: 0

Related Questions