我正在尝试用JSF验证两个密码字段,但直到现在还没有好处,我在google上搜索它,但一切都是关于JSF 1.2而且非常令人困惑,我正在使用JSF 2.0.
这就是我到目前为止所做的事情:
<h:outputLabel for="password" value="Password:" />
<h:inputSecret id="password" value="#{register.user.password}" >
<f:ajax event="blur" listener="#{register.validatePassword}" render="m_password" />
</h:inputSecret>
<rich:message id="m_password" for="password"/>
<h:outputLabel for="password_2" value="Password (again):" />
<h:inputSecret id="password_2" value="#{register.user.password_2}" >
<f:ajax event="blur" listener="#{register.validatePassword}" />
</h:inputSecret>
Run Code Online (Sandbox Code Playgroud)
这就是我的控制器:
public void validatePassword() {
FacesMessage message;
if (!user.getPassword().equals(user.getPassword_2()) ){
message = new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "different password");
}else{
message = new FacesMessage(FacesMessage.SEVERITY_INFO, null, "ok");
}
FacesContext.getCurrentInstance().addMessage("form:password", message);
}
Run Code Online (Sandbox Code Playgroud)
伙计们好吗?
我想在这个菜单中创建OR条件:
<li class="#{facesContext.viewRoot.viewId == ('/company/team.xhtml' or '/company/partnerships.xhtml' ) ? 'active' : '' }"><a class="item" href="company/company.xhtml">Company</a>
<ul>
<li><a href="company/team.xhtml">Team</a></li>
<li><a href="company/partnerships.xhtml">Partnerships</a></li>
</ul>
</li>
Run Code Online (Sandbox Code Playgroud)
如果用户选择了"页面" team.xthml或" partnerships.xhtml页面",则"活动"值将在<li>标签中设置.
但我怀疑:
我有这种情况:
public class Package(){
@OneToOne(cascade=CascadeType.PERSIST)
private Product product;
@OneToOne(cascade=CascadeType.PERSIST)
private User user;
..
}
Run Code Online (Sandbox Code Playgroud)
当我尝试时session.save(package),会发生错误.我不想保存产品和包装.我只想初始化并将它们设置到我的包对象中.
那可能吗?
我正在使用Apache Commons电子邮件向我的客户发送电子邮件,但我有一个名为'SemanadaComputação'的客户(在portugues BR中),但它是'SemanadaComputação'.我尝试修改我的代码,但它没有任何工作:
public static boolean emailWithImage(String subject, String message, String emailReceiver, String imageURL) {
HtmlEmail email = new HtmlEmail();
email.setCharset("UTF-8"); // I change here, but it is not working
email.setHostName(Constantes.EMAIL_HOST_NAME);
email.setSmtpPort(587);
DefaultAuthenticator authenticator =
new DefaultAuthenticator(Constantes.EMAIL_USER, Constantes.EMAIL_PASSWORD);
email.setAuthenticator(authenticator);
email.setTLS(true);
try {
email.setFrom(Constantes.EMAIL_USER, Constantes.EMAIL_NAME);
email.setSubject(subject);
email.addTo(emailReceiver);
URL url = new URL(imageURL);
String cid = email.embed(url, "image"); /* it must be 'cid' the name of the image */
email.setHtmlMsg("<html><img src=\"cid:" + cid + "\"> <p>" + message + "</p> </html>"); /* …Run Code Online (Sandbox Code Playgroud) 我想像Eclipse一样在Eclipse中移动我的标签:
由此:

对此:

但是使用键盘快捷键,因为每次只是为了重新排序选项卡,使用鼠标这样做非常烦人.
任何的想法 ?
我必须流式传输网络摄像头视频,所以我使用ustream来做这个,它为我生成一个flash嵌入代码,我有一个关闭/打开灯的按钮,但是当我按下按钮时它会刷新整个页面,所以flash组件.
有一些方法不刷新页面仍然发送到命令?那么现在就是这样:
<h:form id="form_supervisory">
<h:panelGrid>
<h:column>
<iframe width="480" height="296" src="http://www.ustream.tv/embed/9599890" scrolling="no" frameborder="0" style="border: 0px none transparent;"> </iframe>
<h:commandButton value="Lâmpada" action="#{supervisoryc.invertBo}" />
<h:graphicImage value="#{supervisoryc.imageBo}" />
</h:column>
</h:panelGrid>
</h:form>
Run Code Online (Sandbox Code Playgroud) 这只是我现在的好奇心.在Eclipse中,这是在新的Facelet模板<head>上定义的部分,但是对于大多数模板来说是同样的事情:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
..
</head>
Run Code Online (Sandbox Code Playgroud)
我想在其上使用更清晰的代码,所以我改为:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
..
</head>
Run Code Online (Sandbox Code Playgroud)
它在开发中运行良好,但我想知道这种方法是否会在未来通过许多浏览器或设备(移动)提出任何问题.
我在班上使用逆向工程并得到这个:
@Entity
@Table(name = "user", catalog = "bytecode", uniqueConstraints =
@UniqueConstraint(columnNames = "email"))
public class User implements java.io.Serializable {
private Integer id;
private String email;
private String password;
private boolean type;
Run Code Online (Sandbox Code Playgroud)
数据库:
CREATE TABLE `bytecode`.`user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`type` bit(1) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
Run Code Online (Sandbox Code Playgroud)
但是我不想在我的属性'type'中设置'true'或'false'但是1或0.我怎么能在hibernate中做到这一点?
此致,Valter Henrique.
我收到一个char*缓冲区,其长度为10.但是我想在我的struct中连接整个内容,它们有一个变量char*.
typedef struct{
char *buffer;
//..
}file_entry;
file_entry real[128];
int fs_write(char *buffer, int size, int file) {
//every time this function is called buffer have 10 of lenght only
// I want to concat the whole text in my char* in my struct
}
Run Code Online (Sandbox Code Playgroud)
像这样的东西:
real[i].buffer += buffer;
Run Code Online (Sandbox Code Playgroud)
我怎么能在C中这样做?