小编Kuk*_*tje的帖子

正规用于手机

我想使用Validators验证一些JSF的字段.我正在寻找一种模式来验证只接受以下条件的手机号码:

1-可以在开头包含一个可选的'+'(并且在开头的'+'之后不应该有空格).

2-这个数字可能包含一到几个字符:

  • 数字字符[0-9]
  • 连字符( - )
  • 空间
  • 点(.)

我正在使用这种模式,(^\\+)?[0-9\\s-\\.]*但它不起作用,特别是我无法意识到这种情况"从开头'+'之后应该没有空间"

我的代码:

public Boolean isValid(String str) throws PatternSyntaxException {

        Pattern pattern = Pattern.compile("(^\\+)?[0-9\\s-\\.]*");
        Matcher matcher = pattern.matcher(telFax);
        boolean result = matcher.matches();

    return result;
}
Run Code Online (Sandbox Code Playgroud)

java regex validation jsf

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

在primefaces 数据表列中居中输出文本

我已经搜索了几个小时的资源,试图找到一个可行的解决方案来解决我认为的一个简单问题:如何将输出文本集中在一个 primefaces 数据表的各个列中?

我看到的每一个地方都说用<div>标签包围列,这对我来说真的很奇怪而且效率低下。很多地方都说使用style="center",这是行不通的。即使在primefaces.org extensions 展示中给出的例子也表明这不起作用,他们有:

 <p:column filterBy="#{message.country}">  
      <f:facet name="header">  
         <h:outputText value="Country" />  
      </f:facet>  
         <h:outputText value="#{message.country}" style="center"/>  
 </p:column>  
Run Code Online (Sandbox Code Playgroud)

然而,国家/地区的数据向左对齐。

为了使列中的文本居中:

<p:column headerText="Last Name">
    <h:outputText value="#{item.lastName}" />
</p:column>
Run Code Online (Sandbox Code Playgroud)

这是:

<p:column headerText="Last Name">
    <div align="center">
        <h:outputText value="#{item.lastName}" />
    </div>
</p:column>
Run Code Online (Sandbox Code Playgroud)

唯一的办法?

css jsf primefaces

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

将 @SessionScoped CDI bean 注入 JSF @ManagedBean 后实例为 null

我有: - 存储库类:

@SessionScoped
public class EmployeeRepository {
    @PersistenceContext
    EntityManager entityManager;
    public List<Employee> getEmployees(){
        TypedQuery<Employee> qu = entityManager.createQuery("select * from Employee", Employee.class);
        List<Employee> emp2 = qu.getResultList();
        return emp2;
    }
}
Run Code Online (Sandbox Code Playgroud)

托管 Bean:

@ManagedBean(name = "helloWorldBean")
public class HelloWorldBean {
    @Inject
    private EmployeeRepository employeerepo;
    public String getMsg() {
        return "Hallo";
    }
    public String getEmployees() {
        return String.valueOf(employeerepo.getEmployees().size());
    }
}
Run Code Online (Sandbox Code Playgroud)

和一个 JSF 页面:

<h:head>
    <title>JavaCodeGeeks</title>
</h:head>
<h:body>
    - Message : <h:outputText value="#{helloWorldBean.msg}" />
    - Employee count : <h:outputText value="#{helloWorldBean.employees}" />
</h:body> …
Run Code Online (Sandbox Code Playgroud)

jsf inject cdi

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

未找到 PrimeFaces 7.0 getCallbackParams()

我刚刚从 PrimeFaces 6.2 升级到 7.0,但找不到getCallbackParams(). 在 PrimeFaces 6.2 中,它没有被弃用,也没有暗示它会在后续版本中移动。

某些RequestContext功能已移至PrimeFaces.current().ajax()(如addCallbackParam()),但也不在那里。

它是否已被移除或移至其他地方?

jsf primefaces primefaces-7.0

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

p:commandButton不能显示p:对话框

