我会尽量简短,请在这里和我在一起
"A.jsf" - >托管bean:bean"#{bean.list}":将我们带到B.jsf
<p:growl id="msgs" showDetail="true"/>
<h:form id="myform1" enctype="multipart/form-data">
<p:panel header="Upload" style="font-size: 11px;">
<h:panelGrid columns="2" cellpadding="10">
<h:outputLabel value="Drawing:" />
<p:fileUpload fileUploadListener="#{bean.handleFileUpload}" update="msgs" allowTypes="*.*;"/>
</h:panelGrid>
<p:commandButton ajax="false" immediate="true" id="back" value="Back" action="#{bean.list}"/>
<p:commandButton ajax="false" id="persist" value="Persist" action="#{bean.handleRevision}" />
</p:panel>
</h:form>
Run Code Online (Sandbox Code Playgroud)
那么 handleFileUpload()
if(!upload){
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error", "You do not have permission to upload.");
FacesContext.getCurrentInstance().addMessage(null, msg);
}
...
Run Code Online (Sandbox Code Playgroud)
"B.jsf" - >托管bean:bean2
...
<p:growl id="msgs" showDetail="true"/>
...
Run Code Online (Sandbox Code Playgroud)
当我点击上传时,它会给我一个咆哮错误消息"你没有上传权限.",这很好.但是当我点击"返回",这将把我带到B.jsf时,我看到了咆哮的消息"你没有权限上传." 再次.似乎正在发生的是当我点击"返回"时,我发送其他表单请求上传,然后生成相同的错误消息,然后显示在B.jsf.有没有办法解决这个问题,除了将"后退"按钮放入一个空的表格,因为现在我有两个按钮站在彼此的顶部,而不是并排.我试着这样做:
FacesContext.getCurrentInstance().addMessage("tom", msg);
Run Code Online (Sandbox Code Playgroud)
希望它会发送到id ="tom"的组件,那么id = msgs的growl将不会加载,但没有运气.upload当我单击Back按钮时,我尝试打开标志,但在处理back …
所以我有一个inputText它的值挂钩myBean.text,我希望如果我点击回车键,那么inputText将调用一个方法myBean来做一些事情.谁能帮我?
编辑
__PRE__
然后在inputText豆
__PRE__
我真的想滥用@Asynchronous来加速我的Web应用程序,因此我想更多地了解这一点,以避免错误地使用此注释.
所以我知道这个带注释的方法中的业务逻辑将在一个单独的线程中处理,因此用户不必等待.所以我有两种持久化数据的方法
public void persist(Object object) {
em.persist(object);
}
@Asynchronous
public void asynPersist(Object object) {
em.persist(object);
}
Run Code Online (Sandbox Code Playgroud)
所以我有几个场景,我想问一下这些场景中哪一个不行
1. B is not depend on A
A a = new A();
asynPersist(a); //Is it risky to `asynPersist(a) here?`
B b = new B();
persist(b);
//Cant asynPersist(B) here because I need the `b` to immediately
//reflect to the view, or should I `asynPersist(b)` as well?
2. Same as first scenario but B now depend on A. Should I `asynPersist(a)`
3. …Run Code Online (Sandbox Code Playgroud) 当我尝试压缩jpg图像时,大多数情况下它完美地工作,但是一些jpg图像在压缩后变为绿色.这是我的代码
public void compressImage(String filename, String fileExtension) {
BufferedImage img = null;
try {
File file = new File(filename);
img = ImageIO.read(file);
if (fileExtension.toLowerCase().equals(".png") || fileExtension.toLowerCase().equals(".gif")) {
//Since there might be transparent pixel, if I dont do this,
//the image will be all black.
for (int x = 0; x < img.getWidth(); x++) {
for (int y = 0; y < img.getHeight(); y++) {
int rgb = img.getRGB(x, y);
int alpha = (rgb >> 24) & 0xff;
if (alpha != …Run Code Online (Sandbox Code Playgroud) 如何删除OneToMany关系中的实体.
@Entity
@NamedQueries({
@NamedQuery(name="User.findByUserNamePassword",
query="select c from User c where c.userName = :userName AND c.password = :password")
})
@Table(name="\"USER\"")
public class User implements Serializable {
@OneToMany(mappedBy="user", cascade=CascadeType.ALL, orphanRemove=true)
private List<Profession> professions;
public List<Profession> getProfessions() {
return professions;
}
public void setProfessions(List<Profession> professions) {
this.professions = professions;
}
public void addProfession(Profession profession){
if(this.professions == null){
this.professions = new ArrayList<Profession>();
}
this.professions.add(profession);
profession.setUser(this);
}
public void removeProfession(Profession profession){
if(this.professions != null){
professions.remove(profession);
profession.setUser(null);
}
}
}
Run Code Online (Sandbox Code Playgroud)
内部职业实体
@Entity
public class Profession implements …Run Code Online (Sandbox Code Playgroud) 此演示展示了在使用jQuery拖动组件时如何发送事件.我有一个组件DIV,当我拖动该组件时,我想打印出相对于DIV容器的组件坐标,任何jQuery pro都可以帮助我.这是我到目前为止所得到的.
<div id="container" style="width: 400px; height: 4000px; border: 1px solid black;" >
<div id="draggable" style="width: 150px; height: 150px; background-color: black; cursor: move;">
<div class="count"/>
</div>
</div>
<script>
jQuery(function(){
jQuery("#draggable").draggable({
containment: "#contain",
scroll: false,
drag: function(){
}
});
function updateCoordinate(newCoordinate){
jQuery(".count").text(newCoordinate);
}
});
</script>
Run Code Online (Sandbox Code Playgroud)
在拖动的回调事件中,我需要弄清楚pageX, pageY以及offsetX, offsetY在拖动时找出组件的相对位置.我是jQuery的新手.我知道我可以获得两者pageX, pageY并且offsetX, offsetY喜欢这样
jQuery("#container").click(function(event){
var offset = jQuery(this).offset();
var pageX = event.pageX;
var pageY = event.pageY;
});
Run Code Online (Sandbox Code Playgroud)
但我不确定如何将它们组合在一起.
我有一个下拉列表p:selectonemenu和一个复选框p:selectbooleancheckbox,当我选中复选框时,我想将其设置selectonemenu为特定值.我不希望用户更改它,所以我将selectonemenu disabled属性设置为true.但是,当它被禁用时,它的值不会出现在请求参数映射中,当我这样做时facescontext.getcurrentinstance().getexternalcontext().getrequestparametermap(),我需要它的值到这个映射.有办法解决这个问题吗?
我将font-end写入遗留的Servlet系统,在那里他们使用请求映射参数来获取表单属性值.
我有一个表格Image来保存图像信息.我也想存储图像本身.我也应该这样
1.将Blob存储在同一个图像表中,并将其设置为惰性,如下所示
@Basic(optional = false, fetch = FetchType.LAZY)
@Lob
@Column(name = "IMAGE_BLOB", length=100000) //This will generate MEDIUMBLOB
private byte[] imageBlob;
Run Code Online (Sandbox Code Playgroud)
要么
2.创建一个ImageBlob与之OneToOne关系的另一个表Image,并获取懒惰的关系
@OneToOne(cascade = CascadeType.ALL, mappedBy = "image", fetch=FetchType.LAZY)
private ImageBlob imageBlob;
Run Code Online (Sandbox Code Playgroud)
这两种技术在性能方面是否相同?
我已经看到这个问题在很多地方问了,但是没有一个得到适当的回答所以我决定再问一遍.所以,如果我有这个:如果我在A.xhtml和我
<ui:include src="B.xhtml">
<ui:param name="formId" value="awesome Id"/>
</ui:include>
Run Code Online (Sandbox Code Playgroud)
所以B.xhtml,我可以这样做
<h:outputText value="#{formId}"/>
Run Code Online (Sandbox Code Playgroud)
当我跑步时A.xhtml,我会看到awesome Id在屏幕上打印出来.但是,如何访问formId辅助bean中的值.我看里面FacesContext.getCurrentInstance().getAttributes(),FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap()我似乎无法找到它.为了更进一步,我尝试:
在里面B.xhtml,我现在有
<h:inputHidden id="hiddenFormId" value="#{formId}"/>
<h:outputText value="#{formId}"/>
Run Code Online (Sandbox Code Playgroud)
这个想法是,我可以访问的值formId的RequestParameterMap下键hiddenFormId.但是现在如果我有:
<h:form id="myForm">
<ui:include src="B.xhtml">
<ui:param name="formId" value="awesome Id"/>
</ui:include>
<a4j:commandButton render="myForm" value="My Button"/>
</h:form>
Run Code Online (Sandbox Code Playgroud)
如果我查看POST请求(在chrome或ff调试模式下),我会得到这个错误
<partial-response><error><error-name>class javax.faces.component.UpdateModelException</error-name><error-message><![CDATA[/B.xhtml @9,61 value="${formId}": /index.xhtml @27,61 value="awesome Id": Illegal Syntax for Set Operation]]></error-message></error></partial-response>
那么如何在托管bean中访问ui:param值?
我正在使用Parse(解析1.9.2)使用React Native向Android和IOS发送推送通知.但是,即使我单击通知并打开了应用程序,Parse也不会记录此事件.如何使用Parse记录此通知已打开,我该怎么办?当我Past Push在Parse仪表板上打开时,它总是这么说N/A Notifications Opens.请帮忙
java ×5
jsf ×5
jpa ×2
jquery ×2
primefaces ×2
android ×1
asynchronous ×1
blob ×1
compression ×1
ejb ×1
ejb-3.0 ×1
ios ×1
java-ee ×1
jpa-2.0 ×1
jpeg ×1
jquery-ui ×1
jsf-2 ×1
one-to-many ×1
parse-server ×1
react-native ×1
uiinclude ×1