问:
equals() method comparison for two different list implementations
Below is the program to compare two different list implementations. When I run this, getting true as a result.

I want to understand the behaviour of this equals() method in this case.

```<code>package com.tests;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class ListsTest {
    public static void main(String[] args) {
        List listA = new ArrayList<>();
        List listB = new LinkedList<>();
        Object object = new Object();
        Integer integer = new Integer(4);
        listA.add(object);
        listB.add(object);
        System.out.println(listA.equals(listB));
    }
}
</code>```

答:
ArrayList and LinkedList are both AbstractLists. From the documentation:

Returns true if and only if the specified object is also a list, both lists have the same size, and all corresponding pairs of elements in the two lists are equal.

Both of your lists contains one element - the variable object, so they are same as they are both lists.

Body:
Below is the program to compare two different list implementations. When I run this, getting true as a result.

I want to understand the behaviour of this equals() method in this case.

package com.tests;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class ListsTest {
    public static void main(String[] args) {
        List listA = new ArrayList<>();
        List listB = new LinkedList<>();
        Object object = new Object();
        Integer integer = new Integer(4);
        listA.add(object);
        listB.add(object);
        System.out.println(listA.equals(listB));
    }
}


来源: stackexchange

问:
Command bar button error visualization whit IsDynamicOverflowEnabled
I have a simple bar commander with buttons. when I try to resize the window, with IsDynamicOverflowEnabled enabled, when there is no space in the command bar, the primary buttons move to the secondary ones.
This creates this graphic problem:

The Select button is cut.

this is the XAML of commandBar:

```<code><CommandBar x:Name="command" DefaultLabelPosition="Right" IsDynamicOverflowEnabled="True">
</code>```

this is for for any appBarButton:

```<code><AppBarButton x:Name="searchAppBarButton" Style="{StaticResource AppBarButtonRevealStyle}" ToolTipService.ToolTip="Search" Click="searchAppBarButton_Click" Label="Search">
     <AppBarButton.Content>
            <FontIcon x:Name="IconSearch" FontFamily="Segoe MDL2 Assets" Glyph="" />
     </AppBarButton.Content>
</AppBarButton>
</code>```

UPDATE:
I found the problem, the problem is the style AppBarButtonRevealStyle of the appbarbutton.
removing the style works correctly.
this is the complete code:

```<code>        <CommandBar Background="Transparent" DefaultLabelPosition="Right" IsDynamicOverflowEnabled="True">
        <CommandBar.Content>
            <TextBlock Margin="10,0,0,0" Style="{StaticResource HeaderTextBlockStyle}"
                    FontSize="40"
                    Text="Command Bar"/>
        </CommandBar.Content>
        <CommandBar.PrimaryCommands>
            <AppBarButton  ToolTipService.ToolTip="Layout" Style="{StaticResource AppBarButtonRevealStyle}" Label="Layout">
                <AppBarButton.Content>
                    <FontIcon FontFamily="Segoe MDL2 Assets" Glyph="" />
                </AppBarButton.Content>
            </AppBarButton>
            <AppBarButton  ToolTipService.ToolTip="Layout" Style="{StaticResource AppBarButtonRevealStyle}" Label="Layout">
                <AppBarButton.Content>
                    <FontIcon FontFamily="Segoe MDL2 Assets" Glyph="" />
                </AppBarButton.Content>
            </AppBarButton>
            <AppBarButton  ToolTipService.ToolTip="Layout" Style="{StaticResource AppBarButtonRevealStyle}" Label="Layout">
                <AppBarButton.Content>
                    <FontIcon FontFamily="Segoe MDL2 Assets" Glyph="" />
                </AppBarButton.Content>
            </AppBarButton>
            <AppBarButton  ToolTipService.ToolTip="Layout" Style="{StaticResource AppBarButtonRevealStyle}" Label="Layout">
                <AppBarButton.Content>
                    <FontIcon FontFamily="Segoe MDL2 Assets" Glyph="" />
                </AppBarButton.Content>
            </AppBarButton>
        </CommandBar.PrimaryCommands>
        <CommandBar.SecondaryCommands>
            <AppBarButton x:Name="clearAllRecentDocument" ToolTipService.ToolTip="Clear All"
                          Label="Clear All"
                          Icon="Delete" LabelPosition="Collapsed" ></AppBarButton>
        </CommandBar.SecondaryCommands>
</code>```

答:
Phew! After a lot of trial and looking into deeper sections of the style with the visual states, it turns out the issue that was causing that kinda problem was quite simple to resolve.

Background:

So the IsDynamicOverflowEnabled property of the control is bounded with the 3 Visual States namely:

Overflow

OverflowWithToggleButtons

OverflowWithMenuIcons

Now, in your case the OverflowWithMenuIcons visual state is triggered (This is more of an FYI, just in case you want to apply some kind of special behaviors on the trigger).

The Issue:

The issue is that in the Style AppBarButtonRevealStyle, on the top, there are two Setters:

```<code><Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="Width" Value="68" />
</code>```

Because of which, even though the content gets adapted to the new layout, the AppBarButton still has a HardCoded Width of 68. Also, since the HorizontalAlignment is set to left, even if the control took more width it would still not cover the whole clickable area.

The Solution:

Well it's simple, Setting the Width to Auto would allow the content to automatically change it's width and setting the HorizontalAlignment to Stretch would allow the control to expand itself to stretch till the parent's width that'll cover the click area. The modified code is as below:

```<code><Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Width" Value="Auto" />
</code>```

How to get the style?