我在单击时显示对话框有问题。这是显而易见的,但我无法发现该错误。我已经坚持了好几天,这太疯狂了。你能帮我吗。

<h:form id="form">

<p:commandButton
    rendered="#{characterBean.characterSession.characterName ne null}"
    value="#{characterBean.characterSession.title.titleName}"
    icon="fa fa-fw fa-edit" onclick="PF('dlg').show();"
    update="@form"/>

<p:dialog id="titleDetail" header="#{i18n['title.yourTitles']}"
    widgetVar="dlg" dynamic="true" closable="false" resizable="false"
    showEffect="fade" hideEffect="fade">
    <h:panelGroup>
        <p:messages autoUpdate="true" />
        <h:selectOneMenu id="titleSelect" converter="#{titleConverter}"
            value="#{characterBean.characterSession.title}">
            <f:selectItems value="#{characterBean.titleUnlocked}" var="t"
                itemValue="#{t}" itemLabel="#{t.titleName}" />
        </h:selectOneMenu>
        <hr />
        <h:panelGrid columns="2" style="width: 100%; text-align:center">
            <p:commandButton value="#{i18n['general.submit']}"
                icon="fa fa-check"
                actionListener="#{characterBean.updateCharacterTitle}"
                oncomplete="PF('dlg').hide();" update="@form" />

            <p:commandButton value="#{i18n['general.cancel']}"
                icon="fa fa-close" action="#{characterBean.submitCancel}"
                oncomplete="PF('dlg').hide();" update="@form" process="@this" />
        </h:panelGrid>
        <p:remoteCommand name="updateForm()" process="@this" update="@form" />
    </h:panelGroup>
</p:dialog>

</h:form>
Run Code Online (Sandbox Code Playgroud)

jsf primefaces

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

使用 p inputMask 后无法接受输入数字,为大于 999 的数字添加逗号

对于下面的输入文本字段,用户可以输入 1 到 99,999 之间的值。只输入数字。

<p:message for="usage" display="text"><p:autoUpdate/></p:message>
<p:inputText id="usage" maxlength="10" required="true"
    requiredMessage="You must provide an input" value="#{powerMB.usage}">  
    <f:validateDoubleRange minimum="1" maximum="99999" for="usage" />   
    <p:keyFilter regEx="/[0-9]/i"  />         
</p:inputText>
Run Code Online (Sandbox Code Playgroud)

当前输入值接受 - 示例

1 
34                      
99
3534
53535
Run Code Online (Sandbox Code Playgroud)

我曾试图掩盖一个特定的输入值

如何将 Primefaces inputMask 限制为仅数字?

https://www.primefaces.org/showcase/ui/input/inputMask.xhtml

试图为大于 999 的数字添加逗号

我收到以下代码的以下错误

usage: Validation Error: Value is not of the correct type
Run Code Online (Sandbox Code Playgroud)
<p:message for="usage" display="text"><p:autoUpdate/></p:message>
<p:inputMask id="usage" maxlength="5" required="true"
    requiredMessage="You must provide an input" mask="99,999" value="#{powerMB.usage}">  
    <f:validateDoubleRange minimum="1" maximum="99999" for="usage" />   
</p:inputMask>
Run Code Online (Sandbox Code Playgroud)

输入给定为

1 …
Run Code Online (Sandbox Code Playgroud)

validation jsf primefaces input-mask

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

如何解决 java.lang.LinkageError: 加载器约束冲突

每当我在 Eclipse 中部署 Liferay portlet 的 war 文件时,我都会收到以下错误。任何人都可以帮助我知道为什么会发生这种情况以及如何解决它。

