小编pak*_*ore的帖子

Java&=运算符是否适用&或&&?

假设

boolean a = false;
Run Code Online (Sandbox Code Playgroud)

我想知道是否这样做:

a &= b; 
Run Code Online (Sandbox Code Playgroud)

相当于

a = a && b; //logical AND, a is false hence b is not evaluated.
Run Code Online (Sandbox Code Playgroud)

或者另一方面它意味着

a = a & b; //Bitwise AND. Both a and b are evaluated.
Run Code Online (Sandbox Code Playgroud)

java operators

130
推荐指数
3
解决办法
11万
查看次数

logback编码器模式文档在哪里

我已经完成了logback的所有文档,在日志记录时无法找到配置编码器模式的文档,例如:

<encoder>
  <pattern>%d{HH:mm:ss.SSS} %-4relative %-5level %logger{35} - %msg%n</pattern>
</encoder>
Run Code Online (Sandbox Code Playgroud)

我想要一个表(就像log4j那样)解释配置模式的不同选项.

模式的文档在哪里?也许他们是在另一个项目中定义的?

java logging log4j logback

83
推荐指数
1
解决办法
5万
查看次数

如何使用相同的凭据记录两次用户会话时使其无效

我正在使用带有Richfaces和Facelets的JSF 1.2.

我有一个应用程序,有许多会话范围的bean和一些应用程序bean.

用户使用Firefox登录.创建一个ID ="A"的会话; 然后他打开Chrome并使用相同的凭据再次登录.创建ID ="B"的会话.

当创建会话"B"时,我希望能够销毁会话"A".怎么做?

也.当Firefox中的用户做任何事情时,我希望能够显示一个弹出窗口或某种通知,说"你已经登出,因为你已经从其他地方登录".

我有一个sessionListener,可以跟踪创建和销毁的会话.问题是,我可以将HTTPSession对象保存在应用程序范围的bean中,并在检测到用户已登录两次时将其销毁.但有些东西告诉我这是错误的,不会奏效.

JSF是否跟踪服务器端的某些会话?如何通过标识符访问它们?如果没有,如何在用户登录两次时首次登录?

java session jsf richfaces facelets

19
推荐指数
1
解决办法
2万
查看次数

在会话到期之前调用方法

我的webapp有登录用户.暂停时间.在会话到期之前,我想执行一个方法来清理一些锁.

我实现了一个sessionListener但是一旦我到达public void sessionDestroyed(HttpSessionEvent event)会话已经不见了,我需要一些来自它的数据,所以我想FacesConfig.getCurrentInstance()在会话实际到期之前执行一个方法(需要会话存活并且能够访问).

我怎样才能做到这一点?有任何想法吗?这是我的Session Listener:

public class MySessionListener implements HttpSessionListener {

    private static final Logger log = LoggerFactory.getLogger(MySessionListener.class);

    public MySessionListener() {

    }

    public void sessionCreated(HttpSessionEvent event) {
        log.debug("Current Session created : "
              + event.getSession().getId()+ " at "+ new Date());
    }