It's simple too, click on the AppBarButtonRevealStyle in your code and press F12, it'll open the Generic.xaml, copy the style from there (since you can't modify it there) and paste it in the <Page.Resources> Tag of your xaml and then replace the above code.

Just for reference I've put the modified style below:

Modified Style:

```<code><Page.Resources>
    <Style TargetType="AppBarButton" x:Key="AppBarButtonRevealStyle">
        <Setter Property="Background" Value="{ThemeResource AppBarButtonRevealBackground}" />
        <Setter Property="Foreground" Value="{ThemeResource AppBarButtonForeground}" />
        <Setter Property="BorderBrush" Value="{ThemeResource AppBarButtonRevealBorderBrush}" />
        <Setter Property="BorderThickness" Value="{ThemeResource AppBarButtonRevealBorderThemeThickness}" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
        <Setter Property="FontWeight" Value="Normal" />
        <Setter Property="Width" Value="Auto" />
        <Setter Property="UseSystemFocusVisuals" Value="True" />
        <Setter Property="AllowFocusOnInteraction" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="AppBarButton">
                    <Grid x:Name="Root"
                    MinWidth="{TemplateBinding MinWidth}"
                    MaxWidth="{TemplateBinding MaxWidth}"
                    Background="{TemplateBinding Background}">
                        <Grid.Resources>
                            <Style x:Name="LabelOnRightStyle" TargetType="AppBarButton">
                                <Setter Property="Width" Value="NaN" />
                            </Style>
                        </Grid.Resources>

                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="ApplicationViewStates">
                                <VisualState x:Name="FullSize" />
                                <VisualState x:Name="Compact">

                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentViewbox" Storyboard.TargetProperty="Margin">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="0,14,0,14" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="LabelOnRight">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentViewbox" Storyboard.TargetProperty="Margin">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="12,14,0,14" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentRoot" Storyboard.TargetProperty="MinHeight">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarThemeCompactHeight}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel" Storyboard.TargetProperty="(Grid.Row)">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="0" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel" Storyboard.TargetProperty="(Grid.Column)">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="1" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel" Storyboard.TargetProperty="TextAlignment">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Left" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel" Storyboard.TargetProperty="Margin">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="8,15,12,17" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="LabelCollapsed">

                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentRoot" Storyboard.TargetProperty="MinHeight">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarThemeCompactHeight}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Overflow">
                                    <VisualState.Setters>
                                        <Setter Target="ContentRoot.MinHeight" Value="0" />
                                        <Setter Target="ContentViewbox.Visibility" Value="Collapsed" />
                                        <Setter Target="TextLabel.Visibility" Value="Collapsed" />
                                        <Setter Target="OverflowTextLabel.Visibility" Value="Visible" />
                                    </VisualState.Setters>
                                </VisualState>
                                <VisualState x:Name="OverflowWithToggleButtons">
                                    <VisualState.Setters>
                                        <Setter Target="ContentRoot.MinHeight" Value="0" />
                                        <Setter Target="ContentViewbox.Visibility" Value="Collapsed" />
                                        <Setter Target="TextLabel.Visibility" Value="Collapsed" />
                                        <Setter Target="OverflowTextLabel.Visibility" Value="Visible" />
                                        <Setter Target="OverflowTextLabel.Margin" Value="38,0,12,0" />
                                    </VisualState.Setters>
                                </VisualState>
                                <VisualState x:Name="OverflowWithMenuIcons">
                                    <VisualState.Setters>
                                        <Setter Target="ContentRoot.MinHeight" Value="0" />
                                        <Setter Target="ContentViewbox.HorizontalAlignment" Value="Left" />
                                        <Setter Target="ContentViewbox.VerticalAlignment" Value="Center" />
                                        <Setter Target="ContentViewbox.Width" Value="16" />
                                        <Setter Target="ContentViewbox.Height" Value="16" />
                                        <Setter Target="ContentViewbox.Margin" Value="12,0,12,0" />
                                        <Setter Target="TextLabel.Visibility" Value="Collapsed" />
                                        <Setter Target="OverflowTextLabel.Visibility" Value="Visible" />
                                        <Setter Target="OverflowTextLabel.Margin" Value="38,0,12,0" />
                                    </VisualState.Setters>

                                </VisualState>
                                <VisualState x:Name="OverflowWithToggleButtonsAndMenuIcons">
                                    <VisualState.Setters>
                                        <Setter Target="ContentRoot.MinHeight" Value="0" />
                                        <Setter Target="ContentViewbox.HorizontalAlignment" Value="Left" />
                                        <Setter Target="ContentViewbox.VerticalAlignment" Value="Center" />
                                        <Setter Target="ContentViewbox.Width" Value="16" />
                                        <Setter Target="ContentViewbox.Height" Value="16" />
                                        <Setter Target="ContentViewbox.Margin" Value="38,0,12,0" />
                                        <Setter Target="TextLabel.Visibility" Value="Collapsed" />
                                        <Setter Target="OverflowTextLabel.Visibility" Value="Visible" />
                                        <Setter Target="OverflowTextLabel.Margin" Value="76,0,12,0" />
                                    </VisualState.Setters>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal">

                                    <Storyboard>
                                        <PointerUpThemeAnimation Storyboard.TargetName="OverflowTextLabel" />
                                    </Storyboard>
                                </VisualState>

                                <VisualState x:Name="PointerOver">
                                    <VisualState.Setters>
                                        <Setter Target="Root.(RevealBrush.State)" Value="PointerOver" />
                                        <Setter Target="Root.Background" Value="{ThemeResource AppBarButtonRevealBackgroundPointerOver}" />
                                        <Setter Target="Border.BorderBrush" Value="{ThemeResource AppBarButtonRevealBorderBrushPointerOver}" />
                                        <Setter Target="Content.Foreground" Value="{ThemeResource AppBarButtonForegroundPointerOver}" />
                                        <Setter Target="TextLabel.Foreground" Value="{ThemeResource AppBarButtonForegroundPointerOver}" />
                                        <Setter Target="OverflowTextLabel.Foreground" Value="{ThemeResource AppBarButtonForegroundPointerOver}" />
                                    </VisualState.Setters>

                                    <Storyboard>
                                        <PointerUpThemeAnimation Storyboard.TargetName="OverflowTextLabel" />
                                    </Storyboard>
                                </VisualState>

                                <VisualState x:Name="Pressed">
                                    <VisualState.Setters>
                                        <Setter Target="Root.(RevealBrush.State)" Value="Pressed" />
                                        <Setter Target="Root.Background" Value="{ThemeResource AppBarButtonRevealBackgroundPressed}" />
                                        <Setter Target="Border.BorderBrush" Value="{ThemeResource AppBarButtonRevealBorderBrushPressed}" />
                                        <Setter Target="Content.Foreground" Value="{ThemeResource AppBarButtonForegroundPressed}" />
                                        <Setter Target="TextLabel.Foreground" Value="{ThemeResource AppBarButtonForegroundPressed}" />
                                        <Setter Target="OverflowTextLabel.Foreground" Value="{ThemeResource AppBarButtonForegroundPressed}" />
                                    </VisualState.Setters>

                                    <Storyboard>
                                        <PointerDownThemeAnimation Storyboard.TargetName="OverflowTextLabel" />
                                    </Storyboard>
                                </VisualState>

                                <VisualState x:Name="Disabled">
                                    <VisualState.Setters>
                                        <Setter Target="Root.Background" Value="{ThemeResource AppBarButtonRevealBackgroundDisabled}" />
                                        <Setter Target="Border.BorderBrush" Value="{ThemeResource AppBarButtonRevealBorderBrushDisabled}" />
                                        <Setter Target="Content.Foreground" Value="{ThemeResource AppBarButtonForegroundDisabled}" />
                                        <Setter Target="TextLabel.Foreground" Value="{ThemeResource AppBarButtonForegroundDisabled}" />
                                        <Setter Target="OverflowTextLabel.Foreground" Value="{ThemeResource AppBarButtonForegroundDisabled}" />
                                    </VisualState.Setters>
                                </VisualState>
                                <VisualState x:Name="OverflowNormal">

                                    <Storyboard>
                                        <PointerUpThemeAnimation Storyboard.TargetName="ContentRoot" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="OverflowPointerOver">
                                    <VisualState.Setters>
                                        <Setter Target="Root.Background" Value="{ThemeResource AppBarButtonRevealBackgroundPointerOver}" />
                                        <Setter Target="Border.BorderBrush" Value="{ThemeResource AppBarButtonRevealBorderBrushPointerOver}" />
                                        <Setter Target="Content.Foreground" Value="{ThemeResource AppBarButtonForegroundPointerOver}" />
                                        <Setter Target="TextLabel.Foreground" Value="{ThemeResource AppBarButtonForegroundPointerOver}" />
                                        <Setter Target="OverflowTextLabel.Foreground" Value="{ThemeResource AppBarButtonForegroundPointerOver}" />
                                    </VisualState.Setters>

                                    <Storyboard>
                                        <PointerUpThemeAnimation Storyboard.TargetName="ContentRoot" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="OverflowPressed">
                                    <VisualState.Setters>
                                        <Setter Target="Root.Background" Value="{ThemeResource AppBarButtonRevealBackgroundPressed}" />
                                        <Setter Target="Border.BorderBrush" Value="{ThemeResource AppBarButtonRevealBorderBrushPressed}" />
                                        <Setter Target="Content.Foreground" Value="{ThemeResource AppBarButtonForegroundPressed}" />
                                        <Setter Target="TextLabel.Foreground" Value="{ThemeResource AppBarButtonForegroundPressed}" />
                                        <Setter Target="OverflowTextLabel.Foreground" Value="{ThemeResource AppBarButtonForegroundPressed}" />
                                    </VisualState.Setters>

                                    <Storyboard>
                                        <PointerDownThemeAnimation Storyboard.TargetName="ContentRoot" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="InputModeStates">
                                <VisualState x:Name="InputModeDefault" />
                                <VisualState x:Name="TouchInputMode">
                                    <VisualState.Setters>
                                        <Setter Target="OverflowTextLabel.Padding" Value="0,11,0,13" />
                                    </VisualState.Setters>
                                </VisualState>
                                <VisualState x:Name="GameControllerInputMode">
                                    <VisualState.Setters>
                                        <Setter Target="OverflowTextLabel.Padding" Value="0,11,0,13" />
                                    </VisualState.Setters>
                                </VisualState>
                            </VisualStateGroup>

                        </VisualStateManager.VisualStateGroups>
                        <Grid x:Name="ContentRoot" MinHeight="{ThemeResource AppBarThemeMinHeight}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>

                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Viewbox x:Name="ContentViewbox"
                            Height="20"
                            Margin="0,14,0,4"
                            HorizontalAlignment="Stretch"
                            AutomationProperties.AccessibilityView="Raw" >
                                <ContentPresenter x:Name="Content"
                                Height="20"
                                Content="{TemplateBinding Icon}"
                                Foreground="{TemplateBinding Foreground}"/>
                            </Viewbox>
                            <TextBlock x:Name="TextLabel"
                            Grid.Row="1"
                            Text="{TemplateBinding Label}"
                            Foreground="{TemplateBinding Foreground}"
                            FontSize="12"
                            FontFamily="{TemplateBinding FontFamily}"
                            TextAlignment="Center"
                            TextWrapping="Wrap"
                            Margin="2,0,2,6"
                            AutomationProperties.AccessibilityView="Raw" />
                            <TextBlock x:Name="OverflowTextLabel"
                            Text="{TemplateBinding Label}"
                            Foreground="{TemplateBinding Foreground}"
                            FontSize="15"
                            FontFamily="{TemplateBinding FontFamily}"
                            TextAlignment="Left"
                            TextTrimming="Clip"
                            TextWrapping="Wrap"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Center"
                            Margin="12,0,12,0"
                            Padding="0,5,0,7"
                            Visibility="Collapsed"
                            AutomationProperties.AccessibilityView="Raw" />
                            <Border
                            x:Name="Border"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Grid.RowSpan="2" Grid.ColumnSpan="2"/>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</Page.Resources>
</code>```

I hope this solves the query, please do let me know if there is anything in the comments section

ContentLicense: CC BY-SA 3.0

Body:
I have a simple bar commander with buttons. when I try to resize the window, with IsDynamicOverflowEnabled enabled, when there is no space in the command bar, the primary buttons move to the secondary ones.
This creates this graphic problem:

The Select button is cut.

this is the XAML of commandBar:

<CommandBar x:Name="command" DefaultLabelPosition="Right" IsDynamicOverflowEnabled="True">

this is for for any appBarButton:

<AppBarButton x:Name="searchAppBarButton" Style="{StaticResource AppBarButtonRevealStyle}" ToolTipService.ToolTip="Search" Click="searchAppBarButton_Click" Label="Search">
     <AppBarButton.Content>
            <FontIcon x:Name="IconSearch" FontFamily="Segoe MDL2 Assets" Glyph="" />
     </AppBarButton.Content>
</AppBarButton>

UPDATE:
I found the problem, the problem is the style AppBarButtonRevealStyle of the appbarbutton.
removing the style works correctly.
this is the complete code:

        <CommandBar Background="Transparent" DefaultLabelPosition="Right" IsDynamicOverflowEnabled="True">
        <CommandBar.Content>
            <TextBlock Margin="10,0,0,0" Style="{StaticResource HeaderTextBlockStyle}"
                    FontSize="40"
                    Text="Command Bar"/>
        </CommandBar.Content>
        <CommandBar.PrimaryCommands>
            <AppBarButton  ToolTipService.ToolTip="Layout" Style="{StaticResource AppBarButtonRevealStyle}" Label="Layout">
                <AppBarButton.Content>
                    <FontIcon FontFamily="Segoe MDL2 Assets" Glyph="" />
                </AppBarButton.Content>
            </AppBarButton>
            <AppBarButton  ToolTipService.ToolTip="Layout" Style="{StaticResource AppBarButtonRevealStyle}" Label="Layout">
                <AppBarButton.Content>
                    <FontIcon FontFamily="Segoe MDL2 Assets" Glyph="" />
                </AppBarButton.Content>
            </AppBarButton>
            <AppBarButton  ToolTipService.ToolTip="Layout" Style="{StaticResource AppBarButtonRevealStyle}" Label="Layout">
                <AppBarButton.Content>
                    <FontIcon FontFamily="Segoe MDL2 Assets" Glyph="" />
                </AppBarButton.Content>
            </AppBarButton>
            <AppBarButton  ToolTipService.ToolTip="Layout" Style="{StaticResource AppBarButtonRevealStyle}" Label="Layout">
                <AppBarButton.Content>
                    <FontIcon FontFamily="Segoe MDL2 Assets" Glyph="" />
                </AppBarButton.Content>
            </AppBarButton>
        </CommandBar.PrimaryCommands>
        <CommandBar.SecondaryCommands>
            <AppBarButton x:Name="clearAllRecentDocument" ToolTipService.ToolTip="Clear All"
                          Label="Clear All"
                          Icon="Delete" LabelPosition="Collapsed" ></AppBarButton>
        </CommandBar.SecondaryCommands>

Body:
Phew! After a lot of trial and looking into deeper sections of the style with the visual states, it turns out the issue that was causing that kinda problem was quite simple to resolve.

Background:

So the IsDynamicOverflowEnabled property of the control is bounded with the 3 Visual States namely:

Overflow

OverflowWithToggleButtons

OverflowWithMenuIcons

Now, in your case the OverflowWithMenuIcons visual state is triggered (This is more of an FYI, just in case you want to apply some kind of special behaviors on the trigger).

The Issue:

The issue is that in the Style AppBarButtonRevealStyle, on the top, there are two Setters:

<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="Width" Value="68" />

Because of which, even though the content gets adapted to the new layout, the AppBarButton still has a HardCoded Width of 68. Also, since the HorizontalAlignment is set to left, even if the control took more width it would still not cover the whole clickable area.

The Solution:

Well it's simple, Setting the Width to Auto would allow the content to automatically change it's width and setting the HorizontalAlignment to Stretch would allow the control to expand itself to stretch till the parent's width that'll cover the click area. The modified code is as below:

<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Width" Value="Auto" />

How to get the style?

It's simple too, click on the AppBarButtonRevealStyle in your code and press F12, it'll open the Generic.xaml, copy the style from there (since you can't modify it there) and paste it in the <Page.Resources> Tag of your xaml and then replace the above code.

Just for reference I've put the modified style below:

Modified Style:

<Page.Resources>
    <Style TargetType="AppBarButton" x:Key="AppBarButtonRevealStyle">
        <Setter Property="Background" Value="{ThemeResource AppBarButtonRevealBackground}" />
        <Setter Property="Foreground" Value="{ThemeResource AppBarButtonForeground}" />
        <Setter Property="BorderBrush" Value="{ThemeResource AppBarButtonRevealBorderBrush}" />
        <Setter Property="BorderThickness" Value="{ThemeResource AppBarButtonRevealBorderThemeThickness}" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
        <Setter Property="FontWeight" Value="Normal" />
        <Setter Property="Width" Value="Auto" />
        <Setter Property="UseSystemFocusVisuals" Value="True" />
        <Setter Property="AllowFocusOnInteraction" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="AppBarButton">
                    <Grid x:Name="Root"
                    MinWidth="{TemplateBinding MinWidth}"
                    MaxWidth="{TemplateBinding MaxWidth}"
                    Background="{TemplateBinding Background}">
                        <Grid.Resources>
                            <Style x:Name="LabelOnRightStyle" TargetType="AppBarButton">
                                <Setter Property="Width" Value="NaN" />
                            </Style>
                        </Grid.Resources>

                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="ApplicationViewStates">
                                <VisualState x:Name="FullSize" />
                                <VisualState x:Name="Compact">

                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentViewbox" Storyboard.TargetProperty="Margin">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="0,14,0,14" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="LabelOnRight">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentViewbox" Storyboard.TargetProperty="Margin">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="12,14,0,14" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentRoot" Storyboard.TargetProperty="MinHeight">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarThemeCompactHeight}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel" Storyboard.TargetProperty="(Grid.Row)">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="0" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel" Storyboard.TargetProperty="(Grid.Column)">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="1" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel" Storyboard.TargetProperty="TextAlignment">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Left" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel" Storyboard.TargetProperty="Margin">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="8,15,12,17" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="LabelCollapsed">

                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentRoot" Storyboard.TargetProperty="MinHeight">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource AppBarThemeCompactHeight}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="TextLabel" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Overflow">
                                    <VisualState.Setters>
                                        <Setter Target="ContentRoot.MinHeight" Value="0" />
                                        <Setter Target="ContentViewbox.Visibility" Value="Collapsed" />
                                        <Setter Target="TextLabel.Visibility" Value="Collapsed" />
                                        <Setter Target="OverflowTextLabel.Visibility" Value="Visible" />
                                    </VisualState.Setters>
                                </VisualState>
                                <VisualState x:Name="OverflowWithToggleButtons">
                                    <VisualState.Setters>
                                        <Setter Target="ContentRoot.MinHeight" Value="0" />
                                        <Setter Target="ContentViewbox.Visibility" Value="Collapsed" />
                                        <Setter Target="TextLabel.Visibility" Value="Collapsed" />
                                        <Setter Target="OverflowTextLabel.Visibility" Value="Visible" />
                                        <Setter Target="OverflowTextLabel.Margin" Value="38,0,12,0" />
                                    </VisualState.Setters>
                                </VisualState>
                                <VisualState x:Name="OverflowWithMenuIcons">
                                    <VisualState.Setters>
                                        <Setter Target="ContentRoot.MinHeight" Value="0" />
                                        <Setter Target="ContentViewbox.HorizontalAlignment" Value="Left" />
                                        <Setter Target="ContentViewbox.VerticalAlignment" Value="Center" />
                                        <Setter Target="ContentViewbox.Width" Value="16" />
                                        <Setter Target="ContentViewbox.Height" Value="16" />
                                        <Setter Target="ContentViewbox.Margin" Value="12,0,12,0" />
                                        <Setter Target="TextLabel.Visibility" Value="Collapsed" />
                                        <Setter Target="OverflowTextLabel.Visibility" Value="Visible" />
                                        <Setter Target="OverflowTextLabel.Margin" Value="38,0,12,0" />
                                    </VisualState.Setters>

                                </VisualState>
                                <VisualState x:Name="OverflowWithToggleButtonsAndMenuIcons">
                                    <VisualState.Setters>
                                        <Setter Target="ContentRoot.MinHeight" Value="0" />
                                        <Setter Target="ContentViewbox.HorizontalAlignment" Value="Left" />
                                        <Setter Target="ContentViewbox.VerticalAlignment" Value="Center" />
                                        <Setter Target="ContentViewbox.Width" Value="16" />
                                        <Setter Target="ContentViewbox.Height" Value="16" />
                                        <Setter Target="ContentViewbox.Margin" Value="38,0,12,0" />
                                        <Setter Target="TextLabel.Visibility" Value="Collapsed" />
                                        <Setter Target="OverflowTextLabel.Visibility" Value="Visible" />
                                        <Setter Target="OverflowTextLabel.Margin" Value="76,0,12,0" />
                                    </VisualState.Setters>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal">

                                    <Storyboard>
                                        <PointerUpThemeAnimation Storyboard.TargetName="OverflowTextLabel" />
                                    </Storyboard>
                                </VisualState>

                                <VisualState x:Name="PointerOver">
                                    <VisualState.Setters>
                                        <Setter Target="Root.(RevealBrush.State)" Value="PointerOver" />
                                        <Setter Target="Root.Background" Value="{ThemeResource AppBarButtonRevealBackgroundPointerOver}" />
                                        <Setter Target="Border.BorderBrush" Value="{ThemeResource AppBarButtonRevealBorderBrushPointerOver}" />
                                        <Setter Target="Content.Foreground" Value="{ThemeResource AppBarButtonForegroundPointerOver}" />
                                        <Setter Target="TextLabel.Foreground" Value="{ThemeResource AppBarButtonForegroundPointerOver}" />
                                        <Setter Target="OverflowTextLabel.Foreground" Value="{ThemeResource AppBarButtonForegroundPointerOver}" />
                                    </VisualState.Setters>

                                    <Storyboard>
                                        <PointerUpThemeAnimation Storyboard.TargetName="OverflowTextLabel" />
                                    </Storyboard>
                                </VisualState>

                                <VisualState x:Name="Pressed">
                                    <VisualState.Setters>
                                        <Setter Target="Root.(RevealBrush.State)" Value="Pressed" />
                                        <Setter Target="Root.Background" Value="{ThemeResource AppBarButtonRevealBackgroundPressed}" />
                                        <Setter Target="Border.BorderBrush" Value="{ThemeResource AppBarButtonRevealBorderBrushPressed}" />
                                        <Setter Target="Content.Foreground" Value="{ThemeResource AppBarButtonForegroundPressed}" />
                                        <Setter Target="TextLabel.Foreground" Value="{ThemeResource AppBarButtonForegroundPressed}" />
                                        <Setter Target="OverflowTextLabel.Foreground" Value="{ThemeResource AppBarButtonForegroundPressed}" />
                                    </VisualState.Setters>

                                    <Storyboard>
                                        <PointerDownThemeAnimation Storyboard.TargetName="OverflowTextLabel" />
                                    </Storyboard>
                                </VisualState>

                                <VisualState x:Name="Disabled">
                                    <VisualState.Setters>
                                        <Setter Target="Root.Background" Value="{ThemeResource AppBarButtonRevealBackgroundDisabled}" />
                                        <Setter Target="Border.BorderBrush" Value="{ThemeResource AppBarButtonRevealBorderBrushDisabled}" />
                                        <Setter Target="Content.Foreground" Value="{ThemeResource AppBarButtonForegroundDisabled}" />
                                        <Setter Target="TextLabel.Foreground" Value="{ThemeResource AppBarButtonForegroundDisabled}" />
                                        <Setter Target="OverflowTextLabel.Foreground" Value="{ThemeResource AppBarButtonForegroundDisabled}" />
                                    </VisualState.Setters>
                                </VisualState>
                                <VisualState x:Name="OverflowNormal">

                                    <Storyboard>
                                        <PointerUpThemeAnimation Storyboard.TargetName="ContentRoot" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="OverflowPointerOver">
                                    <VisualState.Setters>
                                        <Setter Target="Root.Background" Value="{ThemeResource AppBarButtonRevealBackgroundPointerOver}" />
                                        <Setter Target="Border.BorderBrush" Value="{ThemeResource AppBarButtonRevealBorderBrushPointerOver}" />
                                        <Setter Target="Content.Foreground" Value="{ThemeResource AppBarButtonForegroundPointerOver}" />
                                        <Setter Target="TextLabel.Foreground" Value="{ThemeResource AppBarButtonForegroundPointerOver}" />
                                        <Setter Target="OverflowTextLabel.Foreground" Value="{ThemeResource AppBarButtonForegroundPointerOver}" />
                                    </VisualState.Setters>

                                    <Storyboard>
                                        <PointerUpThemeAnimation Storyboard.TargetName="ContentRoot" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="OverflowPressed">
                                    <VisualState.Setters>
                                        <Setter Target="Root.Background" Value="{ThemeResource AppBarButtonRevealBackgroundPressed}" />
                                        <Setter Target="Border.BorderBrush" Value="{ThemeResource AppBarButtonRevealBorderBrushPressed}" />
                                        <Setter Target="Content.Foreground" Value="{ThemeResource AppBarButtonForegroundPressed}" />
                                        <Setter Target="TextLabel.Foreground" Value="{ThemeResource AppBarButtonForegroundPressed}" />
                                        <Setter Target="OverflowTextLabel.Foreground" Value="{ThemeResource AppBarButtonForegroundPressed}" />
                                    </VisualState.Setters>

                                    <Storyboard>
                                        <PointerDownThemeAnimation Storyboard.TargetName="ContentRoot" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="InputModeStates">
                                <VisualState x:Name="InputModeDefault" />
                                <VisualState x:Name="TouchInputMode">
                                    <VisualState.Setters>
                                        <Setter Target="OverflowTextLabel.Padding" Value="0,11,0,13" />
                                    </VisualState.Setters>
                                </VisualState>
                                <VisualState x:Name="GameControllerInputMode">
                                    <VisualState.Setters>
                                        <Setter Target="OverflowTextLabel.Padding" Value="0,11,0,13" />
                                    </VisualState.Setters>
                                </VisualState>
                            </VisualStateGroup>

                        </VisualStateManager.VisualStateGroups>
                        <Grid x:Name="ContentRoot" MinHeight="{ThemeResource AppBarThemeMinHeight}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>

                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Viewbox x:Name="ContentViewbox"
                            Height="20"
                            Margin="0,14,0,4"
                            HorizontalAlignment="Stretch"
                            AutomationProperties.AccessibilityView="Raw" >
                                <ContentPresenter x:Name="Content"
                                Height="20"
                                Content="{TemplateBinding Icon}"
                                Foreground="{TemplateBinding Foreground}"/>
                            </Viewbox>
                            <TextBlock x:Name="TextLabel"
                            Grid.Row="1"
                            Text="{TemplateBinding Label}"
                            Foreground="{TemplateBinding Foreground}"
                            FontSize="12"
                            FontFamily="{TemplateBinding FontFamily}"
                            TextAlignment="Center"
                            TextWrapping="Wrap"
                            Margin="2,0,2,6"
                            AutomationProperties.AccessibilityView="Raw" />
                            <TextBlock x:Name="OverflowTextLabel"
                            Text="{TemplateBinding Label}"
                            Foreground="{TemplateBinding Foreground}"
                            FontSize="15"
                            FontFamily="{TemplateBinding FontFamily}"
                            TextAlignment="Left"
                            TextTrimming="Clip"
                            TextWrapping="Wrap"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Center"
                            Margin="12,0,12,0"
                            Padding="0,5,0,7"
                            Visibility="Collapsed"
                            AutomationProperties.AccessibilityView="Raw" />
                            <Border
                            x:Name="Border"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Grid.RowSpan="2" Grid.ColumnSpan="2"/>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</Page.Resources>

I hope this solves the query, please do let me know if there is anything in the comments section


问:
Invalid Data Type error while casting PL/SQL Array to Table
I have a PL/SQL stored proc which needs to return a RefCursor type object as output parameter.

```<code>PROCEDURE usp_appnt_stts_driver_wraper2
( in_req_src_system_id   IN NUMBER,
  in_req_user_info       IN VARCHAR2,
  out_response_rec1      OUT SYS_REFCURSOR)
</code>```

At the end of the SP, I am able to return Hard Coded values to my front end by using a Select Statement.

```<code>OPEN out_response_rec1 FOR
SELECT 'data1', 'data2', 'data3', 'data 4' FROM DUAL;
</code>```

This works fine. But I need to send the data which I am getting from an Array.

The Array is populated like this,

```<code>FOR g_index IN g_slsnetoutbndarr.FIRST..g_slsnetoutbndarr.LAST

LOOP

  out_response_rec.EXTEND;
  IF g_SlsnetOutbndArr(g_index).Rectypdesc IS NOT NULL THEN
    out_response_rec(g_index).Rectypdesc   := g_SlsnetOutbndArr(g_index).Rectypdesc ;
    out_response_rec(g_index).Recdetltcode := g_SlsnetOutbndArr(g_index).Recdetltcode;
    out_response_rec(g_index).RecDetlDesc  := g_SlsnetOutbndArr(g_index).RecDetlDesc ;
  END IF;

 END LOOP;
</code>```

So at the end of this code, the Array Object out_response_rec has all the values I need.

But How do I transfer these values in the RefCursor output parameter?

Update 1

I have tried to create a new data type in the Package specification.

```<code>TYPE  SlsnetOutbndRec IS RECORD(
Rectypdesc    VARCHAR2(30),
Recdetltcode  NUMBER,
RecDetlDesc  VARCHAR2(130));

TYPE SlsnetOutbndTabArr IS TABLE OF SlsnetOutbndRec;
</code>```

Finally I have tried to Cast the Array to table in my SP as

```<code>OPEN out_response_rec_result FOR
SELECT * FROM TABLE (Cast(out_response_rec AS SlsnetOutbndTabArr));
</code>```

But this is throwing an Invalid Data Type error. The SP does not recognize the new data types I created.

答:
You need to create the types in the SQL scope (not the PL/SQL scope) if you want to use them in SQL statements (in versions prior to Oracle 12):

```<code>CREATE TYPE  SlsnetOutbndRec IS OBJECT(
  Rectypdesc    VARCHAR2(30),
  Recdetltcode  NUMBER,
  RecDetlDesc  VARCHAR2(130)
)
/

CREATE TYPE SlsnetOutbndTabArr IS TABLE OF SlsnetOutbndRec
/
</code>```

Then you can use it in your procedure (assuming your 3rd party data type is a collection or a VARRAY):

```<code>PROCEDURE usp_appnt_stts_driver_wraper2(
  in_req_src_system_id    IN  NUMBER,
  in_req_user_info        IN  VARCHAR2,
  out_response_rec_result OUT SYS_REFCURSOR
)
IS
  out_response_rec SlsnetOutbndTabArr := SlsnetOutbndTabArr();
  g_slsnetoutbndarr ThirdPartyDataType := Get_From_3rd_party_Package();
BEGIN
  FOR i IN 1 .. g_slsnetoutbndarr.COUNT LOOP
    IF g_SlsnetOutbndArr(i).Rectypdesc IS NOT NULL THEN
      out_response_rec.EXTEND;
      out_response_rec := SlsnetOutbndRec(
        g_SlsnetOutbndArr(i).Rectypdesc,
        g_SlsnetOutbndArr(i).Recdetltcode,
        g_SlsnetOutbndArr(i).RecDetlDesc
      );
    END IF;
  END LOOP;

  OPEN out_response_rec_result FOR
    SELECT *
    FROM TABLE( out_response_rec );
END;
</code>```

If the 3rd party data type is an associative array then:

```<code>  ...
IS
  out_response_rec SlsnetOutbndTabArr   := SlsnetOutbndTabArr();
  g_slsnetoutbndarr ThirdPartyDataType  := Get_From_3rd_party_Package();
  i                 ThirdPartyIndexType := g_slsnetoutbndarr.FIRST;
BEGIN
  WHILE i IS NOT NULL LOOP
    IF g_SlsnetOutbndArr(i).Rectypdesc IS NOT NULL THEN
      out_response_rec.EXTEND;
      out_response_rec := SlsnetOutbndRec(
        g_SlsnetOutbndArr(i).Rectypdesc,
        g_SlsnetOutbndArr(i).Recdetltcode,
        g_SlsnetOutbndArr(i).RecDetlDesc
      );
    END IF;
    i := g_slsnetoutbndarr.NEXT(i);
  END LOOP;

...
</code>```

Body:
I have a PL/SQL stored proc which needs to return a RefCursor type object as output parameter.

PROCEDURE usp_appnt_stts_driver_wraper2
( in_req_src_system_id   IN NUMBER,
  in_req_user_info       IN VARCHAR2,
  out_response_rec1      OUT SYS_REFCURSOR)

At the end of the SP, I am able to return Hard Coded values to my front end by using a Select Statement.

OPEN out_response_rec1 FOR
SELECT 'data1', 'data2', 'data3', 'data 4' FROM DUAL;

This works fine. But I need to send the data which I am getting from an Array.

The Array is populated like this,

FOR g_index IN g_slsnetoutbndarr.FIRST..g_slsnetoutbndarr.LAST

LOOP

  out_response_rec.EXTEND;
  IF g_SlsnetOutbndArr(g_index).Rectypdesc IS NOT NULL THEN
    out_response_rec(g_index).Rectypdesc   := g_SlsnetOutbndArr(g_index).Rectypdesc ;
    out_response_rec(g_index).Recdetltcode := g_SlsnetOutbndArr(g_index).Recdetltcode;
    out_response_rec(g_index).RecDetlDesc  := g_SlsnetOutbndArr(g_index).RecDetlDesc ;
  END IF;

 END LOOP;

So at the end of this code, the Array Object out_response_rec has all the values I need.

But How do I transfer these values in the RefCursor output parameter?

Update 1

I have tried to create a new data type in the Package specification.

TYPE  SlsnetOutbndRec IS RECORD(
Rectypdesc    VARCHAR2(30),
Recdetltcode  NUMBER,
RecDetlDesc  VARCHAR2(130));

TYPE SlsnetOutbndTabArr IS TABLE OF SlsnetOutbndRec;

Finally I have tried to Cast the Array to table in my SP as

OPEN out_response_rec_result FOR
SELECT * FROM TABLE (Cast(out_response_rec AS SlsnetOutbndTabArr));

But this is throwing an Invalid Data Type error. The SP does not recognize the new data types I created.

Body:
You need to create the types in the SQL scope (not the PL/SQL scope) if you want to use them in SQL statements (in versions prior to Oracle 12):

CREATE TYPE  SlsnetOutbndRec IS OBJECT(
  Rectypdesc    VARCHAR2(30),
  Recdetltcode  NUMBER,
  RecDetlDesc  VARCHAR2(130)
)
/

CREATE TYPE SlsnetOutbndTabArr IS TABLE OF SlsnetOutbndRec
/

Then you can use it in your procedure (assuming your 3rd party data type is a collection or a VARRAY):

PROCEDURE usp_appnt_stts_driver_wraper2(
  in_req_src_system_id    IN  NUMBER,
  in_req_user_info        IN  VARCHAR2,
  out_response_rec_result OUT SYS_REFCURSOR
)
IS
  out_response_rec SlsnetOutbndTabArr := SlsnetOutbndTabArr();
  g_slsnetoutbndarr ThirdPartyDataType := Get_From_3rd_party_Package();
BEGIN
  FOR i IN 1 .. g_slsnetoutbndarr.COUNT LOOP
    IF g_SlsnetOutbndArr(i).Rectypdesc IS NOT NULL THEN
      out_response_rec.EXTEND;
      out_response_rec := SlsnetOutbndRec(
        g_SlsnetOutbndArr(i).Rectypdesc,
        g_SlsnetOutbndArr(i).Recdetltcode,
        g_SlsnetOutbndArr(i).RecDetlDesc
      );
    END IF;
  END LOOP;

  OPEN out_response_rec_result FOR
    SELECT *
    FROM TABLE( out_response_rec );
END;

If the 3rd party data type is an associative array then:

  ...
IS
  out_response_rec SlsnetOutbndTabArr   := SlsnetOutbndTabArr();
  g_slsnetoutbndarr ThirdPartyDataType  := Get_From_3rd_party_Package();
  i                 ThirdPartyIndexType := g_slsnetoutbndarr.FIRST;
BEGIN
  WHILE i IS NOT NULL LOOP
    IF g_SlsnetOutbndArr(i).Rectypdesc IS NOT NULL THEN
      out_response_rec.EXTEND;
      out_response_rec := SlsnetOutbndRec(
        g_SlsnetOutbndArr(i).Rectypdesc,
        g_SlsnetOutbndArr(i).Recdetltcode,
        g_SlsnetOutbndArr(i).RecDetlDesc
      );
    END IF;
    i := g_slsnetoutbndarr.NEXT(i);
  END LOOP;

...


问:
Update Subquery Question, with foreign key
I misremembered what the key was for this Templates table and therefore I added the wrong field as a foreign key. Now I need to add the foreign key and I want to populate its values based on this other field that is already populated. I started trying to do this with an update statement, but I'm not sure how to do it.

Part of my schema:

Products Table:

```<code>ProductName (key)
TemplateName
TemplateID
...
</code>```

I've added TemplateID, but it has no data in it yet and is nullable.

Templates Table:

```<code>TemplateID (key)
TemplateName
...
</code>```

I want to use the Templates table to find the matching TemplateID for each TemplateName in the Products table and fill that in the foreign key reference in the Products table.

Can I do this with a subquery in Update, or do I need to write some kind of Stored Proc? I'm using Sql Server 2008

答:
Here's a join solution.  It's significant in that only the matched rows will be updated.

```<code>Update p
Set p.TemplateId = t.TemplateId
From Products p
  join Templates t
  On p.TemplateName = t.TemplateName
</code>```

Here's the subquery solution.  Every row of Products will be updated, even when there is no match.

```<code>Update p
Set p.TemplateId =
(
  Select t.TemplateId
  From Templates t
  Where p.TemplateName = t.TemplateName
)
From Products p
</code>```

OwnerDisplayName: Tony Peterson

ContentLicense: CC BY-SA 2.5

Body:
I misremembered what the key was for this Templates table and therefore I added the wrong field as a foreign key. Now I need to add the foreign key and I want to populate its values based on this other field that is already populated. I started trying to do this with an update statement, but I'm not sure how to do it.

Part of my schema:

Products Table:

ProductName (key)
TemplateName
TemplateID
...

I've added TemplateID, but it has no data in it yet and is nullable.

Templates Table:

TemplateID (key)
TemplateName
...

I want to use the Templates table to find the matching TemplateID for each TemplateName in the Products table and fill that in the foreign key reference in the Products table.

Can I do this with a subquery in Update, or do I need to write some kind of Stored Proc? I'm using Sql Server 2008

Body:
Here's a join solution.  It's significant in that only the matched rows will be updated.

Update p
Set p.TemplateId = t.TemplateId
From Products p
  join Templates t
  On p.TemplateName = t.TemplateName

Here's the subquery solution.  Every row of Products will be updated, even when there is no match.

Update p
Set p.TemplateId =
(
  Select t.TemplateId
  From Templates t
  Where p.TemplateName = t.TemplateName
)
From Products p

OwnerDisplayName: David B


问:
How to DELETE an element from String Array? Important: I dont want to convert my Array to a List
I have a Generic method smallestValueInArray(T[] array) and this method gets an Array of any Type. This method looks like this:

```<code>public class Helper {

    public static <T extends Comparable<T>> T smallestValueInArray(T[] array) {
        T smallestValue = array[0];
        T smallerTempValue = array[0];

        for (int i = 0; i < array.length - 2; i+=2) {

            if (array[i].compareTo(array[i+1]) < 0) {
                smallerTempValue = array[i];
            } else {
                smallerTempValue = array[i+1];
            }

            if (smallestValue.compareTo(smallerTempValue) > 0) {
                smallestValue = smallerTempValue;
            }
        }
        return smallestValue;
    }
}
</code>```

In the Main method I want to do something like this:

```<code>for (int i = 0; i < stringArray.length; i++) {
        someOtherArray[i] = Helper.smallestValueInArray(stringArray);
        Helper.deleteElement(stringArray, stringArray[i]);
    }
</code>```

So I want to loop through stringArray, find the smallest element in that Array and add that element to a new array someOtherArray. After that I want to use a method deleteElement() and this method gets two parameters, first one is an Array, and the seccond one is the element position in that Array which should be deleted.

How should my deleteElement() method look like?

Important: I dont want to convert my array in a List and than use list.remove()!

答:
Then use System.arraycopy, and the useful Arrays class.

```<code>static <T> T[] deleteAt(T[] array, int i) {
    int afteri = array.length - (i + 1);
    if (afteri > 0) {
        System.arraycopy(array, i + 1, array, i, afteri);
    }
    return array.copyOf(array, array.length - 1);
}
</code>```

Mind that for int, double and other primitive types an overloaded function would be needed.

Body:
I have a Generic method smallestValueInArray(T[] array) and this method gets an Array of any Type. This method looks like this:

public class Helper {

    public static <T extends Comparable<T>> T smallestValueInArray(T[] array) {
        T smallestValue = array[0];
        T smallerTempValue = array[0];

        for (int i = 0; i < array.length - 2; i+=2) {

            if (array[i].compareTo(array[i+1]) < 0) {
                smallerTempValue = array[i];
            } else {
                smallerTempValue = array[i+1];
            }

            if (smallestValue.compareTo(smallerTempValue) > 0) {
                smallestValue = smallerTempValue;
            }
        }
        return smallestValue;
    }
}

In the Main method I want to do something like this:

for (int i = 0; i < stringArray.length; i++) {
        someOtherArray[i] = Helper.smallestValueInArray(stringArray);
        Helper.deleteElement(stringArray, stringArray[i]);
    }

So I want to loop through stringArray, find the smallest element in that Array and add that element to a new array someOtherArray. After that I want to use a method deleteElement() and this method gets two parameters, first one is an Array, and the seccond one is the element position in that Array which should be deleted.

How should my deleteElement() method look like?

Important: I dont want to convert my array in a List and than use list.remove()!

Body:
Then use System.arraycopy, and the useful Arrays class.

static <T> T[] deleteAt(T[] array, int i) {
    int afteri = array.length - (i + 1);
    if (afteri > 0) {
        System.arraycopy(array, i + 1, array, i, afteri);
    }
    return array.copyOf(array, array.length - 1);
}

Mind that for int, double and other primitive types an overloaded function would be needed.


问:
Failed to load optimized model - GoogleMaps SDK IOS
I am getting this error after installing Google Maps SDK from CocoaPods.

```<code>CoreData: annotation:  Failed to load optimized model at path '/Users/nabeel/Library/Developer/CoreSimulator/Devices/96078737-8063-4BC1-97DB-7FECEC6835D9/data/Containers/Bundle/Application/972CD686-82DD-4357-9CDD-65A735D82190/My-APP-Beta.app/GoogleMaps.bundle/GMSCacheStorage.momd/StorageWithTileVersionID.omo'
CoreData: annotation:  Failed to load optimized model at path '/Users/nabeel/Library/Developer/CoreSimulator/Devices/96078737-8063-4BC1-97DB-7FECEC6835D9/data/Containers/Bundle/Application/972CD686-82DD-4357-9CDD-65A735D82190/My-APP-Beta.app/GoogleMaps.bundle/GMSCacheStorage.momd/StorageWithTileVersionID.omo'
CoreData: annotation:  Failed to load optimized model at path '/Users/nabeel/Library/Developer/CoreSimulator/Devices/96078737-8063-4BC1-97DB-7FECEC6835D9/data/Containers/Bundle/Application/972CD686-82DD-4357-9CDD-65A735D82190/My-APP-Beta.app/GoogleMaps.bundle/GMSCacheStorage.momd/StorageWithTileVersionID.omo'
</code>```

I have tried pod update and pod install again but same issue.

答: If you have already double-checked the basic setup for the "google maps ios-sdk" with an APIkey for your app's bundle identifier here and still have the same problem then probably you have not enabled the google maps API. Go to your app-project's dashboard on https://console.developers.google.com and click the "ENABLE APIS AND SERVICES". There, under the MAPS section select "the Google maps sdk for ios" and enable it.  </p>

ContentLicense: CC BY-SA 4.0

Body:
I am getting this error after installing Google Maps SDK from CocoaPods.

CoreData: annotation:  Failed to load optimized model at path '/Users/nabeel/Library/Developer/CoreSimulator/Devices/96078737-8063-4BC1-97DB-7FECEC6835D9/data/Containers/Bundle/Application/972CD686-82DD-4357-9CDD-65A735D82190/My-APP-Beta.app/GoogleMaps.bundle/GMSCacheStorage.momd/StorageWithTileVersionID.omo'
CoreData: annotation:  Failed to load optimized model at path '/Users/nabeel/Library/Developer/CoreSimulator/Devices/96078737-8063-4BC1-97DB-7FECEC6835D9/data/Containers/Bundle/Application/972CD686-82DD-4357-9CDD-65A735D82190/My-APP-Beta.app/GoogleMaps.bundle/GMSCacheStorage.momd/StorageWithTileVersionID.omo'
CoreData: annotation:  Failed to load optimized model at path '/Users/nabeel/Library/Developer/CoreSimulator/Devices/96078737-8063-4BC1-97DB-7FECEC6835D9/data/Containers/Bundle/Application/972CD686-82DD-4357-9CDD-65A735D82190/My-APP-Beta.app/GoogleMaps.bundle/GMSCacheStorage.momd/StorageWithTileVersionID.omo'

I have tried pod update and pod install again but same issue.


问:
Postgresql join between many tables
Ok, I used MySQL/postgres for many years before moving to MongoDB for the past 6yrs and I'm drawing some blanks now. I've been looking around on the best way to do this and with my very simple dataset the querytime is an average of 20ms. Seems crazy for < 100 rows. I probably did this the super complex way :)

So the idea here is to get a list of the lessons the user has access to, along with their LATEST quiz score and LATEST lesson progress (how far they made it in the lesson).

```<code>SELECT DISTINCT ON (m.id) m.id,m.lesson_name,m.course_name,m.order,m.progress,m.thumb,m.media_id,m.length,m.quiz_id,m.score FROM (SELECT
    lessons.id,lessons.name AS lesson_name,courses.name AS course_name, lesson_courses."order", less_prog.progress, lessons.thumb, lessons.media_id, lessons.length, lesson_quiz.id as quiz_id, acclessq.score,acclessq.timestamp as atime, less_prog.timestamp as ltime
    FROM lessons
    INNER JOIN lesson_courses ON lessons."id" = lesson_courses.lessons_id
    INNER JOIN plan_courses ON plan_courses.courses_id = lesson_courses.courses_id
    INNER JOIN courses ON courses.id = lesson_courses.courses_id
    LEFT JOIN (
        SELECT progress,lessons_id,timestamp FROM lesson_progress WHERE accounts_id = 1
    ) as less_prog ON less_prog.lessons_id = lessons.id
    LEFT JOIN (
        SELECT lesson_quiz.id,lesson_quiz.lessons_id FROM lesson_quiz
    ) as lesson_quiz ON lessons.id=lesson_quiz.lessons_id
    LEFT JOIN (
        SELECT score,lesson_quiz_id,account_lesson_quiz.timestamp FROM account_lesson_quiz WHERE account_lesson_quiz.accounts_id = 1
    ) as acclessq ON lesson_quiz.id=acclessq.lesson_quiz_id
    LEFT JOIN (
        SELECT accounts_id,plans_id FROM account_plans WHERE accounts_id = 1
    ) as account_plans ON account_plans.plans_id = plan_courses.plans_id
    GROUP BY lessons.id,courses.id,courses.name,lesson_courses.order,less_prog.progress, lessons.thumb, lessons.media_id, lessons.length, quiz_id, acclessq.score,atime,ltime
    ORDER BY courses.id, lesson_courses."order",atime DESC,ltime DESC) m
</code>```

I'm sure I've done it way too crazy, but I get the right results... So how can I simplify it and get the performance down for when we have more results?

UPDATE: Tried rewriting using WITH's. Dropped perf to an average of 15ms. It does look much cleaner but I still feel it's way too high for this little amount of data.

```<code>WITH lesson_quiz AS (SELECT lesson_quiz.id,lesson_quiz.lessons_id FROM
lesson_quiz),
less_prog AS (SELECT progress,lessons_id,timestamp FROM lesson_progress
WHERE accounts_id = 1),
acclessq AS (SELECT score,lesson_quiz_id,account_lesson_quiz.timestamp
FROM account_lesson_quiz WHERE account_lesson_quiz.accounts_id = 1),
acc_plans AS (SELECT accounts_id,plans_id FROM account_plans WHERE
accounts_id = 1)

SELECT DISTINCT ON (lessons.id)
lessons.id,lessons.name AS lesson_name,courses.name AS course_name, lesson_courses."order", less_prog.progress, lessons.thumb, lessons.media_id, lessons.length, lesson_quiz.id as quiz_id, acclessq.score
FROM lessons
INNER JOIN lesson_courses ON lessons."id" = lesson_courses.lessons_id
INNER JOIN plan_courses ON plan_courses.courses_id = lesson_courses.courses_id
INNER JOIN courses ON courses.id = lesson_courses.courses_id
LEFT JOIN less_prog ON less_prog.lessons_id = lessons.id
LEFT JOIN lesson_quiz ON lessons.id=lesson_quiz.lessons_id
LEFT JOIN acclessq ON lesson_quiz.id=acclessq.lesson_quiz_id
LEFT JOIN acc_plans ON acc_plans.plans_id = plan_courses.plans_id
ORDER BY id, acclessq.timestamp DESC, less_prog.timestamp DESC
</code>```

Here is the query plan: https://explain.depesz.com/s/IvPl

答: It ended up coming down to the computer. I was testing on my latest edition, fully maxed Macbook Pro. Switching to my desktop, I'm not consistently getting >0.9ms.</p>

Title: Postgresql join between many tables

Body:
Ok, I used MySQL/postgres for many years before moving to MongoDB for the past 6yrs and I'm drawing some blanks now. I've been looking around on the best way to do this and with my very simple dataset the querytime is an average of 20ms. Seems crazy for < 100 rows. I probably did this the super complex way :)

