标签: behavior

php array_unique的奇怪行为

我正在使用以下代码来输出数组:

echo "======output without array_unique=====";
var_dump($selected);
echo "=====output with array_unique=====";
var_dump(array_unique($selected));die;                
Run Code Online (Sandbox Code Playgroud)

输出是:

======output without array_unique=====

array
  0 => 
    array
      'uri' => string 'http://localhost/conferences/tags/0caf4c990e0a385156b33fee58e7e3fb' (length=63)
      'tag' => string '1' (length=1)
      'weight' => float 4
      'selected' => string 'select' (length=6)
  1 => 
    array
      'uri' => string 'http://localhost/conferences/tags/0caf4c990e0a385156b33fee58e7e3fb' (length=63)
      'tag' => string '1' (length=1)
      'weight' => float 4
      'selected' => string 'select' (length=6)
  2 => 
    array
      'uri' => string 'http://localhost/conferences/tags/ffc709d5131f752df8aae22d7da4240f' (length=63)
      'tag' => string '2' (length=1)
      'weight' => float 4
      'selected' => string …
Run Code Online (Sandbox Code Playgroud)

php arrays behavior unique

3
推荐指数
1
解决办法
4468
查看次数

SQL中1总是等于'1'吗?

我试图确定用于将数字与相同数字的字符或字符串版本进行比较的标准SQL行为.是否SELECT 1 = '1'(或类似)总是返回某种"truthy"值(true,1,'t'等)?我已经在PostgreSQL和MySQL上做了很多确认,但我找不到整个SQL的资源.

更新:问题的目的是我试图弄清楚在选择/插入/更新/等时使用不带引号的数字是否有效.来自非数字字段,其值为数字.

mysql sql postgresql comparison behavior

3
推荐指数
1
解决办法
1218
查看次数

wicket ajax隐藏/取消隐藏可重复使用的面板,无需提交表格

我准备了一个可重复使用的面板并将其添加到我的页面.我的页面表单中有2个下拉选项.我使用来自https://cwiki.apache.org/WICKET/dropdownchoice-examples.html#DropDownChoiceExamples的ajax示例 - 注意 两个DDC工作正常(更改一个值然后隐藏/取消隐藏另一个.但它不起作用我的面板.我使用:

private final MyPanel panel1 = new MyPanel ("MyPanel"); 
panel1.setOutputMarkupPlaceholderTag(true); 
Run Code Online (Sandbox Code Playgroud)

...在DDC1中ajax行为方法:

onUpdate(AjaxRequestTarget target) { ...
    DDC2.setVisible(true); 
    panel1.setVisible(true); 
}
Run Code Online (Sandbox Code Playgroud)

我必须提交表格以隐藏/取消panel1.如何在DDC2不提交表单的情况下使其工作方式相同?

ajax wicket behavior panel

3
推荐指数
1
解决办法
3951
查看次数

具有行为的RadioButtons绑定到单个属性

  • 我有几个RadioButtons,我不想将它们中的每一个的"IsChecked"属性绑定到代码中的唯一属性.
  • 我希望有一个像"CurrentSelected"这样的属性,并根据它来设置"IsChecked".
  • 另外我不想使用转换器.
  • 我试图使用行为"ChangePropertyAction",但它看起来只是以一种方式工作.这是我的代码:

    <RadioButton
        x:Name="UpRadioButton"
        Margin="5"
        Content="Up"
        >
        <i:Interaction.Triggers>
            <ei:DataTrigger Binding="{Binding IsChecked, ElementName=UpRadioButton}" Value="True">
                <ei:ChangePropertyAction TargetObject="{Binding Mode=OneWay}" PropertyName="SelectedDirection" Value="{x:Static Enums:DirectionEnum.Up}" />
            </ei:DataTrigger>
        </i:Interaction.Triggers>
    </RadioButton>
    
    <RadioButton
        x:Name="DownRadioButton"
        Margin="5"
        Content="Down"
        >
        <i:Interaction.Triggers>
            <ei:DataTrigger Binding="{Binding IsChecked, ElementName=DownRadioButton}" Value="True">
                <ei:ChangePropertyAction TargetObject="{Binding Mode=OneWay}" PropertyName="SelectedDirection" Value="{x:Static Enums:DirectionEnum.Down}" />
            </ei:DataTrigger>
        </i:Interaction.Triggers>
    </RadioButton>
    
    <RadioButton
        x:Name="LeftRadioButton"
        Margin="5"
        Content="Left"
        >
        <i:Interaction.Triggers>
            <ei:DataTrigger Binding="{Binding IsChecked, ElementName=LeftRadioButton}" Value="True">
                <ei:ChangePropertyAction TargetObject="{Binding Mode=OneWay}" PropertyName="SelectedDirection" Value="{x:Static Enums:DirectionEnum.Left}" />
            </ei:DataTrigger>
        </i:Interaction.Triggers>
    </RadioButton>
    
    <RadioButton
        x:Name="RightRadioButton"
        Margin="5"
        Content="Right"
        >
        <i:Interaction.Triggers>
            <ei:DataTrigger Binding="{Binding IsChecked, ElementName=RightRadioButton}" Value="True">
                <ei:ChangePropertyAction TargetObject="{Binding …
    Run Code Online (Sandbox Code Playgroud)

