1

I have link that opens popup panel, before opening that panel I would like some action to be executed from my ejb stateless bean and popup panel should be rendered. After opened that panel I click commandButton which should execute action from my bean and close that panel. Second action is not executed.

If I remove 'render' attribute from first a4j:commandLink everything is ok.

I used: Richfaces 4.1.0.Final (I also tried 4.2.3.Final and the newest: 4.3.0.20121214-M3), Seam 3.1.0.Final, JBoss 7.1.1.Final.

my_page.xhtml:

    <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:s="http://jboss.org/seam/faces"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich">

<h:head></h:head>
<h:body>
    <h:form>
        <a4j:commandLink action="#{myBean.init()}" render="myPopupPanel"
            oncomplete="#{rich:component('myPopupPanel')}.show(); return false;">
            Open panel
        </a4j:commandLink>
    </h:form>

    <rich:popupPanel id="myPopupPanel" modal="false" autosized="true"
        resizeable="false">
        <h:form id="deviceInputEditForm">

            <a4j:commandButton action="#{myBean.doAction()}" value="DoAction"
                oncomplete="#{rich:component('myPopupPanel')}.hide();" />

        </h:form>
    </rich:popupPanel>
</h:body>
</html>

MyBean.java:

package com.hajdi.test;

import javax.ejb.Stateless;
import javax.inject.Named;

@Named
@Stateless
public class MyBean {
   public void init() {
      System.out.println("Init called.");
   }

   public void doAction() {
      System.out.println("doAction called");
   }
}
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
user2017741
  • 11
  • 1
  • 2
  • I never used rich faces, only prime faces. But I will try to guess the component you are trying to access on onComplete method needs to be inside the same form the commandButton is. Also check the POST reply from http they usually bring error messages with information on whats wrong. – fredcrs Jan 28 '13 at 10:55
  • Which scope is your bean in? Did you forget to add it? See: http://stackoverflow.com/questions/8707460/passing-state-between-ejb-methods-requestscoped-and-stateless – Johny T Koshy Jan 28 '13 at 11:24
  • @fredcrs Thanks it works! I put first commandLink and popupPanel in one form and it works. – user2017741 Jan 28 '13 at 13:01
  • np, just added the answer in case someone faces the same problem – fredcrs Jan 28 '13 at 17:13

7 Answers7

1
  1. it is better to render a inner component id of the popupPane instead of the popupPane id.
  2. In jsf 2, it is better to use only ONE form for one page, the state management is based on the form, I think this is a big design issue in jsf2. Before Richfaces 4.3, two forms will cause some weird problem, I do not know if 4.3 fixed it. MyFaces has its solution to void the multi form problems.
Hantsy
  • 8,006
  • 7
  • 64
  • 109
1

You can create an under form in popup panel like

<rich:popupPanel id="myPopupPanel" modal="false" autosized="true"
        resizeable="false">
        <h:form id="deviceInputEditForm">
           <s:div id="anythingyouwant>"
            <a4j:commandButton action="#{myBean.doAction()}" value="DoAction"
                oncomplete="#{rich:component('myPopupPanel')}.hide();" />
            </s:div>
        </h:form>
    </rich:popupPanel>

And then try to re render that from your first like

<h:form>
        <a4j:commandLink action="#{myBean.init()}" render="anythingyouwant"
            oncomplete="#{rich:component('myPopupPanel')}.show(); return false;">
            Open panel
        </a4j:commandLink>
    </h:form>
enter code here

give it a try and let me know here

Jim
  • 11
  • 1
0

I never used rich faces, only prime faces. But I will try to guess the component you are trying to access on onComplete method needs to be inside the same form the commandButton is. Also check the POST reply from http they usually bring error messages with information on whats wrong

fredcrs
  • 3,558
  • 7
  • 33
  • 55
0

the render="myPopupPanel" attribute shouldn't be reRender="myPopupPanel"?

0

I suggest to try:

<h:body>
    <h:form>
        <a4j:commandLink action="#{myBean.init()}" render="myPopupPanel"
            oncomplete="#{rich:component('myPopupPanel')}.show(); return false;">
            Open panel
        </a4j:commandLink>

    <rich:popupPanel id="myPopupPanel" modal="false" autosized="true"
        resizeable="false">
            <a4j:commandButton action="#{myBean.doAction()}" value="DoAction"
                oncomplete="#{rich:component('myPopupPanel')}.hide();" />
    </rich:popupPanel>

    </h:form>
</h:body>

It is usually better to have only one form element when we use rich faces...

Regards

Rodmar Conde
  • 956
  • 1
  • 12
  • 24
0

https://stackoverflow.com/a/6908500/3583985

Try with above link.its sorted my question too.. same problem faced by me

add region tags and all are works well

thanks

Community
  • 1
  • 1
Priyan Chngd
  • 21
  • 1
  • 8
0

a4j:commandLink doesn't have any attribute as render, i think you misspelled it. The attribute name is rendered.

<a4j:commandLink action="#{myBean.init()}" rendered="myPopupPanel" oncomplete="#{rich:component('myPopupPanel')}.show(); return false;"> Open panel </a4j:commandLink>

ved raj
  • 33
  • 4
  • 1
    You're confusing RichFaces 3.x with 4.x. See the docs: http://docs.jboss.org/richfaces/latest_4_0_X/vdldoc/a4j/commandLink.html Still then, the correct RichFaces 3.x approach would be using `reRender` attribute and very definitely not `rendered`. See the docs: http://docs.jboss.org/richfaces/latest_3_3_X/en/tlddoc/a4j/commandLink.html – BalusC Sep 13 '14 at 10:34
  • Sorry sorry... actual atribute name is `reRender` for 3.x and `render` for 4.x. `rendered` is another flag that indicating whether or not this component should be rendered. The default value for this property is true. Thanks @BalusC for correcting me :) – ved raj Dec 23 '16 at 07:11