java.lang.LinkageError: loader constraint violation: when resolving overridden method "com.liferay.portal.spring.extender.internal.context.ModuleBeanFactoryPostProcessor.postProcessBeanFactory(Lorg/springframework/beans/factory/config/ConfigurableListableBeanFactory;)V" the class loader (instance of org/eclipse/osgi/internal/loader/EquinoxClassLoader) of the current class, com/liferay/portal/spring/extender/internal/context/ModuleBeanFactoryPostProcessor, and its superclass loader (instance of org/apache/catalina/loader/WebappClassLoader), have different Class objects for the type org/springframework/beans/factory/config/ConfigurableListableBeanFactory used in the signature
    at com.liferay.portal.spring.extender.internal.context.ModuleApplicationContextRegistrator._createApplicationContext(ModuleApplicationContextRegistrator.java:138)
    at com.liferay.portal.spring.extender.internal.context.ModuleApplicationContextRegistrator.start(ModuleApplicationContextRegistrator.java:60)
    at sun.reflect.GeneratedMethodAccessor756.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.felix.dm.InvocationUtil.invokeMethod(InvocationUtil.java:111)
    at org.apache.felix.dm.InvocationUtil.invokeCallbackMethod(InvocationUtil.java:66)
    at org.apache.felix.dm.impl.ComponentImpl.invokeCallbackMethod(ComponentImpl.java:769)
    at org.apache.felix.dm.impl.ComponentImpl.invoke(ComponentImpl.java:760)
    at org.apache.felix.dm.impl.ComponentImpl.bindService(ComponentImpl.java:705)
    at org.apache.felix.dm.impl.ComponentImpl.access$400(ComponentImpl.java:54)
    at org.apache.felix.dm.impl.ComponentImpl$7.run(ComponentImpl.java:202)
    at org.apache.felix.dm.impl.SerialExecutor.runTask(SerialExecutor.java:137)
    at org.apache.felix.dm.impl.SerialExecutor.runTasks(SerialExecutor.java:119)
    at org.apache.felix.dm.impl.SerialExecutor.execute(SerialExecutor.java:85)
    at org.apache.felix.dm.impl.ComponentImpl.calculateStateChanges(ComponentImpl.java:252) …
Run Code Online (Sandbox Code Playgroud)

java classloader liferay-7

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

单击确认对话框后,无法下载zip文件。

我无法下载该zip文件。在confirmDialog中单击“确定”按钮后,我无法下载zip文件。如果我没有使用confirmDialog,则可以下载文件。谁能帮我这个忙,

在这里,我添加了代码以供参考。

<h:form>
    <p:panelGrid rendered="true">
        <p:commandButton style="HEIGHT: 24px; WIDTH: 300px" id="AjaxFalse"
            value="AjaxFalse"
            action="#{testDownload.getZipFile}"
            title="AjaxFalse" rendered="true">
            <p:confirm message="Are you sure?"
                header="Confirmation"
                icon="ui-icon-alert" />
        </p:commandButton>

    </p:panelGrid>

    <p:confirmDialog global="true" showEffect="fade" hideEffect="fade" width="500">
                <h:panelGroup layout="block" style="text-align: center">
                    <p:commandButton value="Ok"  type="submit" styleClass="ui-confirmdialog-yes" style="width:70px;"/>
                    <p:commandButton value="Cancel" type="button" styleClass="ui-confirmdialog-no" style="width:70px;"/>
                </h:panelGroup>
    </p:confirmDialog>
</h:form>
Run Code Online (Sandbox Code Playgroud)

我的菜豆是

