这是如此简单的事情
<p:commandLink value="Tom" onclick="document.getElementById('tom').focus()"/><br/>
<input id="tom"/>
Run Code Online (Sandbox Code Playgroud)
当您单击Tom时,文本框将获得焦点.好的,现在尝试一下
<p:commandLink value="Tom" onclick="document.getElementById('tom').focus()"/><br/>
<h:inputText id="tom"/> <br/>
Run Code Online (Sandbox Code Playgroud)
当我点击什么都没发生时,我查看了萤火虫,我明白了
document.getElementById("tom") is null
Run Code Online (Sandbox Code Playgroud)
当我尝试使用jQuery时$('#tom').focus(),没有任何事情发生,没有错误,但也没有获得焦点.response当我从firebug看到时,这是(不确定这是否是来自服务器的响应)
<?xml version="1.0" encoding="utf-8"?>
<partial-response>
<changes>
<update id="javax.faces.ViewState"><![CDATA[455334589763307998:-2971181471269134244]]></update>
</changes>
<extension primefacesCallbackParam="validationFailed">{"validationFailed":false}</extension>
</partial-response>
Run Code Online (Sandbox Code Playgroud)
我需要花一点时间解释一下,所以请和我在一起.我有NewsFeed一个与自己有OneToMany关系的表.
@Entity
public class NewsFeed(){
...
@ManyToOne(optional=true, fetch=FetchType.LAZY)
@JoinColumn(name="REPLYTO_ID")
private NewsFeed replyTo;
@OneToMany(mappedBy="replyTo", cascade=CascadeType.ALL)
private List<NewsFeed> replies = new ArrayList<NewsFeed>();
public void addReply(NewsFeed reply){
replies.add(reply);
reply.setReplyTo(this);
}
public void removeReply(NewsFeed reply){
replies.remove(reply);
}
}
Run Code Online (Sandbox Code Playgroud)
所以你可以这样想.每个Feed都有一个List也是类型的回复NewsFeed.现在,我很容易删除原始Feed并获取更新后的列表.删除后我需要做的就是这个.
feeds = scholarEJB.findAllFeed(); //This will query the db and return updated list
Run Code Online (Sandbox Code Playgroud)
但是在尝试删除replies并获取更新后的列表时遇到问题.所以这是我如何删除replies.在我的JSF托管bean里面
//Before invoke this method, I have the value of originalFeed, and deletedFeed set.
//These original feeds are display inside a p:dataTable X, …Run Code Online (Sandbox Code Playgroud) 我想在我的JSF页面上显示PDF文件,我已经检查了如何在iFrame的jsf页面中显示pdf文档,但是我不想在iframe上显示它(因为它将生成滚动条)。我只想将pdf显示在图像上的页面上,并能够为其提供宽度和高度。
编辑嗨BalusC。我仍然无法显示pdf内联。这是我的代码。
@WebServlet(name = "pdfHandler", urlPatterns = {"/pdfHandler/*"})
public class pdfHandler extends HttpServlet {
private static final int DEFAULT_BUFFER_SIZE = 10240;
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String requestedFile = request.getPathInfo();
File file = new File("/Users/KingdomHeart/Downloads/Test/pdf/" + requestedFile);
response.reset();
response.setContentType("application/pdf");
response.setBufferSize(DEFAULT_BUFFER_SIZE);
response.setHeader("Content-Length", String.valueOf(file.length()));
response.setHeader("Content-Disposition", "inline; filename=\"" + file.getName() + "\"");
BufferedInputStream input = null;
BufferedOutputStream output = null;
try{
input = new BufferedInputStream(new FileInputStream(file), DEFAULT_BUFFER_SIZE);
output = new BufferedOutputStream(response.getOutputStream(), DEFAULT_BUFFER_SIZE);
byte[] buffer = new …Run Code Online (Sandbox Code Playgroud) 如果我要给出一个特定的java.util.Date,我该如何生成该给定日期的开始和结束.例如,我的日期是August 25, 2011,那么我的开始日期是August 25, 2011 00 00 00,我的日期结束August 25, 2011 23 59 59
背景 :(如果你想知道为什么我问这个问题,请阅读下面的内容)
我使用JPA映射date到我的MySql数据库.我希望date有时间,所以我用TemoporalType.TIMESTAMP
@Temporal(TemporalType.TIMESTAMP)
private Date dateProcess; //java.util.Date
Run Code Online (Sandbox Code Playgroud)
我需要查询给定特定日期的所有数据,并且由于date存储如上,我需要一个日期范围来实现我想要的.
我的游戏计划是转换java.util.Date为JodaTime#DateTinme,然后在那里构建开始和结束日期,并将其转换回来,以便我可以作为参数传递给JPQL.但似乎JodaTime非常不可变,我似乎无法在任何地方看到一个setter方法.
我在展示中关注这个例子:http: //showcase.richfaces.org/richfaces/component-sample.jsf?demo = pop&sample = login&skin = blueSky它显示了我如何点击一个链接打开一个popupPanel并追加该面板到该链接的相同位置.但我想这样,如果我再次点击,它将关闭面板.谁知道如何实现这一目标?这是我的代码
<h:outputLink value="#" id="sb-dd-ol" >
<rich:componentControl event="click" operation="show" target="sb-dd-pp">
<a4j:param noEscape="true" value="event"/>
<rich:hashParam>
<a4j:param noEscape="true" name="top"
value="jQuery(#{rich:element('sb-dd-ol')}.parentNode).offset().top +
jQuery(#{rich:element('sb-dd-ol')}.parentNode).height()" />
<a4j:param noEscape="true" name="left"
value="jQuery(#{rich:element('sb-dd-ol')}.parentNode).offset().left" />
</rich:hashParam>
</rich:componentControl>
Test
</h:outputLink>
<rich:popupPanel id="sb-dd-pp" autosized="true" modal="false"
moveable="false" resizeable="false" followByScroll="false">
This is a test
</rich:popupPanel>
Run Code Online (Sandbox Code Playgroud) 我强行使用一个非常旧版本的MyFaces 2.0.5我认为,动态包含EL导致这么多问题,所以我切换到静态包含ui:fragment
<ui:fragment rendered="#{filtersPopup.filterFileName == 'checkBoxFilters'}">
checkBoxFilters
<ui:include src="/analytics/checkBoxFilters.xhtml" rendered="#{filtersPopup.filter != null}"/>
</ui:fragment>
<ui:fragment rendered="#{filtersPopup.filterFileName == 'DateRelativeFilter'}">
DateRelativeFilter
<ui:include src="/analytics/DateRelativeFilter.xhtml" rendered="#{filtersPopup.filter != null}"/>
</ui:fragment>
<ui:fragment rendered="#{filtersPopup.filterFileName == 'listboxFilter'}">
listboxFilter
<ui:include src="/analytics/listboxFilter.xhtml" rendered="#{filtersPopup.filter != null}"/>
</ui:fragment>
Run Code Online (Sandbox Code Playgroud)
有了它,它仍然抱怨重复的id,因为我在这些源文件的夫妇上使用相同的id.所以它似乎rendered应该是false,它仍然使它成为组件树.但重复的ID很好.我可以轻松解决这个问题,所以现在当我提交表单时,我得到了这个例外
/analytics/checkBoxFilters.xhtml at line 24 and column 118 value="#{filtersPopup.filter.groups}": Property 'groups' not found on type ListBoxFilter
Run Code Online (Sandbox Code Playgroud)
所以从异常中可以看出,它ListBoxFilter是我想要的对象,所以只包含ListBoxFilter.xhtml,但正在访问checkBoxFilters.xhtml因此错误.知道如何解决这个问题吗?
我正在使用Sugarcrm 6.5,我想问我是否可以在主表而不是cstm表中创建字段.现在我通过这个帖子创建自定义字段 http://support.sugarcrm.com/02_Documentation/04_Sugar_Developer/Sugar_Developer_Guide_7.1/70_API/Application/Module_Loader/90_Package_Examples/Creating_an_Installable_Package_that_Creates_New_Fields/这种方法自定义字段添加到CSTM表
当我环顾四周,这下面的帖子(最后一个回复说有可能)
http://forums.sugarcrm.com/f3/how-take-out-_c-when-creating-custom-field-56452/
我使用了Magento 1.9,我有这样的场景:
我不喜欢这个工作流程.有没有办法,我可以在magento中更改此行为,当登录用户"添加到购物车"产品时,它不应该将该产品添加到用户配置文件.非常感谢你
这converter是从我的JSF调用的.我已在里面注册了faces-config.xml
public class ProjectConverter implements Converter{
@EJB
DocumentSBean sBean;
@ManagedProperty(value="#{logging}")
private Logging log;
public ProjectConverter(){
}
public Object getAsObject(FacesContext context, UIComponent component, String value)
{
if(value.trim().equals("")){
return null;
}
return sBean.getProjectById(value);
}
public String getAsString(FacesContext context, UIComponent component, Object value)
{
if(value == null){
return null;
}
return String.valueOf(((Project) value).getId());
}
}
Run Code Online (Sandbox Code Playgroud)
我遇到了java.lang.NullPointerException,当我进入时getAsObject(),主要原因是因为我的会话Bean sBean为空.我不知道如何解决这个问题,我需要访问我的Session bean,以便我可以从我的数据库中查询
我希望关于标题的问题有意义,如果没有,请说:机器A,通过我登录的Web浏览器admin,我转到机器B,然后登录admin,机器A中的Web浏览器应该强制注销用户admin.我给了这个想法,我认为如果我尝试手动实现它会很难看.我有一种感觉,这可以在Glassfish中完成.
我使用Java EE 6 + Glassfish v3.0.1.身份验证和授权是通过Glassfish中设置的jdbcRealm实现的