问题列表 - 第24239页

ASP.NET MVC是/否具有强绑定模型MVC的单选按钮

有谁知道如何将是/否单选按钮绑定到ASP.NET MVC中强类型模型的布尔属性.

模型

public class MyClass
{
     public bool Blah { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

视图

<%@  Page Title="blah"  Inherits="MyClass"%>
    <dd>
        <%= Html.RadioButton("blah", Model.blah) %> Yes
        <%= Html.RadioButton("blah", Model.blah) %> No
    </dd>
Run Code Online (Sandbox Code Playgroud)

谢谢

解:

感谢Brian的指导,但这与他写的相反.如此 -

<%@  Page Title="blah"  Inherits="MyClass"%>
<dd>
    <%= Html.RadioButton("blah", !Model.blah) %> Yes
    <%= Html.RadioButton("blah", Model.blah) %> No
</dd>
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc boolean model radio-button

129
推荐指数
7
解决办法
14万
查看次数

Java3D:在Canvas3D上绘制2D HUD

我正在使用Java3D来渲染三维场景.我想在3d图像的顶部叠加一个二维"抬头显示器".如何在3d画布上高效绘制2D内容?

谢谢!

java 3d java-3d

5
推荐指数
1
解决办法
2597
查看次数

BOOST.IOstreams:写入bzip2的麻烦

您好我想使用Boost.IOstreams将我的数据存储到bzip2文件中.

void test_bzip()
{
namespace BI = boost::iostreams;
{
string fname="test.bz2";
  {
    BI::filtering_stream<BI::bidirectional> my_filter; 
    my_filter.push(BI::combine(BI::bzip2_decompressor(), BI::bzip2_compressor())) ; 
    my_filter.push(std::fstream(fname.c_str(), std::ios::binary|std::ios::out)) ; 
    my_filter << "test" ; 

    }//when my_filter is destroyed it is trowing an assertion.
}
};
Run Code Online (Sandbox Code Playgroud)

我做错了什么?我正在使用boost 1.42.0.

亲切的问候阿曼.

编辑 如果我删除双向选项代码正在运行:

#include <fstream> 
#include <iostream> 
#include <boost/iostreams/copy.hpp> 
#include <boost/iostreams/filter/bzip2.hpp> 
#include <boost/iostreams/device/file.hpp> 
#include <boost/iostreams/filtering_stream.hpp>
#include <string>



void test_bzip()
{
        namespace BI = boost::iostreams;
        {
                std::string fname="test.bz2";
                {
                        std::fstream myfile(fname.c_str(), std::ios::binary|std::ios::out); 
                        BI::filtering_stream<BI::output> my_filter; 
                        my_filter.push(BI::bzip2_compressor()) ; 
                        //my_filter.push(std::fstream(fname.c_str(), std::ios::binary|std::ios::out)) ; //this line will work on …
Run Code Online (Sandbox Code Playgroud)

c++ boost-iostreams bzip2

6
推荐指数
1
解决办法
2036
查看次数

使用hg在我的两台计算机之间同步我的项目

我有两台电脑:我公司的台式机和家里的便携式电脑.

现在我想使用hg使用"USB可移动磁盘"在它们之间同步项目.

所以我想知道如何实现它?

我桌面上的专业版是:D:\ work\mypro.

我使用以下命令来初始化它:

hg init
Run Code Online (Sandbox Code Playgroud)

然后我连接到卷标为"H"的USB磁盘,并使用以下命令获取克隆:

cd H:
hg init
hg clone D:\work\mypro mypro-usb
Run Code Online (Sandbox Code Playgroud)

在我使用的便携式计算机中:

cd D:
hg clone H:\mypro-usb mypro-home
Run Code Online (Sandbox Code Playgroud)

但是我不知道如果我在mypro-home中修改一些文件(删除或添加和修改)怎么办,如何使mypro-usb同步更改,我也想同步在桌面上的mypro.

怎么做?

---------------在我从richj得到答案后添加以下内容----------------

到richj:

感谢您的回复.

以下是我的做法:Pro-Com是我桌面上的项目(初始化为存储库),Pro-USB是我USB中的存储库,Pro-Home是我家用计算机中的存储库.

当我在Pro-Com中进行一些更改时,我使用以下命令:

hg add
hg push Pro-USB
Run Code Online (Sandbox Code Playgroud)

然后我将目录更改为Pro-USB,使用:

hg update
hg push Pro-Home
Run Code Online (Sandbox Code Playgroud)

在我的家用电脑中,我运行:

hg update
(make some edition)
hg commit
hg push Pro-USB
Run Code Online (Sandbox Code Playgroud)

然后USB中的存储库与我的家用电脑的存储库相同,我可以将其推送到我的桌面.

在我看来,存储库之间的操作可以通过"hg push"和"hg pull"完成,其他命令如"hg update""hg import"只能在工作副本和它的存储库之间工作.

我的理解是对的吗?

mercurial

6
推荐指数
1
解决办法
4606
查看次数

执行bash文件时出错

嗨,您好!

我在学习组合.sh文件和PHP时遇到了一些问题.我创建了一个文件test.sh,在该文件中我调用了一个名为test.php的PHP文件.

如果我双击.sh文件然后它运行完美但当我尝试从终端运行它时,我得到"命令未找到".我在我的.sh文件中的确切文件夹,但它不会工作.这是我的test.sh:

#!/bin/bash
LIB=${0/%cli/}
exec php -q ${LIB}test.php one two three
exit; 
Run Code Online (Sandbox Code Playgroud)

当我双击test.sh文件然后它返回像它所支持的argv数组.但为什么我不能从终端运行它?

php bash shell

0
推荐指数
1
解决办法
443
查看次数

boost :: lambda表达式无法编译

我尝试编写一个函数,使用boost lambda库计算两个代码字之间的汉明距离.我有以下代码:

#include <iostream>
#include <numeric>
#include <boost/function.hpp>
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/if.hpp>
#include <boost/bind.hpp>
#include <boost/array.hpp>

template<typename Container>
int hammingDistance(Container & a, Container & b) {
  return std::inner_product(
    a.begin(),
    a.end(),
    b.begin(),
    (_1 + _2),
    boost::lambda::if_then_else_return(_1 != _2, 1, 0)
  );
}

int main() {
  boost::array<int, 3> a = {1, 0, 1}, b = {0, 1, 1};
  std::cout << hammingDistance(a, b) << std::endl;
}
Run Code Online (Sandbox Code Playgroud)

而我得到的错误是:

HammingDistance.cpp: In function ‘int hammingDistance(Container&, Container&)’:
HammingDistance.cpp:15: error: no match for ‘operator+’ in ‘<unnamed>::_1 + <unnamed>::_2’ …
Run Code Online (Sandbox Code Playgroud)

c++ boost boost-lambda

4
推荐指数
1
解决办法
2223
查看次数

Spring AOP:如何获得建议方法的注释

我想用Spring/AOP和注释实现声明性安全性.正如您在下一个代码示例中所看到的,我使用了限制注释和参数"allowedRoles"来定义允许执行建议方法的人员.

    @Restricted(allowedRoles="jira-administrators")
        public void setPassword(...) throws UserMgmtException {             
               // set password code
               ...
        }
Run Code Online (Sandbox Code Playgroud)

现在,问题是在我的建议中我无法访问已定义的注释:

public Object checkPermission(ProceedingJoinPoint pjp) throws Throwable {

    Signature signature = pjp.getSignature();
    System.out.println("Allowed:" + rolesAllowedForJoinPoint(pjp));
            ...
}

private Restricted rolesAllowedForJoinPoint(ProceedingJoinPoint thisJoinPoint)
        {
            MethodSignature methodSignature = (MethodSignature) thisJoinPoint.getSignature();
            Method targetMethod = methodSignature.getMethod();

            return targetMethod.getAnnotation(Restricted.class);
        }
Run Code Online (Sandbox Code Playgroud)

上面的方法总是返回null(根本没有找到注释).有一个简单的解决方案吗?

我读了一些关于使用AspectJ代理的内容,但我不想使用这个代理.

java security spring spring-aop

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

JavaScript进度条

我希望有一个进度条,当我点击一个按钮时会显示,例如"立即验证".我的要求是检查2000个URL是否正常工作.这在程序执行时花了很多时间.因此,我需要向用户显示进度条以了解状态.我怎么能用JavaScript做到这一点?

javascript progress-bar

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

这些对象是在堆栈上还是在堆上?

如果有人能告诉我我是否理解它,我真的很感激:

class X
{
   A a1=new A(); // reference on the stack, object value on the heap
   a1.VarA=5;    // on the stack - value type
   A a2=a1;      // reference on the stack, object value on the heap
   a2.VarA=10;   // on the stack - value type         
}
Run Code Online (Sandbox Code Playgroud)

此外a1,a2引用都在堆栈上,而它们的"对象"值在堆上.但是VarA变量,它仍然是纯粹的价值类型呢?

class A
{
   int VarA;
}
Run Code Online (Sandbox Code Playgroud)

c# stack memory-management

13
推荐指数
2
解决办法
3389
查看次数

Android - 键盘弹出时调整屏幕?

当软键盘弹出时,我希望能够在Android上调整我的UI屏幕.

所以,我在下面的第一张图片和屏幕底部的EditText有类似的东西,当用户点击EditText时,我想要与第二张图片中发生的情况相同.

也就是说,EditText向上移动并且似乎"坐"在软键盘的顶部,当软键盘消失时,它应该返回到其先前的状态.

谁能让我知道接近和实现这个的最佳方法?

alt text http://img40.imageshack.us/img40/2300/keyboarddown.png


alt text http://img46.imageshack.us/img46/9339/keyboardup.png

keyboard user-interface android screen android-edittext

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