So the idea here is to get a list of the lessons the user has access to, along with their LATEST quiz score and LATEST lesson progress (how far they made it in the lesson).

SELECT DISTINCT ON (m.id) m.id,m.lesson_name,m.course_name,m.order,m.progress,m.thumb,m.media_id,m.length,m.quiz_id,m.score FROM (SELECT
    lessons.id,lessons.name AS lesson_name,courses.name AS course_name, lesson_courses."order", less_prog.progress, lessons.thumb, lessons.media_id, lessons.length, lesson_quiz.id as quiz_id, acclessq.score,acclessq.timestamp as atime, less_prog.timestamp as ltime
    FROM lessons
    INNER JOIN lesson_courses ON lessons."id" = lesson_courses.lessons_id
    INNER JOIN plan_courses ON plan_courses.courses_id = lesson_courses.courses_id
    INNER JOIN courses ON courses.id = lesson_courses.courses_id
    LEFT JOIN (
        SELECT progress,lessons_id,timestamp FROM lesson_progress WHERE accounts_id = 1
    ) as less_prog ON less_prog.lessons_id = lessons.id
    LEFT JOIN (
        SELECT lesson_quiz.id,lesson_quiz.lessons_id FROM lesson_quiz
    ) as lesson_quiz ON lessons.id=lesson_quiz.lessons_id
    LEFT JOIN (
        SELECT score,lesson_quiz_id,account_lesson_quiz.timestamp FROM account_lesson_quiz WHERE account_lesson_quiz.accounts_id = 1
    ) as acclessq ON lesson_quiz.id=acclessq.lesson_quiz_id
    LEFT JOIN (
        SELECT accounts_id,plans_id FROM account_plans WHERE accounts_id = 1
    ) as account_plans ON account_plans.plans_id = plan_courses.plans_id
    GROUP BY lessons.id,courses.id,courses.name,lesson_courses.order,less_prog.progress, lessons.thumb, lessons.media_id, lessons.length, quiz_id, acclessq.score,atime,ltime
    ORDER BY courses.id, lesson_courses."order",atime DESC,ltime DESC) m

