简体   繁体   English

在jsf 1.2中使用a4j:support

[英]Using a4j:support with jsf 1.2

I need to make some save action on h:selectonemenu. 我需要对h:selectonemenu进行一些保存操作。 When it's value change then it should save this value, but without page refresh (so without submit). 更改值时,应保存该值,但不刷新页面(因此不提交)。

Unfortunatelly I must work with jsf 1.2. 不幸的是,我必须使用jsf 1.2。 After some research I've found that it can be done with a4j:support, however I have no idea how to include it into my project. 经过一些研究,我发现可以使用a4j:support来完成,但是我不知道如何将其包含到我的项目中。 Do I need to download some old richfaces libraries ? 我需要下载一些旧的richfaces库吗? (as i know richfaces 4 doesnt support jsp syntax). (据我所知,richfaces 4不支持jsp语法)。 Or does exists some other way to achieve this goal ?? 还是存在其他实现此目标的方法?

1. You could use Richfaces 3.3.4.Final (downaload here ). 1.您可以使用Richfaces 3.3.4.Final( 在此处下载 )。

This is way you should include, register and use libraries in a project. 是您应该在项目中包括,注册和使用库的方式。 Notice: 注意:

A JSF application with RichFaces assumes that the following JARs are available in the project: commons-beanutils-1.7.0.jar, commons-collections-3.2.jar, commons-digester-1.8.jar, commons-logging-1.0.4.jar, jhighlight-1.0.jar. 使用RichFaces的JSF应用程序假定项目中提供以下JAR:commons-beanutils-1.7.0.jar,commons-collections-3.2.jar,commons-digester-1.8.jar,commons-logging-1.0.4。 jar,jhighlight-1.0.jar。

Example (from developer guide ) for your case: 针对您的案例的示例(来自开发人员指南 ):

<h:form id="planetsForm">
<h:outputLabel value="Select the planet:" for="planets" />
<h:selectOneMenu id="planets" value="#{planetsMoons.currentPlanet}" valueChangeListener="#{planetsMoons.planetChanged}">
    <f:selectItems value="#{planetsMoons.planetsList}" />
    <a4j:support event="onchange" reRender="moons" />
</h:selectOneMenu>
<h:dataTable id="moons" value="#{planetsMoons.moonsList}" var="item">
    <h:column>
        <h:outputText value="#{item}"/>
    </h:column>
</h:dataTable>

2. Example of other solution: 2.其他解决方案示例:

You could use jQuery.ajax() with custom servlet. 您可以将jQuery.ajax()与自定义servlet一起使用。

JS: JS:

$.ajax({
        type: 'GET',
        url: '/app/customservlet.jsf?value=' + selectOneValue; //selected value
});

Servlet: Servlet:

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse res) {     
    String selectOneValue = req.getParameter("value");      
    //do something
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM