在我的JSF/Facelets应用程序中,我想使用自定义标记从页面ID列表中动态生成痕迹痕迹:
<foo:breadcrumbs trail="foo,bar,baz"/>
Run Code Online (Sandbox Code Playgroud)
这应该产生如下:
<h:commandLink action="foo" ... />
<h:commandLink action="bar" ... />
<!-- (etc.) -->
Run Code Online (Sandbox Code Playgroud)
我的代码看起来像这样:
<ui:repeat value="#{fn:split(trail, ',')}" var="key">
<h:commandLink action="#{key}" ... />
</ui:repeat>
Run Code Online (Sandbox Code Playgroud)
此代码的问题是#{key}被解释为方法绑定.但是,我只想将字符串值#{key}作为导航结果返回.我怎样才能做到这一点?
我唯一能想到的是创建一个具有outcome字段和动作处理程序的虚拟托管bean ,并像这样调用它:
<h:commandLink action="#{dummy.click}" ...>
<f:setPropertyActionListener target="#{dummy.outcome}" value="#{key}" />
</h:commandLink>
Run Code Online (Sandbox Code Playgroud)
使用如此定义的虚拟类:
public class Dummy {
private String outcome;
public String click() {
return outcome;
}
public void setOutcome(String outcome) {
this.outcome = outcome;
}
public void getOutcome() {
return outcome;
}
}
Run Code Online (Sandbox Code Playgroud)
这看起来很丑陋,我不知道它是否会起作用.
我有Richfaces应用程序,我部署到Glassfish v3.好几个星期(差不多)一切正常,但今天突然出现了以下错误.我的pom.xml中有jsf-facelets-1.1.14.jar依赖项.我不知道如何解决这个问题.救命!!
Source Document: jndi:/server/swmind.rcp.web/WEB-INF/faces-config.xml Cause: Unable to find class 'com.sun.facelets.FaceletViewHandler'
at com.sun.faces.config.processor.AbstractConfigProcessor.createInstance(AbstractConfigProcessor.java:275)
at com.sun.faces.config.processor.ApplicationConfigProcessor.setViewHandler(ApplicationConfigProcessor.java:527)
at com.sun.faces.config.processor.ApplicationConfigProcessor.processViewHandlers(ApplicationConfigProcessor.java:847)
at com.sun.faces.config.processor.ApplicationConfigProcessor.process(ApplicationConfigProcessor.java:331)
at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:114)
at com.sun.faces.config.processor.LifecycleConfigProcessor.process(LifecycleConfigProcessor.java:116)
at com.sun.faces.config.processor.AbstractConfigProcessor.invokeNext(AbstractConfigProcessor.java:114)
at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:223)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:335)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:223)
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:4591)
at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:535)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5193)
at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:928)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:912)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1933)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1605)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:126)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:236)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:339)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:183)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:272)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:305)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:320)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1176)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$900(CommandRunnerImpl.java:83)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1224)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:365)
at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:204)
at …Run Code Online (Sandbox Code Playgroud) 在JSF中,我们可以绑定HtmlDataTable到backing bean并获取行数据.但是ui:repeat甚至没有绑定属性.那么,我怎么知道点击了哪一行(元素)ui:repeat?
JSF Custom Components和Facelets Composite Components有什么区别?
我正在尝试创建一个复合组件,以便在我的项目中使用,因此,我创建了一个名为"componentes-ui-web"的项目,并推出了2个xhtml文件,这些文件是我的组件.
项目的结构如下:
src
> |-> main
> > |->java
> > |->META-INF
> > |->faces-config.xml
> > |->resources
> > |->componentes
> > |->popupSimples.xhtml
> > |->popupSubmit.xhtml
Run Code Online (Sandbox Code Playgroud)
这是代码popupSubmit.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:ui="http://java.sun.com/jsf/facelets"
xmlns:icecore="http://www.icefaces.org/icefaces/core"
xmlns:ice="http://www.icesoft.com/icefaces/component"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:ace="http://www.icefaces.org/icefaces/components">
<composite:interface>
<composite:attribute name="modal" default="false" />
<composite:attribute name="visivel" default="false" />
<composite:attribute name="style" default="" />
<composite:attribute name="titulo" default="Sem título definido" />
<composite:attribute name="exibidoQuandoTipoUsuario" default="" />
<composite:attribute name="metodoFechar"
method-signature="java.lang.Void fechar()" required="true" />
<composite:attribute name="metodoSubmeter"
method-signature="java.lang.Void …Run Code Online (Sandbox Code Playgroud) 我与Mojarra 2.1.3合作.
当用户点击"刷新不工作"按钮时,它会刷新ui:repeat的内容.我希望检查复选框,就像在初始化时一样.
我发现:如果我删除h:head in facelet"刷新不工作"的作品...有什么想法吗?
小脸:
<h:head></h:head>
<h:body>
<h:form id="myForm" >
<h:panelGroup id="panelToRefreshOutsideRepeat">
<ui:repeat value="#{sandbox.columns}" var="column">
<h:panelGroup id="panelToRefreshInsideRepeat">
<h2>composite onlyCheckbox:</h2>
<trc:onlyCheckbox value="#{column.value}" />
<br />
<h2>composite onlyInputText:</h2>
<trc:onlyInputText value="#{column.value}" />
<br />
<br/>
<h:commandButton value="Refresh don't work" >
<f:ajax render="panelToRefreshInsideRepeat" />
</h:commandButton>
<h:commandButton value="Refresh work" >
<f:ajax render=":myForm:panelToRefreshOutsideRepeat" />
</h:commandButton>
</h:panelGroup>
<br/>
</ui:repeat>
</h:panelGroup>
Run Code Online (Sandbox Code Playgroud)
onlyCheckbox和onlyInputText的复合:
<composite:interface>
<composite:attribute name="value"
type="boolean"/>
</composite:interface>
<composite:implementation>
boolean: <h:selectBooleanCheckbox value="#{cc.attrs.value}" />
<!-- for onlyInputText h:inputText instead of h:selectBooleanCheckbox -->
boolean value: #{cc.attrs.value}
</composite:implementation>
Run Code Online (Sandbox Code Playgroud)
和支持bean:
@ManagedBean …Run Code Online (Sandbox Code Playgroud) 我正在尝试从我的支持bean中的JSF 2.0页面调用函数传递动态参数.只要我传递一个静态字符串,它工作正常,但是当我尝试使用动态字符串时,我总是得到一个EL解析错误.我猜它是一个语法问题,但我想不出用方法表达式做另一种方法.我知道我可以用<f:param..../>标签来做,但我不会放弃这个:)
<h:dataTable var="urlresult" value="#{search.searchResults_sites_urls}">
<h:column>
<h:form>
<h:outputText value="#{urlresult}" />
<h:commandLink action="#{search.showUrls(#{urlresult})}" value=" x" />
</h:form>
</h:column>
</h:dataTable>
Run Code Online (Sandbox Code Playgroud)
支持bean中的方法:
public void showUrls(String url) {
//CODE
}
Run Code Online (Sandbox Code Playgroud)
这是怎么造成的,我该如何解决?
我有这样的事情:
<ul>
<li>User</li>
<li>Admin</li>
..
</ul>
Run Code Online (Sandbox Code Playgroud)
并且只有当实际用户处于角色"管理员"时才想呈现列表项"管理员".
我知道,我可以这样做:
<ul>
<li>User</li>
<h:panelGroup rendered="#{request.isUserInRole('admin')}">
<li>Admin</li>
</h:panelGroup>
..
</ul>
Run Code Online (Sandbox Code Playgroud)
但是,由于h:panelGroup,标记会插入"span"元素.
是否有一个带有'rendered'属性的JSF-Component,它不会插入任何html?
不幸的是,Facelets ui:remove/ui:include没有'呈现'属性:
<ul>
<li>User</li>
<ui:remove rendered="#{request.isUserInRole('admin')}">
<li>Admin</li>
</ui:remove>
..
</ul>
Run Code Online (Sandbox Code Playgroud)
我该如何解决这种情况?
我在点击链接时调用了一种方法。以下代码可以正常工作
<ui:repeat value="#{myBean.names}" var="name"
varStatus="idx">
<li>
<h:commandLink value="#{name.label}">
<f:ajax execute="@this" event="click" render="@all" listener="#{myBean.changeActiveName}" >
</f:ajax>
</h:commandLink>
</li>
</ui:repeat>
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试将参数传递给Ajax调用时,它将开始刷新整个页面
<ui:repeat value="#{myBean.names}" var="name"
varStatus="idx">
<li>
<h:commandLink value="#{name.label}">
<f:ajax execute="@this" event="click" render="@all" listener="#{myBean.changeActiveName}" >
<f:param name="idx" value="#{idx}" />
</f:ajax>
</h:commandLink>
</li>
</ui:repeat>
Run Code Online (Sandbox Code Playgroud)
此代码有什么问题?
如何制作包含ajax状态以供全局使用的primefaces模板.
到目前为止,这就是我所做的.
template/default.xhtml(Facelets模板)
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition 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"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="./../resources/css/default.css" rel="stylesheet" type="text/css" />
<link href="./../resources/css/cssLayout.css" rel="stylesheet" type="text/css" />
<title>Facelets Template</title>
</h:head>
<h:body>
<div id="top">
<ui:insert name="top">
<!--modal ajax status here-->
<p:ajaxStatus onstart="statusDialog.show();" oncomplete="statusDialog.hide();"/>
<p:dialog modal="true" widgetVar="statusDialog" header="Loading"
draggable="false" closable="false">
<p:graphicImage value="../resources/images/ajax-loader-square.gif" />
</p:dialog>
<!--modal ajax status end-->
</ui:insert>
</div>
<div id="content" class="center_content">
<ui:insert name="content">Content</ui:insert>
</div>
<div id="bottom">
<ui:insert name="bottom">Bottom</ui:insert>
</div>
</h:body>
Run Code Online (Sandbox Code Playgroud)
login.xhtml(Facelets模板客户端) …
facelets ×10
jsf ×6
jsf-2 ×5
ajax ×1
breadcrumbs ×1
el ×1
glassfish ×1
jar ×1
java ×1
navigation ×1
primefaces ×1
templates ×1
uirepeat ×1