I'm sure I've done it way too crazy, but I get the right results... So how can I simplify it and get the performance down for when we have more results?

UPDATE: Tried rewriting using WITH's. Dropped perf to an average of 15ms. It does look much cleaner but I still feel it's way too high for this little amount of data.

WITH lesson_quiz AS (SELECT lesson_quiz.id,lesson_quiz.lessons_id FROM
lesson_quiz),
less_prog AS (SELECT progress,lessons_id,timestamp FROM lesson_progress
WHERE accounts_id = 1),
acclessq AS (SELECT score,lesson_quiz_id,account_lesson_quiz.timestamp
FROM account_lesson_quiz WHERE account_lesson_quiz.accounts_id = 1),
acc_plans AS (SELECT accounts_id,plans_id FROM account_plans WHERE
accounts_id = 1)

SELECT DISTINCT ON (lessons.id)
lessons.id,lessons.name AS lesson_name,courses.name AS course_name, lesson_courses."order", less_prog.progress, lessons.thumb, lessons.media_id, lessons.length, lesson_quiz.id as quiz_id, acclessq.score
FROM lessons
INNER JOIN lesson_courses ON lessons."id" = lesson_courses.lessons_id
INNER JOIN plan_courses ON plan_courses.courses_id = lesson_courses.courses_id
INNER JOIN courses ON courses.id = lesson_courses.courses_id
LEFT JOIN less_prog ON less_prog.lessons_id = lessons.id
LEFT JOIN lesson_quiz ON lessons.id=lesson_quiz.lessons_id
LEFT JOIN acclessq ON lesson_quiz.id=acclessq.lesson_quiz_id
LEFT JOIN acc_plans ON acc_plans.plans_id = plan_courses.plans_id
ORDER BY id, acclessq.timestamp DESC, less_prog.timestamp DESC

