JSF2忽略了Action属性 [英] JSF2 ignores Action attribut

查看:83
本文介绍了JSF2忽略了Action属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的xhtml代码:

<h:commandLink action="#{detailController.updateProject}" class="positive" >
 <h:graphicImage library="img" name="tick.png" alt=""/> 
 <h:outputText value="Save" />
</h:commandLink>

未从JSF框架调用此操作(updateProject())!即使我在managedBean中将其删除,也不会引发任何异常.

This action (updateProject()) is not being called from JSF framework! Even if I delete it in the managedBean there is no exception thrown.

还有其他人有这样的问题吗?我什至无法解释-.-我的意思是这种行动方式!

Does anybodyelse has had problems like that? I can't even explain that -.- I mean this action ethod is there!

添加:是的,它在h:form标记中!但是我认为有两种形式!可能是问题所在吗?

ADD: Yes it is in a h:form tag! But I have two forms in that view! May that be the problem?

ADD2:我还要提到的是,如果我按了按钮,则会使我回到以前的视图!所以我的操作方法被忽略了,而是打开了另一个视图?!?!

ADD2: I should also mention that if I hit the button it throws me back to the previous view! So my action method is being ignored and instead it opens another view ?!?!

为了提供更多信息,我的页面是这样构建的:

To provide more information, my page is built like that:

panelGroup name=show rendered=!controller.edit
  form 
    buttons
    outputtext
  /form
/panelGroup

panelGroup name=edit rendered=controller.edit
   form
     buttons
     inputText
   /form
/panelGroup

所以我同时拥有一个文件的一个实体的编辑和显示!但是只有底部形式的按钮显示出这种奇怪的行为(见上文).

So I have both, edit and show of one entity at one file! But only the buttons in the bottom form show that strange behaviour (see above).

回答BalusC: 1.我使用两种形式(它们不嵌套!) 2.在底部,我已经放置了一个h:messages 我将尝试将控制器放入viewScop中以检查3和4 我不知道该怎么检查5. 谢谢你..

Answering BalusC: 1. I use two forms (they aren't nested!) 2. In the bottom form I had already placed a h:messages I'm gonna try putting my controller into viewScop for checking 3 and 4 I don't know how to check 5. Thank you for that..

推荐答案

这可能有很多可能的原因. @romaintaz仅提到了最明显的一个(最常见的初学者错误):UICommand组件必须放在UIForm组件内部.

This can have a lot of possible causes. @romaintaz has mentioned only the most obvious one (the most common beginner's mistake): UICommand components must be placed inside an UIForm component.

但是,原因更多:

  1. 您有多个嵌套表单.这在HTML中是非法的.该行为取决于所使用的Web浏览器,但通常该按钮不会执行任何操作.您可能没有嵌套表格,但可以并行使用它们.

  1. You have multiple nested forms. This is illegal in HTML. The behaviour is dependent on the webbrowser used, but usually the button won't do anything. You may not nest forms, but you can use them in parallel.

发生了验证或转换错误,h:message未能捕获该错误.通常,这会记录到stdout,但是您也可以使用h:messages来全部获取它们.

A validation or conversion error has occurred which is not been catched by a h:message. Normally this is logged to stdout, but you can also use h:messages to get them all.

UICommand组件被放置在UIData组件(例如h:dataTable)中,该组件的value在后续请求期间未正确保存.如果JSF找不到关联的数据行,则不会调用该动作.将bean放入view范围应该会很有帮助.

The UICommand component is been placed inside an UIData component (e.g. h:dataTable) whose value is not been preserved the right way during the subsequent request. If JSF cannot find the associated data row, the action won't be invoked. Putting bean in view scope should help a lot.

该组件或其父项之一具有rendereddisabled属性,该属性在应用请求值阶段期间评估了false.然后,JSF将不会调用该动作.将bean放入view范围应该会很有帮助.

The component or one of its parents has a rendered or disabled attribute which evaluated false during apply request values phase. JSF won't invoke the action then. Putting bean in view scope should help a lot.

某些PhaseListenerEventListenerFilterServlet已更改了JSF生命周期以跳过调用操作阶段或更改了请求参数,因此JSF无法调用动作.

Some PhaseListener, EventListener, Filter or Servlet in the request-response chain has changed the JSF lifecycle to skip the invoke action phase or altered the request parameters so that JSF can't invoke the action.

这篇关于JSF2忽略了Action属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