    public void sessionDestroyed(HttpSessionEvent event) {
        // get the destroying session...

        HttpSession session = event.getSession();
        prepareLogoutInfoAndLogoutActiveUser(session);

        log.debug("Current Session destroyed :"
              + session.getId()+ " Logging out user...");

        /*
         * nobody can reach user data …
Run Code Online (Sandbox Code Playgroud)

java jsf servlets

15
推荐指数
2
解决办法
2万
查看次数

在JSF/JSP EL和Javascript中连接字符串

我在使用EL和javascript函数时遇到了麻烦(JSF 1.2,Facelets,Richfaces 3.3.0GA).我有一个包含另一个组成的页面:

<ui:include src="/pages/panels/examinationPanel.xhtml">
<ui:param name="prefix" value="new" />
Run Code Online (Sandbox Code Playgroud)

而在我看来,ui:composition我想把它附加prefix到每个身份证上.例如:

<rich:modalPanel id="#{prefix}_examinationPanel">
Run Code Online (Sandbox Code Playgroud)

这没问题.

但问题来自于我想要访问函数中的组件,因为oncomplete我无法正确地连接字符串.例如

oncomplete="#{rich:component('#{prefix}_examinationPanel')}.show();"
Run Code Online (Sandbox Code Playgroud)

我也试过fn:join但它没有执行该函数,因为它在发现"#"字符时会抱怨错误.例如:

 oncomplete="#{rich:component(fn:join(#{prefix},'examinationPanel'))}.show()"
Run Code Online (Sandbox Code Playgroud)

SEVERE: Servlet.service() for servlet Faces Servlet threw exception org.apache.el.parser.ParseException: Encountered "fn:join( #" at line 1, column 33.

Encountered "fn:join( #"
Run Code Online (Sandbox Code Playgroud)

如果我用括号或#和括号括起来,会出现不同的错误.

我究竟做错了什么?

另一个问题,在条件命令中

oncomplete="#{a}?#{b}:#{c}"
Run Code Online (Sandbox Code Playgroud)

如果真或假,我如何"分组"才能执行更多操作?例如这样的事情:

oncomplete="#{a}?(#{b}#{f}):(#{c}#{d}#{e})"
Run Code Online (Sandbox Code Playgroud)

我试过括号,但没有正确解析它.

提前致谢.

java jsf jsp richfaces el

10
推荐指数
2
解决办法
3万
查看次数

where子句中的oracle原始数据类型

我的数据库中有一列RAW类型.我怎样才能在where子句中使用它?
即只获取第三个字节等于4的值.
这不起作用:

SELECT v from T where v[3]=4
Run Code Online (Sandbox Code Playgroud)

sql oracle

8
推荐指数
1
解决办法
8947
查看次数

显示时modalPanel延迟渲染

动机:我想在访问时减小页面的大小,所以我认为modalPanels上的延迟渲染会有所帮助.想法是在用户单击显示它的链接时呈现modalPanel.

我想在rich:modalPanel单击显示它的链接时进行延迟渲染.为了达到这个目的,我找到了一种方法:

代码modalPanel,包裹在里面a4j:outputPanel

 <a4j:outputPanel id="a4jPanel">
  <rich:modalPanel id="panel" rendered="#{bean.renderPanel}">
         <!-- here modalPanel things -->
  </rich:modalPanel>
 </a4j:outputPanel>
Run Code Online (Sandbox Code Playgroud)

支持bean的代码(会话范围):

   public boolean isRenderPanel() {
   return renderPanel;   //default value is false;
   }

    public void setRenderPanel(boolean value){
           this.renderPanel=value;
    }

    public setRenderFalse(){
           this.setRenderPanel(false);
    }
Run Code Online (Sandbox Code Playgroud)

调用它的页面代码:

<a4j:form>
<a4j:jsFunction name="setRenderFalse" action="#{user.setRenderFalse}"/>
<a4j:commandLink value="render and show"  oncomplete="Richfaces.showModalPanel('panel');setRenderFalse();" reRender="a4jPanel">
<f:setPropertyActionListener target="#{user.renderPanel}" value="true" />
</a4j:commandLink>
</a4j:form>
Run Code Online (Sandbox Code Playgroud)

问题:

  • modalPanel需要包含在一个a4j:outputPanel因为reRendering直接modalPanel不起作用(我从来不明白为什么).

  • 渲染之后,需要额外的请求将渲染值设置为false(bean是会话范围的).否则,如果我们重新加载页面,则不会有任何延迟渲染,因为该值设置为true.

  • 支持bean必须处理一个属性以保持每个modalPanel的状态,尽管此属性设置为true每次单击链接并设置为false请求完成时.我试图rendered用JS变量保持状态,但它似乎不起作用(它们只是在页面加载后再读取而且从不再读取).

有更优雅的方式吗?

jsf richfaces

7
推荐指数
1
解决办法
5825
查看次数

rich:dbatable中的列宽

如何设置rich:column内部的colum宽度rich:datatable?该width属性被忽略.请参阅以下代码:

<rich:column label="#{msg[result]}" width="150px">
<f:facet name="header">
    <h:outputText value="#{veryLongText}"/>
</f:facet>
<h:outputText value="#{someValue}" /> 
<f:facet name="footer">
    <h:outputText value="#{someValue}" /> 
</f:facet>
</rich:column>
Run Code Online (Sandbox Code Playgroud)

如果渲染此列并且veryLongText宽度大于150px,则不会在多行中将其分解.相反,它只是忽略列宽并占用所需的空间.

如何解决这个问题?

css richfaces jsf-2

7
推荐指数
1
解决办法
3万
查看次数

a4j:commandLink在reRender之后停止工作

我创建了这个测试用例来隔离我的问题.一旦轮询执行ajax更新,就不会执行a4j:commandLink操作.如果我们在轮询的reRender之前关闭modalPanel,则执行它.

有什么建议吗?提前致谢.

test.xhtml:

<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:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns:fn="http://java.sun.com/jsp/jstl/functions" xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:fnc="http://eyeprevent.com/fnc">
<a4j:outputPanel id="testing">
<rich:modalPanel id="examinationPanel" autosized="true" width="450" rendered="#{test.condition2}">
    <f:facet name="header">
        <h:outputText value="View Examination Images" />
    </f:facet>
    <f:facet name="controls">
        <h:panelGroup>

            <a4j:form>

                <a4j:commandLink action="#{test.close}">
                    <h:graphicImage value="/images/modal/close.png" id="hideExaminationPanel" styleClass="hidelink" />
                </a4j:commandLink>
            </a4j:form>
            <rich:componentControl for="examinationPanel" attachTo="hideExaminationPanel" operation="hide" event="onclick" />

        </h:panelGroup>
    </f:facet>


    <a4j:form>

        <h:panelGrid columns="1" id="timeoutText">
            <h:outputText id="remainingtime" value="condition1" rendered="#{test.condition1}" />
            <h:outputText id="timer" value="condition2" rendered="#{test.condition2}" />

        </h:panelGrid>

        <a4j:poll id="poll" interval="5000" enabled="#{test.poll}" reRender="poll,timeoutText" />



    </a4j:form>
</rich:modalPanel>
Run Code Online (Sandbox Code Playgroud)

链接

TestBean.java

import org.apache.log4j.Logger;
public class TestBean { …
Run Code Online (Sandbox Code Playgroud)

java jsf richfaces

6
推荐指数
1
解决办法
9969
查看次数

没有Accept标头的AWS API Gateway二进制输出

根据http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-payload-encodings.html

If contentHandling is not defined, and if the Content-Type header of the response and the Accept header of the original request match an entry of the binaryMediaTypes list, API Gateway passes through the body. This occurs when the Content-Type header and the Accept header are the same; otherwise, API Gateway converts the response body to the type specified in the Accept header.

我无法发出原始请求发送Accept标头.如何让我的AWS API Gateway以二进制格式返回?(图像/ JPEG).因为我从s3发回的图像在最后一个阶段被转换为文本(因为原始请求缺少Accept: image/jpeg标题).

binary header http amazon-web-services aws-api-gateway

5
推荐指数
1
解决办法
1432
查看次数