Here is the query plan: https://explain.depesz.com/s/IvPl


问:
Spring Boot - There was an unexpected error (type=Bad Request, status=400). Required request body is missing
I created a simple Spring Boot REST service to handle posting data from my HTML page.  When I POST data everything is ok, but when I want to check data on @RequestMapping value href I see error message:

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Wed Nov 15 13:33:46 CET 2017
  There was an unexpected error (type=Bad Request, status=400).
  Required request body is missing: public org.springframework.http.ResponseEntity> pl.sample.atms.web.rest.QuestionRestController.getQuestions5(pl.sample.atms.dto.Question)

How Can I check and get sent data? My code:

JS:

```<code>$.ajax({
    url: 'http://localhost:8080/api/questionsPost',
    dataType: 'json',
    type: 'post',
    contentType: 'application/json',
    data: JSON.stringify(scoreObj),
    success: function( data, textStatus, jQxhr ){
        console.log(data, textStatus, jQxhr)
    },
    error: function( jqXhr, textStatus, errorThrown ){
        console.log( jqXhr, textStatus, errorThrown );
    }
});
</code>```

Rest controller:

```<code>package pl.sample.atms.web.rest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import pl.sample.atms.dao.QuestionRepository;
import pl.sample.atms.dto.Question;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping(value = "/api",  method = {RequestMethod.GET, RequestMethod.POST})
public class QuestionRestController {

    @Autowired
    private QuestionRepository questionRepository;

    @PostMapping("/questionsPost")
    public ResponseEntity<List<Question>> getQuestions5(@RequestBody Question myQuestion) {
        System.out.println(ResponseEntity.ok(new ArrayList<>()));
        System.out.println(myQuestion);
        return ResponseEntity.ok(new ArrayList<>());
    }

}
</code>```

