我正在研究一个广泛使用MVC设计模式的PHP项目.我希望在表单中添加验证,并且对于验证的正确位置感到好奇.
由于生成表单的方式,对回发数据的验证在视图组件中更简单,重复性更低.让视图验证响应数据是否可接受,或者应该在控制器甚至模型中实现?
有什么好处?
在使用域驱动设计时,您的服务方法是否更好地将实体作为参数或实体的id作为参数接收,以便您可以使用存储库检索方法内的实体?
例如:
public void Apply(Job job, User user)
Run Code Online (Sandbox Code Playgroud)
与
public void Apply(int jobId, int userId)
Run Code Online (Sandbox Code Playgroud) 来自维基百科:
甲蛞蝓是识别使用人类可读关键字的页面的URL的一部分.
为了使用户更容易键入URL,通常也会删除或替换特殊字符.例如,重音字符通常被英文字母中的字母取代; 标点符号通常被删除; 和空格(必须编码为%20或+)由短划线( - )或下划线(_)代替,这些更美观.
我开发了一个照片共享网站,用户可以在其上传,分享和查看照片.
所有页面都是自动生成的,没有我对标题的控制.因为照片的标题或用户的名称可能包含重音字符或空格,我需要一个功能来自动创建slugs并保持可读的URL.
我创建了以下函数来替换重音字符(èçëçî),删除标点符号和错误字符(#@&〜^!)并以破折号转换空格.
php:
function sluggable($str) {
$before = array(
'àáâãäåòóôõöøèéêëðçìíîïùúûüñšž',
'/[^a-z0-9\s]/',
array('/\s/', '/--+/', '/---+/')
);
$after = array(
'aaaaaaooooooeeeeeciiiiuuuunsz',
'',
'-'
);
$str = strtolower($str);
$str = strtr($str, $before[0], $after[0]);
$str = preg_replace($before[1], $after[1], $str);
$str = trim($str);
$str = preg_replace($before[2], $after[2], $str);
return $str;
}
Run Code Online (Sandbox Code Playgroud) 我正在努力寻找一个适当的解决方案来实现符合MVVM P&P的WPF DataGrid的排序和分页.
以下示例说明了实现按照MVVM实践进行的分页的有效方法,但排序的自定义实现(在实现分页后需要)不遵循MVVM:
我目前有一个DataGrid绑定到一个CollectionViewSource(在XAML中使用GroupDescriptions和SortDescritptions定义)绑定到我的ViewModel中的ObservableCollection.一旦通过限制DataGrid每页获取的项目数来实现Paging,它就会破坏CollectionViewSource中定义的排序,因为它只对项目的子集进行排序.MVVM下实施分页和排序的最佳方法是什么?
谢谢,
亚伦
在F#中如果我执行类似let form = new Form(Text ="MyForm")并在FSI中运行它,表单将正常显示和更新,甚至收到消息.但是,谁在抽取消息队列?此处没有Application.Run调用.我有点困惑.
我想在多台机器上运行相同的Unix命令集.我知道ssh和下面的东西.我想编写一个shell脚本来执行此操作.我可以访问bash和ksh,我在Linux Red Hat 5上.
ssh root@ip "echo \$HOME"
Run Code Online (Sandbox Code Playgroud)
但是,我有两个问题:
这可能是一个愚蠢的问题.
如何使用XCode 4中的仪器运行应用程序,例如Leaks?
我没有看到像过去那样的选项,而且我环顾四周,要么我在某处错过了,要么就在我面前.
谢谢
如何使用带注释的控制器实现AOP?
我已经搜索并找到了之前关于这个问题的两篇帖子,但似乎无法让解决方案起作用.
这就是我所拥有的:
派遣Servlet:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<context:annotation-config/>
<context:component-scan base-package="com.foo.controller"/>
<bean id="fooAspect" class="com.foo.aop.FooAspect" />
<aop:aspectj-autoproxy>
<aop:include name="fooAspect" />
</aop:aspectj-autoproxy>
</beans>
Run Code Online (Sandbox Code Playgroud)
控制器:
@Controller
public class FooController {
@RequestMapping(value="/index.htm", method=RequestMethod.GET)
public String showIndex(Model model){
return "index";
}
}
Run Code Online (Sandbox Code Playgroud)
方面:
@Aspect
public class FooAspect {
@Pointcut("@target(org.springframework.stereotype.Controller)")
public void controllerPointcutter() {}
@Pointcut("execution(* *(..))")
public void methodPointcutter() {}
@Before("controllerPointcutter()")
public void beforeMethodInController(JoinPoint jp){
System.out.println("### before controller call...");
}
@AfterReturning("controllerPointcutter() && …Run Code Online (Sandbox Code Playgroud) 我通过罗盘框架和蓝图/网格依赖使用saas.我希望能够使用媒体查询设置列的宽度,如下所示:
// /src/partials/_base.scss
$blueprint-grid-columns: 18;
@media screen and (max-width: 1024px){
// If screen res is 1024 or lower, then set grid width to 46px
$blueprint-grid-width: 46px;
}
@media screen and (max-width: 1280px){
$blueprint-grid-width: 50px;
}
@media screen and (max-width: 1600px){
$blueprint-grid-width: 76px;
}
$blueprint-grid-margin: 8px;
Run Code Online (Sandbox Code Playgroud)
这在/stylesheets/screen.css中编译:
@media screen and (max-width: 1024px) {}
@media screen and (max-width: 1280px) {}
@media screen and (max-width: 1600px) {}
Run Code Online (Sandbox Code Playgroud)
但是screen.css其余部分的值没有相应设置.我想这是有道理的,因为$ blueprint-grid-width变量是在编译时读取的,而不是在运行时读取的.
有没有办法通过使用媒体查询输出具有不同网格宽度的布局来获得屏幕分辨率?
相关github问题:https:
//github.com/chriseppstein/compass/issues/302
这主要是与语言无关的问题.
如果我正在等待两个事件完成(例如,两个IO事件或http请求),那么处理此问题的最佳模式是什么.我能想到的一件事是以下(伪js例子).
request1.onComplete = function() {
req1Completed = true;
eventsCompleted();
}
request2.onComplete = function() {
req2Completed = true;
eventsCompleted();
}
eventsCompleted = function() {
if (!req1Completed || !req2Completed) return;
// do stuff
}
Run Code Online (Sandbox Code Playgroud)
这是最有效的模式,还是有更优雅的方法来解决这个问题?
php ×2
aop ×1
architecture ×1
c# ×1
compass-sass ×1
controller ×1
css ×1
datagrid ×1
events ×1
f# ×1
forms ×1
friendly-url ×1
instruments ×1
javascript ×1
linux ×1
mvvm ×1
paging ×1
sass ×1
seo ×1
shell ×1
slug ×1
sorting ×1
spring ×1
string ×1
unix ×1
validation ×1
wpf ×1
xcode4 ×1