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 4008162
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:43:12+00:00 2026-05-20T08:43:12+00:00

Background Use Ajax to fire an event to the web server when a list

  • 0

Background

Use Ajax to fire an event to the web server when a list of items are selected. The element is a JSF rich:orderingList item.

Problem

The class that must receive the event:

public class BusinessAreaListHandler extends ListHandler<ListElement> {
  private static final long serialVersionUID = -581048454118449233L;

  public BusinessAreaListHandler() { load(); }
  public List<ListElement> getBusinessAreas() { return getList(); }
  public Set<ListElement> getSelection() { return getSet(); }

  public void select() {
    System.out.println( "Clicked Element" );
  }

  protected void load() {
    appendList( new ListElement( "employee" ) );
    appendList( new ListElement( "company" ) );
    appendList( new ListElement( "payroll" ) );
  }
}

The ListElement container object:

public class ListElement implements Serializable {
  private static final long serialVersionUID = 5396525520175914504L;

  public final static char SEPARATOR = ':';

  private String id, value;

  protected ListElement( String value ) {
    this( Integer.toString( value.hashCode() ), value );
  }

  public ListElement( String id, String value ) {
    setId( id );
    setValue( value );
  }

  @Override
  public int hashCode() {
    return (53 * (getId().hashCode() + 5)) + (53 * (getValue().hashCode() + 5));
  }

  @Override
  public boolean equals( Object obj ) {
    ListElement le = null;

    if( obj != null && obj instanceof ListElement ) {
      le = (ListElement)obj;
    }

    return le == null ? false : compare( le );
  }

  private boolean compare( ListElement le ) {
    return getId().equals( le.getId() ) && getValue().equals( le.getValue() );
  }

  public String getId() {
    return this.id == null ? "" : this.id;
  }

  public void setId( String id ) {
    this.id = id;
  }

  public String getValue() {
    return this.value == null ? "" : this.value;
  }

  public void setValue( String value ) {
    this.value = value;
  }

  @Override
  public String toString() {
    return getValue();
  }
}

The ListConverter:

public class ListConverter implements Converter {
  @Override
  public Object getAsObject( FacesContext fc, UIComponent ui, String value ) {
    ListElement result = new ListElement( value );
    int index = value.lastIndexOf( ListElement.SEPARATOR );

    System.out.println( "Convert FROM: " + value );

    if( index > 0 ) {
      String id = value.substring( 0, index );
      String v = value.substring( index + 1 );
      result = new ListElement( id, v );
    }

    System.out.println( "Convert TO  : " + result.toString() );

    return result;
  }

  @Override
  public String getAsString( FacesContext fc, UIComponent ui, Object value ) {
    return value.toString();
  }
}

The XHTML fragment that sets up the list and event actions:

<h:panelGrid columns="2">
  <h:panelGroup>
    <rich:orderingList value="#{businessAreas.list}" var="businessArea" converter="businessAreaConverter" immediate="true" orderControlsVisible="false" fastOrderControlsVisible="false" selection="#{businessAreas.selection}" id="BusinessAreas">
      <f:facet name="caption">
        <h:outputText value="Business Areas" />
      </f:facet>
      <rich:column>
        <h:outputText value="#{businessArea}" />
      </rich:column>
      <a4j:support event="onclick" ignoreDupResponses="true" requestDelay="500" action="#{businessAreas.select}" reRender="ColumnClusters" />
      <a4j:support event="onkeyup" ignoreDupResponses="true" requestDelay="500" action="#{businessAreas.select}" reRender="ColumnClusters" />
    </rich:orderingList>
  </h:panelGroup>
  <h:panelGroup>
    <rich:listShuttle sourceValue="#{columnClusters.list}" targetValue="#{domainContent.list}" var="columnCluster" converter="columnClusterConverter" sourceRequired="false" targetRequired="true" moveControlsVisible="true" orderControlsVisible="false" fastOrderControlsVisible="false" sourceCaptionLabel="Column Clusters" targetCaptionLabel="Domain Content" copyTitle="Move" copyControlLabel="Move" copyAllControlLabel="Move All" copyAllTitle="Move All" id="ColumnClusters">
      <rich:column>
        <h:outputText value="#{columnCluster}" />
      </rich:column>
    </rich:listShuttle>
  </h:panelGroup>
  <h:panelGroup>
    <h:commandButton action="action" value="Create Domain" />
  </h:panelGroup>
</h:panelGrid>

The corresponding managed bean is set in faces-config.xml correctly.

Browser output:

Error Message

The following error message is displayed:

INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
sourceId=j_id2:ColumnClusters[severity=(ERROR 2), summary=(j_id2:ColumnClusters:
Validation Error: Value is required.), detail=(j_id2:ColumnClusters: Validation Error:
Value is required.)]

Logging

New Element (Hash:Value): 1193469614:employee
New Element (Hash:Value): 950484093:company
New Element (Hash:Value): -786522843:payroll
New Element (Hash:Value): 3373707:name
New Element (Hash:Value): -1147692044:address
New Element (Hash:Value): 114603:tax
New Element (Hash:Value): 1193469614:employee
Convert FROM: employee
Convert TO  : employee
New Element (Hash:Value): 950484093:company
Convert FROM: company
Convert TO  : company
New Element (Hash:Value): -786522843:payroll
Convert FROM: payroll
Convert TO  : payroll
New Element (Hash:Value): 3373707:name
Convert FROM: name
Convert TO  : name
New Element (Hash:Value): -1147692044:address
Convert FROM: address
Convert TO  : address
New Element (Hash:Value): 114603:tax
Convert FROM: tax
Convert TO  : tax

Question

What is required to trigger a call to select() in BusinessAreaListHandler when users select (or deselect) items?

References

  • http://anonsvn.jboss.org/repos/richfaces/branches/community/3.3.X/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Library.java
  • http://anonsvn.jboss.org/repos/richfaces/branches/community/3.3.X/samples/richfaces-demo/src/main/webapp/richfaces/orderingList/example/playlist.xhtml
  • http://livedemo.exadel.com/richfaces-demo/richfaces/orderingList.jsf
  • Richfaces combobox on selection changed event

Thank you!

  • 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-05-20T08:43:14+00:00Added an answer on May 20, 2026 at 8:43 am

    The problem is this attribute:

    targetRequired="true"
    

    Since the click triggers an immediate Ajax request to the server, it is expected that the right-hand shuttle (the target) has data. Without data, the validation error will be posted.

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

Sidebar

Related Questions

Is it possible/recommended to use background worker threads with the web browser control? I
I want to use an ajax loader while loading the page with transparent background.
Here's the background info first. ASP.NET 2.0 Web Site with AJAX Extensions 1.0. I
A little background: I use PowerShell on windows xp at work and I set
I have to design a form with an input inside it. I use background
background: trying to use the twitter gem for ruby-on-rails. in routes: map.resources :twitter_sessions map.finalize_twitter_sessions
Coming from a .NET background I'm use to reusing string variables for storage, so
I have a panel with transparent background which i use to draw an image.
(background: Why should I use int instead of a byte or short in C#
Background There are several different debug flags you can use with the Visual Studio

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.