Question dto

```<code>package pl.sample.atms.dto;

import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
public class Question {

    @Id
    private Long id;

    private String title;

    public Question() {
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }
}
</code>```

Question repository

```<code>package pl.sample.atms.dao;

import org.springframework.data.repository.CrudRepository;
import pl.sample.atms.dto.Question;

import java.util.List;

public interface QuestionRepository extends CrudRepository<Question, Long> {
    List<Question> findByTitle(String title);
}
</code>```

UPDATE

I changed Rest controller code:

```<code>package pl.sample.atms.web.rest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import pl.sample.atms.dao.QuestionRepository;
import pl.sample.atms.dao.UserInfoRepository;
import pl.sample.atms.dto.Question;
import pl.sample.atms.dto.QuestionAnswer;
import pl.sample.atms.dto.Response;
import pl.sample.atms.dto.UserInfo;

import java.util.ArrayList;
import java.util.List;

import static org.apache.commons.lang3.StringUtils.isBlank;

@RestController
@RequestMapping("/api")
public class QuestionRestController {

    @Autowired
    private QuestionRepository questionRepository;

    @Autowired
    private UserInfoRepository userInfoRepository;

    private List<Question> question = new ArrayList<Question>();

    @GetMapping(value = "/questionsGet")
    public Response getResource() {
        Response response = new Response("Done", question);
        return response;
    }

    @PostMapping(value = "/questionsPost")
    public Response postCustomer(@RequestBody Question oneQuestion) {
        question.add(oneQuestion);

        Response response = new Response("Done", oneQuestion);
        return response;
    }

}
</code>```