public class TestDownload
{
//some code here
//Downloading the zip file in jsf2.x
public String getZipFile()
    {       
    try{
    //enter code here
            FacesContext fc = FacesContext.getCurrentInstance();
            ExternalContext ec = fc.getExternalContext();
            ec.setResponseHeader("Content-Disposition", "attachment;filename=\"" + Test …
Run Code Online (Sandbox Code Playgroud)

jsf primefaces

0
推荐指数
1
解决办法
616
查看次数

如何在单个页面上创建多个p:确认对话框

我需要使用Primefaces在单个XHTML页面上请求两种不同类型的确认对话框.Primefaces展示中的当前示例非常基本.以下是我的基本示例:

<h:form id="mydatatableform"> 
<p:dataTable ... />
    <p:column ... headerText="Column A Data">
        <h:outputText ... />
    </p:column>
    <p:column ... headerText="Acknowledge Docs">
        <p:commandButton value="Acknowledge" ...
            <p:confirm ajax="true" header="Confrimation" message="Do Acknowledge you have received the docs?"/>
        </p:commandButton>
    </p:column>
    <p:column ... headerText="Accept or Deny">
        <p:commandButton value="Accept or Deny" ...
            <p:confirm ajax="true" header="Confrimation" message="Do you Accept or Deny the proposal?"/>
        </p:commandButton>
    </p:column>
</p:dataTable>
</h:form>
<p:confirmDialog id="yesno" global="true">
    <h:form>
        <p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
        <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
    </h:form>
</p:confirmDialog>
Run Code Online (Sandbox Code Playgroud)

好消息是这个工作得很好.

不幸的是,对于Accept或Deny问题的对话框中的选项,用户不希望是否.他们希望在对话框中接受或拒绝.

我找不到任何关于如何使用两个不同的confirmDialog选项或从一个或另一个中选择的方法的好例子.

理想情况下,第二个confrimDialog看起来像这样: …

jsf primefaces jsf-2

0
推荐指数
1
解决办法
6136
查看次数

可以从验证器类设置xp:control的styleClass吗?

对于表格,我为编辑框设置了一个有效期,例如:

<xp:inputText
    id="inpRiskFactors" 
    styleClass="inputEscalation"
    value="#{matterBean.matter.escRiskFactors}" 
    validator="#{matterValidators.valEscRiskFactors}"...
Run Code Online (Sandbox Code Playgroud)

以下是我的验证方法的片段:

public void valEscRiskFactors(FacesContext facesContext, UIComponent component, Object value) {        
        utils.printToConsole(this.getClass().getSimpleName().toString() + " - valEscRiskFactors(...), value = " + value.toString());
        String msg = null;
        if (value.toString().replaceAll("\\s+","").equals("")){
            msg = matterProp.getProperty("msg_valid_esc_risk_factors");
            FacesMessage message = new FacesMessage(msg);
            throw new ValidatorException(message);
        }       
    }
Run Code Online (Sandbox Code Playgroud)

我想知道我是否可以从此方法更改/设置调用组件(UIComponent组件)的styleclass属性?

对于用户来说,最好在xp上应用一些CSS:所需的控件并且不通过验证.

任何人都有一个线索如何实现这一目标?

jsf xpages

0
推荐指数
1
解决办法
45
查看次数

Primefaces autoUpdate 只工作一次

我有一个页面有不同的计算,这是由 ajax 完成的。
在页面的末尾应该有一个提示文本,每次计算后都会更新。

为此,我使用了autoUpdatePrimefaces的功能。

当我最初加载页面时,文本显示正确。同样在第一次计算后,文本会正确刷新。但是如果我做进一步的计算,无论balanceController.getBalance()返回哪个值,文本都不会再改变。
当我调试我的代码时,我看到它balanceController.getDetails()运行正确并且还返回了所需的文本。只有我页面上的内容没有刷新。当我手动重新加载页面(使用浏览器)时,会出现正确的文本。

<p:autoUpdate/>仅在第一次计算期间执行并更新选项卡内容的原因可能是什么?

余额页面.xhtml

<p:tab title="Further details" rendered="#{balanceController.showDetails()}">
    <p:autoUpdate/>

    <h:outputText value="#{balanceController.details}"/>
</p:tab>
Run Code Online (Sandbox Code Playgroud)

平衡控制器.java

public String getDetails() {
    if ( getBalance() >= 0 ) {
        return "Your current balance is: " + Double.toString(getBalance());
    } else {
        return "Your credit has been used up!";
    }
}
Run Code Online (Sandbox Code Playgroud)

jsf primefaces

0
推荐指数
1
解决办法
271
查看次数