升级到 Mojarra 2.2.3 后,我发现了一些奇怪的行为。以下 Javascript 声明被破坏:
在 .xhtml 文件中:
<script type="text/javascript">
<!-- /* <![CDATA[ */
$(document).ready(function() {
if ($('#some_identifier').size() > 0)
...
/* ]]> */-->
</script>
Run Code Online (Sandbox Code Playgroud)
这被混淆成以下废话:
<script type="text/javascript">
<!-- /* <![CDATA[ */
$(document).ready(function() {
if ($('#some_identifier').size() > 0)
...
/* ]]> */-->
</script>
Run Code Online (Sandbox Code Playgroud)
这会破坏 .xhtml 文件中嵌入的所有 javascript 代码。我确认我们之前使用的版本 (2.0.x) 不会发生这种情况,所以我必须假设它与新的 Mojarra 版本有关。关于如何解决此问题或解决此问题的任何想法?
我有一个命令链接:
<h:commandLink value="Delete"
onclick="return confirm('Are you sure?');"
action="#{bean.deleteDestination(destination, '/destination/show')}" />
Run Code Online (Sandbox Code Playgroud)
它调用此托管 bean 操作方法:
public String deleteDestination(Destination selected, String action) {
List<Flight> flights = getEjbFlightFacade().findFlightWithDestination(selected);
if (flights.isEmpty()) {
getEjbDestinationFacade().remove(selected);
setDestinations(getEjbDestinationFacade().findAll());
}
else {
// Here need to show an alert() that user can't remove the item.
}
return action;
}
Run Code Online (Sandbox Code Playgroud)
如评论所示,我想表明alert()最终用户无法删除该项目。我怎样才能做到这一点?
我正在将旧项目从 JSF 1.1 升级到 JSF 2.2。具体来说,我将 JSF 实现从 MyFaces 1.1 升级到 MyFaces 2.2.12,用 Facelets 替换 JSP 并升级/替换过时的标签库。我主要使用从 JSF 1.2 迁移到 JSF 2.0作为指南。
该项目使用了一些在其 JSP 页面中htmLib使用命名空间调用的标记库http://jsftutorials.net/htmLib。我再也找不到关于这个标签库的任何文档,无论是在 jsftutorials 网页还是其他地方,但显然它被用来包含像JSP 页面<div>或<table>在 JSP 页面中的纯 HTML 标签。
由于现在可以在带有 JSF2 的 XML Facelets 中使用纯 HTML 标记,因此我现在正在从htmLibtaglib 中删除所有出现的标记,<htm:div>...</htm:div>例如<div>...</div>.
但是,从使用的一些标签htmLib包含render用于条件渲染的属性,如下所示:
<htmLib:h4 render="someCondition">
...
</htmLib:h4>
Run Code Online (Sandbox Code Playgroud)
因为纯 HTML 标签没有render用于此目的的属性,所以我正在寻找一种有条件地呈现纯 HTML 标签的替代方法,并在 SO 上偶然发现了这个答案:如何有条件地呈现像 <div> 这样的纯 HTML 元素? …
正如用户之前在另一个问题中建议的那样,我需要在另一个bean中注入一个bean.
所以,我做以下事情:
@ManagedBean
@RequestScoped
public class Articles {
private String selectedMenu;
@ManagedProperty(value="#{user}")
private UserManager user;
@PostConstruct
public void init() {
if(selectedMenu==null || selectedMenu.trim().isEmpty()) {
this.selectedMenu="0";
}
}
// now here i should access to user.methods
// getter and setter
}
Run Code Online (Sandbox Code Playgroud)
实际上,我无法访问UserManager数据.我收到这些错误:
BROWSER malformedXML: INVALID_STATE_ERR: Dom Exception 11
服务器日志
30-nov-2010 15.36.58 javax.faces.component.UIViewRoot$ViewMap put
AVVERTENZA: Setting non-serializable attribute value into ViewMap: (key: profileSelector, value class: model.ProfileSelector)
30-nov-2010 15.36.59 com.sun.faces.mgbean.BeanManager preProcessBean
GRAVE: JSF will be unable to create managed bean articles when it …
我以前有JSP实现Spring安全注销,如下所示:
<a id="logout" href="<spring:url value="/j_spring_security_logout" htmlEscape="true" />">Logout</a>
Run Code Online (Sandbox Code Playgroud)
后来当我改为jsf 2并开始使用Facelets时,我再也无法让它工作了.我尝试了很多方法.我试过这个:
<a id="logout" href="<spring:url value="/j_spring_security_logout" htmlEscape="true" />">Logout</a>
Run Code Online (Sandbox Code Playgroud)
但它不会工作.有人可以帮帮我吗?我非常感谢你的帮助.
我在登录页面上收到以下错误.在呈现响应后非法尝试设置ViewHandler.
我正在使用Richfaces 3.3.3和facelets以及jsf和tomcat
web.xml中
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<!-- Start - Richfaces Configuration-->
<!-- Plugging the "Blue Sky" skin into the project -->
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<!-- Making the RichFaces skin spread to standard HTML controls -->
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING</param-name>
<param-value>enable</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name>
<param-value>true</param-value>
</context-param>
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<!-- End - Richfaces Configuration-->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping> …Run Code Online (Sandbox Code Playgroud) 在JSF中是否可以在两个不同的视图中重用表单?我知道,ui:include但是您将如何使用例如“提交”按钮上的操作呢?还是我需要复制表格?
我已经在我的项目中成功实现了i18n.现在我被困在我的豆...
private String pageTitle;
public List<Product> getProductsByCategory(String category) {
if(validate(category)) {
pageTitle = category;
return service.getProductsByCategory(String category);
} else {
pageTitle = "Random products";
return service.getRandomProducts();
}
}
Run Code Online (Sandbox Code Playgroud)
如您所见,我想让我的pageTitle依赖于提供的方法的结果.一切都很好,但考虑到国际化,这并不好.我已经尝试使用Properties.load(新的FileInputStream)方法,但考虑到文件名为base.properties,base_en_US.properties等,这不起作用.
有谁知道这种情况下的最佳做法?提前致谢!
我正在寻找可能性,如果我可以根据从托管bean收到的值获得resourcbundle值.它可能在datatable,datagrid以及呈现值的其他组件中很有用.
我试过这段代码:
<h:outputText value="#{resourceBundle['myBean.myMsg']}" />
Run Code Online (Sandbox Code Playgroud)
但它没有用.我的outputText无法从resourcebundle获取值.结果如下:
???myBean.myMsg
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用当前迭代<p:dataTable var>作为托管bean的属性<f:setPropertyActionListener>.但是,它始终设置为null.
观点dentistas.xhtml:
<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<ui:composition template="/templates/template.xhtml">
<ui:define name="content">
<h:form id="formDentistas">
<p:growl autoUpdate="true" />
<p:commandButton icon="ui-icon-plus" value="Cadastrar"
id="cadastrar" oncomplete="dialogCadastrar.show()" />
<p:dataTable var="dentista" value="#{dentistaMB.dentistas}"
paginator="true" emptyMessage="Não foi encontrado nenhum registro"
rows="10" id="dataTableDentistas">
<f:facet name="header">Lista de Dentistas</f:facet>
<p:column headerText="Nome" sortBy="nome" filterBy="nome" id="nome"
width="200px">
#{dentista.pessoaFisica.nome}
</p:column>
<p:column headerText="Data Nascimento" sortBy="dataNascimento"
filterBy="dataNascimento" id="dataNascimento" width="60px">
#{dentista.pessoaFisica.dataNascimento}
</p:column>
<p:column headerText="CRO" sortBy="cro" filterBy="cro" id="cro" …Run Code Online (Sandbox Code Playgroud)