And I created new class - response:

```<code>package pl.sample.atms.dto;

public class Response {
    private String status;
    private Object data;

    public Response(){

    }

    public Response(String status, Object data){
        this.status = status;
        this.data = data;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
</code>```

Now I am able to see some sent data, but unfortunatelly it isn't generated and sent using JavaScript JSON, but this:

```<code>{"status":"Done","data":[{"id":null,"title":null}]}
</code>```

Structure of JSON which I need:

```<code>"{"N":["4","4","5","4","2"],"E":["4","4","5","3","1"],"O":["3","3","4","2","3"],"U":["2","2","2","2","4"],"S":["3","2","2","3","3"]}"
</code>```

I really don't know what I am doing wrong but I feel that I am close to solve this.

答:
You're restricting your method to just POST requests when using the @PostMapping annotation.

This is equivalent to:

```<code>@RequestMapping(value = "/questionsPost", method = RequestMethod.POST)
</code>```

If you want to accept both POST and GET, I would change it to:

```<code>@RequestMapping(value = "/questionsPost")
</code>```

The value suggests a Post request -> so, personally I would adjust that to just "/questions".

UPDATE
Per your comment on what you're attempting to accomplish, I would highly recommend having two separate methods.  Spring will know which method to call based on if you're posting data, or attempting to get data.  And then adjust your business logic accordingly.

one method for Post:

```<code>@RequestMapping(value = "/questions", method = RequestMethod.POST)
</code>```

one method for Get:

```<code>@RequestMapping(value = "/questions", method = RequestMethod.GET)
</code>```

Body:
I created a simple Spring Boot REST service to handle posting data from my HTML page.  When I POST data everything is ok, but when I want to check data on @RequestMapping value href I see error message:

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Wed Nov 15 13:33:46 CET 2017
  There was an unexpected error (type=Bad Request, status=400).
  Required request body is missing: public org.springframework.http.ResponseEntity> pl.sample.atms.web.rest.QuestionRestController.getQuestions5(pl.sample.atms.dto.Question)

How Can I check and get sent data? My code:

JS:

$.ajax({
    url: 'http://localhost:8080/api/questionsPost',
    dataType: 'json',
    type: 'post',
    contentType: 'application/json',
    data: JSON.stringify(scoreObj),
    success: function( data, textStatus, jQxhr ){
        console.log(data, textStatus, jQxhr)
    },
    error: function( jqXhr, textStatus, errorThrown ){
        console.log( jqXhr, textStatus, errorThrown );
    }
});

Rest controller:

package pl.sample.atms.web.rest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import pl.sample.atms.dao.QuestionRepository;
import pl.sample.atms.dto.Question;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping(value = "/api",  method = {RequestMethod.GET, RequestMethod.POST})
public class QuestionRestController {

    @Autowired
    private QuestionRepository questionRepository;

    @PostMapping("/questionsPost")
    public ResponseEntity<List<Question>> getQuestions5(@RequestBody Question myQuestion) {
        System.out.println(ResponseEntity.ok(new ArrayList<>()));
        System.out.println(myQuestion);
        return ResponseEntity.ok(new ArrayList<>());
    }

}

Question dto

package pl.sample.atms.dto;

import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
public class Question {

    @Id
    private Long id;

    private String title;

    public Question() {
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }
}

Question repository

package pl.sample.atms.dao;

import org.springframework.data.repository.CrudRepository;
import pl.sample.atms.dto.Question;

import java.util.List;

public interface QuestionRepository extends CrudRepository<Question, Long> {
    List<Question> findByTitle(String title);
}

UPDATE

I changed Rest controller code:

package pl.sample.atms.web.rest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import pl.sample.atms.dao.QuestionRepository;
import pl.sample.atms.dao.UserInfoRepository;
import pl.sample.atms.dto.Question;
import pl.sample.atms.dto.QuestionAnswer;
import pl.sample.atms.dto.Response;
import pl.sample.atms.dto.UserInfo;

import java.util.ArrayList;
import java.util.List;

import static org.apache.commons.lang3.StringUtils.isBlank;

@RestController
@RequestMapping("/api")
public class QuestionRestController {

    @Autowired
    private QuestionRepository questionRepository;

    @Autowired
    private UserInfoRepository userInfoRepository;

    private List<Question> question = new ArrayList<Question>();

    @GetMapping(value = "/questionsGet")
    public Response getResource() {
        Response response = new Response("Done", question);
        return response;
    }

    @PostMapping(value = "/questionsPost")
    public Response postCustomer(@RequestBody Question oneQuestion) {
        question.add(oneQuestion);

        Response response = new Response("Done", oneQuestion);
        return response;
    }

}

And I created new class - response:

package pl.sample.atms.dto;

public class Response {
    private String status;
    private Object data;

    public Response(){

    }

