我一直在玩 JSF 2.0 复合组件,但我对composite:attribute标签中的 require 属性的用途有点困惑。该文档说,如果页面作者必须为此属性提供值,则 required 属性为 true。
我已经将其解释为意味着必须为所有具有required=true. 我还假设空字符串是有效值。这就是它在 Mojarra 2.0.2 中的工作方式。
使用这个简单的托管 bean:
@ManagedBean(name = "simpleMB")
@ViewScoped
public class SimpleManagedBean implements Serializable {
private static final long serialVersionUID = -1;
private String whatever;
... setter and getter
}
Run Code Online (Sandbox Code Playgroud)
和复合组件:
<composite:interface>
<composite:attribute name="value" required="true" />
</composite:interface>
<composite:implementation>
<h:outputText value="Value: '#{cc.attrs.value}'" />
</composite:implementation>
Run Code Online (Sandbox Code Playgroud)
这些标签适用于 Mojarra 2.0.2:
<foo:bar value="" />
<foo:bar value="#{simpleMB.whatever}" />
Run Code Online (Sandbox Code Playgroud)
但是,当我升级到 2.0.3 时,只有第一个标签有效。第二个标记导致此错误消息:
/requiredAttribute.xhtml @20,42 <foo:bar> The following attribute(s) are
required, but no …Run Code Online (Sandbox Code Playgroud) 我有三个通用接口(其中两个之间有反转关系),并希望以递归方法处理它们:
public interface User<R extends Role<R,U>, U extends User<R,U>>
{
public R getRole();
public void setRole(R role);
}
public interface Role<R extends Role<R,U>,U extends User<R,U>>
{
public List<R> getRoles();
public void setRoles(List<R> roles);
public List<U> getUser() ;
public void setUser(List<U> user);
}
Run Code Online (Sandbox Code Playgroud)
现在我想在我的Worker班级中使用递归进行一些处理:
public <R extends Role<R,U>,U extends User<R,U>> void recursion(List<R> roles)
{
for(R role : roles)
{
recursion(role.getRoles());
}
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误,我不知道为什么这不起作用或我如何解决这个问题:
Bound mismatch: The generic method recursion(List<R>) of type Worker is not
applicable for the arguments (List<R>). …Run Code Online (Sandbox Code Playgroud) 在本教程之后,我设法使用JSF2获得了Googles AppEngine的工作原型.现在我对ViewScoped ManagedBean有一些奇怪的行为:
@ManagedBean @ViewScoped
public class TestBean implements Serializable
{
private String text; //getter/setter
private List<String> texts; //getter
@PostConstruct public void init()
{
texts = new ArrayList<String>();
texts.add("Test");
text = new String();
}
public void save(ActionEvent ae)
{
texts.add(text);
text = new String();
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的.xhtml页面:
<h:body id="body">
<f:view contentType="text/html">
<h:form id="frm">
<p:panel>
<h:panelGrid columns="2" id="grid">
<p:inputText value="#{testBean.text}"/>
<p:commandButton value="Add" update=":frm:op @parent"
actionListener="#{testBean.save}" />
</h:panelGrid>
</p:panel>
<p:outputPanel id="op">
<p:dataTable var="v" value="#{testBean.texts}">
<p:column><h:outputText value="#{v}" /></p:column>
</p:dataTable>
</p:outputPanel>
</h:form> …Run Code Online (Sandbox Code Playgroud) 目前我部署我war有jboss:hard-deploy我的JBoss AS 6.这很好,但我必须从SVN签出项目并打包它.
在war已经上传到我们詹金斯内部的快照库,这将是很好,如果我可以从该库下载测试服务器上,并直接使用maven其部署到JBoss.
这个问题与从存储库到远程服务器的Maven部署工件之争有关,但我不认为答案是正确的(参见那里的评论).
我们正在使用Bamboo进行持续集成,并使用简单的mvn deploy语句将成功的测试部署到我们的快照存储库.不幸的是,这会产生数千条这样的行:
20-Apr-2012 10:38:44 28688 KB
20-Apr-2012 10:38:44 28692 KB
20-Apr-2012 10:38:44 28696 KB
...
20-Apr-2012 10:38:57 Uploaded: https://xxx (31932 KB at 7496.0 KB/sec)
Run Code Online (Sandbox Code Playgroud)
这出现在Bamboo:
The Build generated 14,979 lines of output. The output is too long and has been
truncated to the last 1,000 lines. Download full Build log.
Run Code Online (Sandbox Code Playgroud)
因此可以下载完整的日志,但是已经完整的上传消息.是否可以抑制上面的行mvn deploy并仅输出摘要?
我只是想知道是否有人知道如何使用mp4parser在Android上使用mp4音频文件并将其叠加到mp4视频文件上.我已经能够将一个视频附加到另一个视频,现在我只需要覆盖我对组合文件的原始mp4.
任何帮助,将不胜感激!
我正处于从JBoss AS 6到JBoss AS 7的迁移过程中,并且我的测试有问题.我们假设一个简单的实体EJB:
@Entity public class MyTest implements Serializable
{
@Id @GeneratedValue(strategy=GenerationType.AUTO)
private long id;
@NotNull
private String headline;
} //getter/setter
Run Code Online (Sandbox Code Playgroud)
在我@Stateless Bean做这样的事情(就像之前的JBoss5和JBoss6):
@Inject private EntityManager em;
public <T extends Object> T persist(T o) throws MyContraintViolationException
{
System.out.println("***************** persist:");
try
{
em.persist(o);
}
catch (Exception e)
{
System.out.println("*************** exception:");
// Further investigation of Exception e,
// then throw MyContraintViolationException
}
}
Run Code Online (Sandbox Code Playgroud)
如果我不违反@NotNull约束,这可以正常工作.如果headline==null,我得到例外,但不要输入我的catch块:
12:19:45 INFO ******************** persist:
12:19:45 WARN …Run Code Online (Sandbox Code Playgroud) 我在使用@Named @ViewScopedJBoss-7.1.1-Final 的Bean中使用RestEasy客户端框架,以使用自定义从REST服务检索数据HttpRequestInterceptor:
RegisterBuiltin.register(ResteasyProviderFactory.getInstance());
DefaultHttpClient httpClient = new DefaultHttpClient();
httpClient.addRequestInterceptor(new PreemptiveAuthInterceptor("test","test"), 0);
ClientExecutor clientExecutor = new ApacheHttpClient4Executor(httpClient); //<---
//The error occurs above, the code below is only for completeness
MyRest rest = ProxyFactory.create(MyRest.class,
"http://localhost:8080/rest",clientExecutor);
Run Code Online (Sandbox Code Playgroud)
这在独立客户端应用程序中工作正常(当我删除ClientExecutor它时也可以,但我需要它来验证REST服务).bean在一个WAR模块里面EAR,resteasy的依赖层次结构解析为:

没有httpclient或httpcore在WAR或EAR.在Bean内部,我得到以下异常:
java.lang.NoClassDefFoundError: org/apache/http/HttpRequestInterceptor
Run Code Online (Sandbox Code Playgroud)
似乎很容易(虽然我想知道重新包装)并且我添加org.apache.httpcomponents:httpclient了编译范围:

不,我得到他跟随例外:
java.lang.LinkageError: loader constraint violation: when resolving method
"org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor.<init>
(Lorg/apache/http/client/HttpClient;)V"
the class loader (instance of org/jboss/modules/ModuleClassLoader)
of the current …Run Code Online (Sandbox Code Playgroud) 如何使用蜡染(1.7)获取SVG图像的大小(宽度/高度)?
String s = "https://openclipart.org/download/228858";
InputStream is = new URL(s).openStream();
DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = f.newDocumentBuilder();
Document doc = builder.parse(is);
SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(doc);
SVGGraphics2D svg = new SVGGraphics2D(ctx,false);
Dimension d = svg.getSVGCanvasSize();
Rectangle r = svg.getClipBounds();
System.out.println(svg.toString()); //org.apache.batik.svggen.SVGGraphics2D[font=java.awt.Font[family=Dialog,name=sanserif,style=plain,size=12],color=java.awt.Color[r=0,g=0,b=0]]
System.out.println("Dimension null? "+(d==null)); //true
System.out.println("Rectangle null? "+(r==null)); //true
Run Code Online (Sandbox Code Playgroud)
该示例可以直接执行,并从打开的clipart.org下载图像.作为绝对尺寸的替代,我也对图像的纵横比感兴趣.
@FacesConverter在AJAX调用期间p:selectOneMenu(Primefaces 3.0),JBoss-7.1.0.CR1b 的自定义有一个奇怪的问题.
简化的转换器看起来像这样,在这个类中没有NPE或其他异常
@FacesConverter("MyConverter")
public class MyConverter implements Converter
{
public Object getAsObject(FacesContext fc, UIComponent uic, String value)
{
logger.debug("getAsObject value: "+value);
if (submittedValue.trim().equals("")) {return null;}
else
{
MyEjb ejb = new MyEjb();
ejb.setId(Long.parseLong(value()));
return ejb; //**** alternative with return null; ****
}
}
public String getAsString(FacesContext fc, UIComponent uic, Object value)
{
if (value == null || value.equals("")) {return "";}
else
{
MyEjb ejb = (MyEjb)value;
return ""+ejb.getId();
}
}
}
Run Code Online (Sandbox Code Playgroud)
转换器用于p:selectOneMenu:
<h:form> …Run Code Online (Sandbox Code Playgroud) 我正在使用REST Web服务并在我的视图中直接使用JAXB对象.一个XMLGregorianCalendar像这样的日期:
@XmlAttribute(name = "record")
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar record;
Run Code Online (Sandbox Code Playgroud)
在尝试使用标准转换器时
<h:outputText value="#{bean.value.record}" >
<f:convertDateTime pattern="dd.MM.yy" />
</h:outputText>
Run Code Online (Sandbox Code Playgroud)
我在JSF2环境中收到错误消息(翻译成英文)(JBoss-7.1.1-Final)
javax.faces.convert.ConverterException: fSelection:dtSelection:0:j_idt42:
Converting of '2012-07-25T20:15:00' into string not possible.
Run Code Online (Sandbox Code Playgroud)
看来,XMLGregorianCalendar默认转换器不支持该类型.我想知道这个日期类型的JSF转换器是否可用,因为这个要求似乎并不那么不寻常......
编辑 Ravi提供了一个自定义转换器的功能示例,但这似乎是不灵活的:
我正在使用JBoss AS 7.1.1.Final"Brontes"并在-Bean中遇到长时间运行的方法调用,该调用在@Stateless5分钟后被取消:
[com.arjuna.ats.arjuna] (Transaction Reaper) ARJUNA012117:
TransactionReaper::check timeout
Run Code Online (Sandbox Code Playgroud)
搜索这个问题我发现了一些答案Jboss 7.1 ejb 2.1自定义事务超时配置和wiki JBoss-AS7参考指南或JBoss Wiki.
答案似乎很简单:用@TransactionTimeout
But注释方法:这个类在我的类路径中不可用!我有一个带有EAR结构的Maven项目,该ejb模块具有以下相关依赖项,我在几个使用EJB3的项目中使用它们:
org.jboss.spec.javax.ejb:jboss-ejb-api_3.1_spec (提供)javax.enterprise:cdi-api (提供)org.hibernate.javax.persistence:hibernate-jpa-2.0-api (提供)org.hibernate:hibernate-validator (提供)缺少哪种依赖?
我想要回合
0.005 to 0.01
Run Code Online (Sandbox Code Playgroud)
即时通讯使用此代码
DecimalFormat df = new DecimalFormat("0.00");
Run Code Online (Sandbox Code Playgroud)
但是0.00
如果有可能,任何人都有一个想法,答案一直在我只想要右边的2位数进行舍入?
java ×11
jboss7.x ×4
jsf-2 ×3
maven ×3
android ×2
ajax ×1
audio ×1
bamboo ×1
batik ×1
classloader ×1
converter ×1
deployment ×1
ejb ×1
generics ×1
image ×1
jaxb ×1
jboss ×1
jpa-2.0 ×1
jsf ×1
mp4 ×1
mp4parser ×1
persistence ×1
primefaces ×1
recursion ×1
resteasy ×1
rounding ×1
svg ×1
transactions ×1