Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8913851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:33:45+00:00 2026-06-15T04:33:45+00:00

In the bad old days in my codebase we relied quite heavily on event

  • 0

In the bad old days in my codebase we relied quite heavily on event requeuing, which I suspect worked due to implementation details in ICEfaces or MyFaces rather than standard-specified behavior. One thing we used to do frequently was this kind of thing:

<ice:inputText value="#{bb.frequency}" valueChangeListener="#{bb.valueChanged}"/>

The goal is to arrange for retune to be called after setFrequency whenever the frequency changes.

Then we had some fairly disgusting code in the backing bean which would requeue the event. It usually looked something like this:

class BB {
  // this happens first, thanks to UPDATE_MODEL_VALUES
  public void setFrequency(Frequency f) {
    this.model.f = f;
  }

  public void valueChanged(ValueChangeEvent event) {
    if (event.getOldValue().equals(event.getNewValue())
      return; // nothing changed, so leave

    if (FacesContext.getCurrentInstance().getPhaseId() != INVOKE_APPLICATION) {
      OurMagicEventUtils.requeueEvent(event, INVOKE_APPLICATION);
    }
    else {
      // do the post-setter work here (the setter happened recently during 
      // UPDATE_MODEL_VALUES so we're up-to-date by here
      this.model.retune();
    }
  }
}

This isn’t a good way to live. I haven’t found a reliable way to requeue events for later phases and it clearly isn’t the kind of thing people do. I see two solutions:

  1. Move the retune intelligence to the BB#setFrequency method.

    I can’t get away with this in many cases because I’m directly addressing a lower-level model class and I don’t want to disturb its behavior for other clients.

  2. Create a custom component and move the logic into the setFoo method there.

    I don’t love this because there are a lot of issues with Mojarra and custom components when embedded in other containers. It also seems like overkill for what I need to do—I literally just need to call retune after setting some properties.

  3. Create backing beans for everything. Delegate most methods directly to the inner thing, but catch setFoo and perform the retune there. This is very similar to what we used to do, and it means a lot of boilerplate, wrappers, and glue code, so I don’t love it.

In my mind I imagine something like this:

<ice:inputText value="#{bb.frequency}" afterChange=#{bb.retune}"/>

but that obviously doesn’t work, nor would attaching an <f:actionListener> since that requires a class name but has no association to whatever you’re currently doing, and besides it can only be set on UICommands which UIInputs are not.

What’s the elegant/correct way to solve this dilemma?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:33:48+00:00Added an answer on June 15, 2026 at 4:33 am

    As you’re using JSF2 already, just use <f:ajax>.

    <ice:inputText value="#{bb.frequency}">
        <f:ajax listener="#{bb.retune}"/>
    </ice:inputText>
    

    with

    public void retune(AjaxBehaviorEvent event) { // Note: the argument is optional.
        // ...
    }
    

    This will be invoked during invoke action phase when the HTML DOM change event has occured.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the bad old days of interactive console applications, Don Libes created a tool
I am trying to break some of my old habits of writing bad code.
From my age old php days (years ago) I slightly remember that I had
I created a local copy of a remote repository. Because of some old bad
I found the following in some old and bad documented C code: #define addr
This bad boy just does not want to change size to fill the dock
How bad is it to use Location Manager to retrieve the location information when
What bad things happen at the moment document.write() is invoked? I've heard bits and
Sorry for the bad title - I simply do not know what to call
Is it bad practice to have a custom cursor on a website? Not just

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.