在一个表单中,我有一些带有两个commandButton的inputText,一个用于accept,一个用于cancel.如何仅对取消按钮禁用验证?
<h:form id="detailsForm">
<p:inputText id="editUsername" value="#{userController.editUser.usrUsername}" />
<p:inputText id="editFirstName" value="#{userController.editUser.usrFirstName}" />
<p:inputText id="editLastName" value="#{userController.editUser.usrLastName}" />
<p:commandButton value="Accept" update=":detailsForm" actionListener="#{userController.onDetailsEditAccept}" />
<p:commandButton value="Cancel" update=":detailsForm" actionListener="#{userController.onDetailsEditCancel}" />
</h:form>
Run Code Online (Sandbox Code Playgroud)
我已经尝试required="false"在字段上插入但它没有用.我也尝试<f:validateBean disabled="true" />在字段上插入但它没有用.
我有一个对话框来插入一些字段,其中一个是ap:编辑器,显示它被禁用而不是.编辑器主体中会显示一个奇怪的"true"字符串.代码:
<p:dialog id="insertPanel" header="Inserisci" widgetVar="dlg1" appendToBody="true" modal="true">
<h:form id="insertForm">
<h:panelGrid columns="2">
<h:outputLabel value="Nome: " for="name" />
<p:inputText id="name" value="#{controller.name}" />
<h:outputLabel value="Oggetto: " for="subject" />
<p:inputText id="subject" value="#{controller.subject}" />
<h:outputLabel value="Visibilità: " for="visibility" />
<p:inputText id="visibility" value="#{controller.visibility}" />
<h:outputLabel value="Testo: " for="text" />
<p:editor id="text" value="#{controller.text}" width="600"/>
<f:facet name="footer">
<p:commandButton actionListener="#{controller.insert}" value="Inserisci" />
</f:facet>
</h:panelGrid>
</h:form>
</p:dialog>
Run Code Online (Sandbox Code Playgroud)
显示问题的对话框图像:

正如您所看到的那样,编辑器就像被禁用,并在其正文中显示"true".
我有一个页面A打开一个弹出窗口B.页面B,在一些工作后,总是重定向到弹出窗口中的另一个页面C. 然后,页面C调度一个事件以将一些数据发送到页面A,但是页面A没有引用页面C来注册事件处理程序.我试过的代码有点像这样:
网页A:
function handler(e) {
alert(e.detail.message);
}
var popup = window.open('/PageB.aspx');
popup.addEventListener("dispatch", handler, false);
Run Code Online (Sandbox Code Playgroud)
网页B:
location.href = "PageC.aspx";
Run Code Online (Sandbox Code Playgroud)
PageC:
var event = new CustomEvent(
"dispatch",
{
detail: {
message: "Test"
},
bubbles: true,
cancelable: true
}
);
window.dispatchEvent(event);
Run Code Online (Sandbox Code Playgroud)
但这不起作用,因为当我重定向时,PageA错过了对PageC的引用.有谁知道解决这个问题的方法?非常感谢你!
有没有办法自定义rowEditor按钮?我的意思是,如果可以更改图像或添加文本.如果不可能,有没有办法获得与按钮或链接等其他控件相同的行为?
我在会话范围内有一个JSF托管bean,它包含要跟踪的实体,例如,经过身份验证的用户:
@ManagedBean
@SessionScoped
public class LoginController implements Serializable {
User user;
public User getUser() {
return this.user;
}
public void setUser(User user) {
this.user = user;
}
/* ... */
}
Run Code Online (Sandbox Code Playgroud)
在另一个bean中,我必须注入用户以使用它来检索与之关联的角色列表,如下所示:
@ManagedBean
@ViewScoped
public class AnotherController implements Serializable {
List<Role> roles;
@ManagedProperty(value="#{loginController.user}")
User user;
public someMethod() {
/* Some stuff that insert other roles into database, referring the user as owner */
roles = user.getRolesList();
}
}
Run Code Online (Sandbox Code Playgroud)
如果我使用ajax更新页面someMethod,roles列表仍然无法重新加载.如果我em.refresh(user)在user.getRolesList收到此错误之前插入:
Can not refresh …Run Code Online (Sandbox Code Playgroud) 我有一个从SMTP服务器下载电子邮件的bean.阅读电子邮件后,它会在服务器上保存附件.要阅读附件,我使用以下代码:
File f = new File("\\attachments\\" + attachment.getFileName());
f.mkdirs();
f.createNewFile();
FileOutputStream fos = new FileOutputStream(f);
fos.write(bytes);
fos.close();
Run Code Online (Sandbox Code Playgroud)
我在FileOutputStream上创建了一个FileNotFoundException,我无法理解为什么.如果可以提供帮助,我将NetBeans与GlassFish一起使用,并在本地计算机上进行调试.
我有一个流并行执行一系列操作,然后我必须将结果写入文件,所以我需要写入操作是顺序的,但是它需要作为一个流来执行,我有很多数据要写入,我不能使用中间集合。有没有办法做到这一点?
我想到了一个看起来不太干净的解决方案,那就是让写法同步。这种方法是唯一可能的吗?还有其他方法吗?
谢谢你。
java ×4
jsf-2 ×4
primefaces ×3
asp.net ×1
custom-event ×1
editor ×1
file ×1
java-8 ×1
java-stream ×1
javascript ×1
jpa-2.0 ×1
popup ×1
validation ×1