    public Response(String status, Object data){
        this.status = status;
        this.data = data;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}

Now I am able to see some sent data, but unfortunatelly it isn't generated and sent using JavaScript JSON, but this:

{"status":"Done","data":[{"id":null,"title":null}]}

Structure of JSON which I need:

"{"N":["4","4","5","4","2"],"E":["4","4","5","3","1"],"O":["3","3","4","2","3"],"U":["2","2","2","2","4"],"S":["3","2","2","3","3"]}"

I really don't know what I am doing wrong but I feel that I am close to solve this.

Body:
You're restricting your method to just POST requests when using the @PostMapping annotation.

This is equivalent to:

@RequestMapping(value = "/questionsPost", method = RequestMethod.POST)

If you want to accept both POST and GET, I would change it to:

@RequestMapping(value = "/questionsPost")

The value suggests a Post request -> so, personally I would adjust that to just "/questions".

UPDATE
Per your comment on what you're attempting to accomplish, I would highly recommend having two separate methods.  Spring will know which method to call based on if you're posting data, or attempting to get data.  And then adjust your business logic accordingly.

one method for Post:

@RequestMapping(value = "/questions", method = RequestMethod.POST)

one method for Get:

@RequestMapping(value = "/questions", method = RequestMethod.GET)


问:
How to write getters and setters for MessageId variable in java?
I am working on one of the projects. I am mapping JSON to Java object. but in json, one field is started with a capital letter as (MessageId). So I am not able to write proper getter and setter who map MessageId automatically. So can anyone suggest me a proper way?
My getters and setter are as below:-</p>

```<code>public String getMessageId() {
    return MessageId;
}

public void setMessageId(String messageId) {
    MessageId = messageId;
}
</code>```

答: Use @JsonProperty("MessageId") annotation on methods.

Body:
I am working on one of the projects. I am mapping JSON to Java object. but in json, one field is started with a capital letter as (MessageId). So I am not able to write proper getter and setter who map MessageId automatically. So can anyone suggest me a proper way?
My getters and setter are as below:-

public String getMessageId() {
    return MessageId;
}

public void setMessageId(String messageId) {
    MessageId = messageId;
}


问:
Using PrimeFaces
, fire up Ajax in inputText only on keystrokes that change the field
I am using PrimeFaces and have a p:inputText field where I need to update some components on the view based on the latest keystroke inside that p:inputText.
Here's the code:

```<code><p:inputText value="#{customerLController.surnameFilterConstraint}"
             id="surnamefilterfield">
    <p:ajax event="keyup"
            update=":custForm:custDataTable"
            listener="#{customerLController.focusSurname}"
            oncomplete="primeFacesId('surnamefilterfield')"/>
</p:inputText>
</code>```

The thing is, the above code fires up Ajax even in the case of arrow keystrokes (which I would rather avoid given the costly update). Ideally I would like a different version of p:ajax event="change" with the qualification that change is pronounced on keystrokes and not when the user hits Enter (which is what happens now).

If the p:ajax component doesn't allow a way to filter out certain keyup events, then I gather that the only (?) alternative would be to call JavaScript on the client side and then implement the Ajax call in Javascript but then I would forsake the convenience of using the PrimeFaces p:ajax component, wouldn't I?

答:
Since JSF 2.2, I am using elegant way to solve this issue.

Solution is based on combination of p:remoteCommand (as pointed out in one of comments) and  namespace http://xmlns.jcp.org/jsf/passthrough which allows you to define native HTML event attributes in JSF components.

In this case it would be:

First add new namespace to your page

```<code>xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
</code>```

Modify p:inputText and add p:remoteCommand

```<code><p:inputText id="surnamefilterfield"
          value="#{customerLController.surnameFilterConstraint}"
          pt:onkeyup="onKeyUpFilterKeyCode(event)"/>
<p:remoteCommand delay="300" name="onFilteredKeyUp"
              actionListener="#{customerLController.focusSurname}" />
</code>```

add JavaScript function

```<code>   function onKeyUpFilterKeyCode(event){
        var keyCode=event.keyCode;
        console.log("Key code = " + keyCode);
        //if key is not ENTER and not cursor/arrow keys
        if ((keyCode != 13) && !((keyCode >= 37) && keyCode <= 40)){
            //call remoteCommand
            onFilteredKeyUp();
        }
    }
</code>```

(since this JS function contains "special" XML chars follow BalusC recommendations about how to add it to JSF/XML web page)

The advantage of this approach is that you can ajaxify any native HTML event supported by component (and WEB browser) while still using JSF/Primefaces components and "JSF way" of creating WEB pages.

Title: Using PrimeFaces <p:ajax>, fire up Ajax in inputText only on keystrokes that change the field

Body:
I am using PrimeFaces and have a p:inputText field where I need to update some components on the view based on the latest keystroke inside that p:inputText.
Here's the code:

The thing is, the above code fires up Ajax even in the case of arrow keystrokes (which I would rather avoid given the costly update). Ideally I would like a different version of p:ajax event="change" with the qualification that change is pronounced on keystrokes and not when the user hits Enter (which is what happens now).

If the p:ajax component doesn't allow a way to filter out certain keyup events, then I gather that the only (?) alternative would be to call JavaScript on the client side and then implement the Ajax call in Javascript but then I would forsake the convenience of using the PrimeFaces p:ajax component, wouldn't I?

Body:
Since JSF 2.2, I am using elegant way to solve this issue.

Solution is based on combination of p:remoteCommand (as pointed out in one of comments) and  namespace http://xmlns.jcp.org/jsf/passthrough which allows you to define native HTML event attributes in JSF components.

In this case it would be:

First add new namespace to your page

xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"

Modify p:inputText and add p:remoteCommand

<p:inputText id="surnamefilterfield"
          value="#{customerLController.surnameFilterConstraint}"
          pt:onkeyup="onKeyUpFilterKeyCode(event)"/>
<p:remoteCommand delay="300" name="onFilteredKeyUp"
              actionListener="#{customerLController.focusSurname}" />

add JavaScript function

   function onKeyUpFilterKeyCode(event){
        var keyCode=event.keyCode;
        console.log("Key code = " + keyCode);
        //if key is not ENTER and not cursor/arrow keys
        if ((keyCode != 13) && !((keyCode >= 37) && keyCode <= 40)){
            //call remoteCommand
            onFilteredKeyUp();
        }
    }

(since this JS function contains "special" XML chars follow BalusC recommendations about how to add it to JSF/XML web page)

The advantage of this approach is that you can ajaxify any native HTML event supported by component (and WEB browser) while still using JSF/Primefaces components and "JSF way" of creating WEB pages.


问:
Run R script / function declaration without repeating the contents of the code?
I have R file where I write code, define functions and use them.
When I run it, I see all my code in blue repeated and afterwards it runs the code.

Please advise how to avoid this behavior.

For example:

```<code>ped2df <- function(file) {

  df <- read.pedfile(file)
  names(df) <- df[1,]
  df <- df[-1,]
  df <- gather(df)

 }
test <- lapply(files, ped2df)

Running this:

# Get ped files and convert them into long dfs:
>
> ped2df <- function(file) {
+
+   df <- read.pedfile(file)
+   names(df) <- df[1,]
+   df <- df[-1,]
+   df <- gather(df)
+
+ }
>
> test <- lapply(files, ped2df)
</code>```

I want it to run only test <- lapply(files, ped2df).

P.S

I have tried adding ; but it didn't help.

答:
If you want to use self-defined functions, but not have them displayed when you run the script you can use source("your_self_defined_functions.R").

You split your .R file into two files:

One in which you define the functions (save it as "your_self_defined_functions.R")

One where you only want to call the functions and do your analysis.

The latter should look something like this:

```<code>source("your_self_defined_functions.R")

files <- somethingsomething
test <- lapply(files, ped2df)
</code>```

And the entire your_self_defined_functions.R is run silently.

Body:
I have R file where I write code, define functions and use them.
When I run it, I see all my code in blue repeated and afterwards it runs the code.

Please advise how to avoid this behavior.

For example:

ped2df <- function(file) {

  df <- read.pedfile(file)
  names(df) <- df[1,]
  df <- df[-1,]
  df <- gather(df)

 }
test <- lapply(files, ped2df)

Running this:

# Get ped files and convert them into long dfs:
>
> ped2df <- function(file) {
+
+   df <- read.pedfile(file)
+   names(df) <- df[1,]
+   df <- df[-1,]
+   df <- gather(df)
+
+ }
>
> test <- lapply(files, ped2df)

I want it to run only test <- lapply(files, ped2df).

P.S

I have tried adding ; but it didn't help.

Body:
If you want to use self-defined functions, but not have them displayed when you run the script you can use source("your_self_defined_functions.R").

You split your .R file into two files:

One in which you define the functions (save it as "your_self_defined_functions.R")

One where you only want to call the functions and do your analysis.

The latter should look something like this:

source("your_self_defined_functions.R")

files <- somethingsomething
test <- lapply(files, ped2df)

And the entire your_self_defined_functions.R is run silently.


答: Rename your field MessageId to messageId let your Getter/ Setter as is and add @JsonProperty("MessageId") to your field messageId

Title: How to write getters and setters for MessageId variable in java?


问:
Reordering Chart Data Series
How does one reorder series used to create a chart in Excel?

For example, I go to the chart, right click > Select Data. In the left column I see series 1, series 2, to series n.

Say, I want to move series 3 after series 4, can it be done from chart view? I don't want to move the data cells in the worksheet.

I'm using Excel 2011 (mac OS X).

答:
Excel 2010 - if you're looking to reorder the series on a pivot chart:

go to your underlying pivot table

right-click on one of the Column Labels for the series you're looking to adjust (Note: you need to click on one of the series headings (i.e. 'Saturday' or 'Sunday' in the example shown below) not the 'Column Labels' text itself)

in the pop-up menu, hover over 'Move' and then select an option from the resulting sub-menu to reposition the series variable.

your pivot chart will update itself accordingly

Title: Reordering Chart Data Series


答:
If you are using Jackson then you can annotate that field with MessageId and Jackson will do the rest for you, e.g.:

```<code>@JsonProperty("MessageId")
private String messageId;

//getters and setters
</code>```

Here's the documentation.

Body:
If you are using Jackson then you can annotate that field with MessageId and Jackson will do the rest for you, e.g.:

@JsonProperty("MessageId")
private String messageId;

//getters and setters

Here's the documentation.


问:
Installing multiple Jenkins instances on same Windows machine caused issues
I recently saw a blog, which suggested two instances of Jenkins can run on same Windows machine: Two Guys Arguing, Pro Tips: Run Multiple Jenkins CI Servers on a Single Machine.

But rather than deploying the jenkins.war, I actually installed another Jenkins on top of already installed Jenkins on my Windows machine, Which caused the previous Jenkins to stop.

答:
Steps to install next jenkins instance:

You need make the full copy of working jenkins folder to second location.
for example D:\jenkins2

next you need to edit inside this folder file jenkins.xml. Modify line

```<code><arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8083 --webroot="%BASE%\war"</arguments>
</code>```

and set value --httpPort to expected value.

run cmd.exe as Administrator

inside cmd run command: sc.exe create JenkinsUpgrade binpath= "D:\jenkins2\jenkins.exe" displayname="Jenkins for Upgrade"

where JenkinsUpgrade is servicename and have to be unique,

binpath contains desired path of new jenkins instance,

displayname is the name displayed in services.

This command creates a new instance of a jenkins server in a separated directory.

To uninstall this instance you can use command sc delete JenkinsUpgrade.

Body:
Steps to install next jenkins instance:

You need make the full copy of working jenkins folder to second location.
for example D:\jenkins2

next you need to edit inside this folder file jenkins.xml. Modify line

<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8083 --webroot="%BASE%\war"</arguments>

and set value --httpPort to expected value.

run cmd.exe as Administrator

inside cmd run command: sc.exe create JenkinsUpgrade binpath= "D:\jenkins2\jenkins.exe" displayname="Jenkins for Upgrade"

where JenkinsUpgrade is servicename and have to be unique,

binpath contains desired path of new jenkins instance,

displayname is the name displayed in services.

This command creates a new instance of a jenkins server in a separated directory.

To uninstall this instance you can use command sc delete JenkinsUpgrade.