c# wpf xaml behavior

3
推荐指数
1
解决办法
865
查看次数

简单的VHDL电路的意外行为

模拟器中信号Q_VLD1和Q_VLD2的不同延迟原因是什么? 模拟结果.它是否是模拟器的预期行为?

我使用Xilinx Isim.它有代码和测试平台:

entity assign_test is
    port(CLK   : in  STD_LOGIC;
         D_VLD : in  STD_LOGIC;
         Q_VLD1 : out STD_LOGIC;
         Q_VLD2 : out STD_LOGIC
    );
end assign_test;

architecture Behavioral of assign_test is
    signal D_VLD_i : std_logic;
    signal d_vld_dly1 : std_logic;
    signal d_vld_dly2 : std_logic;
begin
    D_VLD_i <= D_VLD;

    process (clk) is
    begin
        if rising_edge(clk) then
            d_vld_dly1 <= D_VLD;
            d_vld_dly2 <= D_VLD_i;
        end if;
    end process ;

    Q_VLD1 <= d_vld_dly1;
    Q_VLD2 <= d_vld_dly2;
end Behavioral;


ENTITY tb_assign_test IS
END tb_assign_test;
ARCHITECTURE …
Run Code Online (Sandbox Code Playgroud)

behavior delay vhdl

3
推荐指数
1
解决办法
70
查看次数

如何通过Behavior清除绑定到ViewModel的WPF PasswordBox?

我写了WPF MVVM Prism 6.2应用程序.在登录窗口(即PrismUserControl)的视图中,我在视图模型中将PaswordBox绑定(通过行为)到"密码"属性.每次在应用程序运行时调用登录窗口时,PasswordBox必须为空. (例如,在用户关闭当前会话之后,他或她必须只看到Shell上方的空Shell和登录窗口.)我的问题是上面的 PasswordBox仅在应用程序加载后第一次显示为空.如果PaswordBox在第二次或第三次显示等,则它不为空.请看下面的图片:

在此输入图像描述

如您所见,密码不为空,但在这种情况下它必须为空.以下是来自登录窗口标记的XAML片段,其中PaswordBox为:

. . . . . . . . . . . . . .
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
. . . . . . . . . . . . . .
<PasswordBox Grid.Row="1" Grid.Column="1" Height="30" Margin="0 10 5 0" AutomationProperties.AutomationId="UserPasswordBox">
        <i:Interaction.Behaviors>
            <behavior:PasswordBoxBindingBehavior Password="{Binding Password}"/>
        </i:Interaction.Behaviors>
</PasswordBox>
. . . . . . . . . . . . . . . .
Run Code Online (Sandbox Code Playgroud)

下面是XAML中涉及的行为类,如上所示:

public class PasswordBoxBindingBehavior : Behavior<PasswordBox>
{
    protected override void …
Run Code Online (Sandbox Code Playgroud)

c# wpf behavior mvvm

3
推荐指数
1
解决办法
2765
查看次数

BottomSheetDialog get Behavour 总是返回 null

我使用BottomSheetDialog并且我必须获得 Behavior 以便可以设置setBottomSheetCallback()来处理一些东西。

正如谷歌所说,我必须将 Coordinator 放在 parentView 上并向其添加行为。我在 MainActivity(根活动)中定义了 CoordinatorLayout,如下所示:

<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:tag="coordinatorLayout"
    app:layout_behavior="android.support.design.widget.BottomSheetBehavior"

...
Run Code Online (Sandbox Code Playgroud)

这是尝试从活动中获取:

 public void setupDialog(final Dialog dialog, int style) {

 CoordinatorLayout coordinatorLayout = getActivity().getWindow().getDecorView();
 BottomSheetBehavior behavior = BottomSheetBehavior.from(coordinatorLayout);
Run Code Online (Sandbox Code Playgroud)

我也试过:

CoordinatorLayout coordinatorLayout = getActivity().getWindow().getDecorView().findViewById(R.id.coordinatorLayout); 
//this is point to the coordinatorView 

BottomSheetBehavior behavior = BottomSheetBehavior.from(coordinatorLayout);
//But this returns same error that "The view is not a child of CoordinatorLayout"
Run Code Online (Sandbox Code Playgroud)

如您所见,我通过了协调器布局,但方法无法在其中找到行为。我还应该提到使用BottonSheetDialog 的要点

  1. 我像这样显示我的 BottonSheetFragments:
  2. 我在 OnCreateView(而不是 setupDialog())中膨胀了我的BottomSheetDialog,以便在里面添加 …

android behavior android-coordinatorlayout

3
推荐指数
1
解决办法
2934
查看次数

java.lang.IllegalStateException:这种处理程序无法附加到多个组件

这个例外:

java.lang.IllegalStateException: this kind of handler cannot be attached to multiple components; it is already attached to component [MarkupContainer [Component id = textField1]], but component [MarkupContainer [Component id = textField2]] wants to be attached too
at org.apache.wicket.behavior.AbstractAjaxBehavior.bind(AbstractAjaxBehavior.java:70)
at org.apache.wicket.Component.add(Component.java:973)
at info.ems.wicket.page.HomePage.<init>(HomePage.java:23)
Run Code Online (Sandbox Code Playgroud)

由以下代码抛出:

public class HomePage extends MasterPage {

    public HomePage() {
        AjaxEventBehavior ajaxOnClickBehavior = new AjaxEventBehavior("onClick") {

            private static final long serialVersionUID = 1L;

            @Override
            protected void onEvent(AjaxRequestTarget target) {
                // Same behavior of both the textField1 and textField2
            } …
Run Code Online (Sandbox Code Playgroud)

java ajax wicket behavior

2
推荐指数
1
解决办法
1109
查看次数

如何调用所有事件处理程序订阅者并获取其结果?

我有这个片段:

public static void Main()
{
    OnComparaison += LePlusPetit;
    OnComparaison += LePlusGrand;
    Console.WriteLine(OnComparaison(0, 9));
    Console.ReadKey();
}

public static int LePlusPetit(object obj1, object obj2)
{
    int int1 = (int)obj1;
    int int2 = (int)obj2;
    return (int1 < int2) ? int1 : int2;
}

public static int LePlusGrand(object obj1, object obj2)
{
    int int1 = (int)obj1;
    int int2 = (int)obj2;
    return (int1 > int2) ? int1 : int2;
}

public delegate int Comparer(object obj1, object obj2);
public static event Comparer OnComparaison;
Run Code Online (Sandbox Code Playgroud)

我一直都是这样的结果9 …

.net c# oop events behavior

2
推荐指数
1
解决办法
901
查看次数

CakePHP 3.0时间戳行为

我想在用户登录时更新users表中的时间戳.我创建了一个名为'lastLogin'的日期时间字段.

从我的用户控制器的登录操作我打电话:

$user = $this->Auth->identify();
if ($user) {
     $this->Auth->setUser($user);
     $this->Users->touch($this->Users->get($user['id']), 'Users.afterLogin');
}
Run Code Online (Sandbox Code Playgroud)

在我的用户表中,我有:

$this->addBehavior('Timestamp', [
    'events' => [
        'Model.beforeSave' => [
            'created' => 'new',
            'modified' => 'always',
        ],
        'Users.afterLogin' => [
            'lastLogin' => 'always'
        ]
    ]
]);
Run Code Online (Sandbox Code Playgroud)

我已经测试过触发了事件并且正在更新实体属性.但是它不会保存到数据库中.

是这个意图,即我必须明确保存实体,还是我错过了什么?

谢谢!

安德

timestamp cakephp behavior cakephp-3.0

2
推荐指数
1
解决办法
2063
查看次数