Click here to Skip to main content
15,889,096 members

JSF2 calendar - How to implement and event after value is set ?

mnd017 asked:

Open original thread
Hi, I've a composite with calendar component inside. I need to catch an event when calendar was changed but in my mainBean (not composite bean).
So, I've got 4 files: mainBean.java, main.xhtml and coposite: myCalendar.xhtml with calComp.java. I want to call 'changed' event in mainBean.java and have no idea how to achive that.

Here is the code:
Composite:

XML
<composite:interface componentType="myComponent">
    <composite:attribute name="value" required="true"/>
    <composite:attribute
            name="myListener"
            method-signature="void listener()" />

</composite:interface>

<composite:implementation>
    <h:panelGroup id="container">

        <p:calendar
            value="#{cc.attrs.value}"
            valueChangeListener="#{cc.valueChanged}"
            <p:ajax event="dateSelect"  update="@this,:buttonpanel" listener="#{cc.attrs.myListener}"/>
        </p:calendar>

    </h:panelGroup>
</composite:implementation>


Main page:

<cc:inputdate value="#{mainBean.item.myDate}" myListener="#{mainBean.event1}"/>


bean for main page:

C#
public void event1()
    {
        log("Event1!!!!");
    }



I've got also log in setMyDate() method. So I now exactly when mainBean has new date set.

In composite's bean there is only "log code", but It was enough to see that Event1 was called before the new value was set..

My question is: How can I catch an event, that will be called AFTER the value for myDate is set? In that event I want to do "getMyValue" with new value. Thanks for help.
Tags: Java, Event, JSF

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900