Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Subject: Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Subject: Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
best choice for this use case ... ?

best choice for this use case ... ?

2007-12-03       - By Giovanni Azua

 Back
Reply:     1     2  

hi,

I have the following use-case -I think should be pretty common- and
would like to
know what would be the best design choice:

- There is a form that contains an autocompleter field filled with all
stock indexes.
- In the same form there are other dependent input values displayed e.g.
exchange
 rate that correspond to the selected index.
- Initially the input action makes sure the  dependent fields are
correctly populated
 i.e. they match the initially selected index.

Now when the user changes the index selection, some of the form fields
must also be updated to be consistent with the new selection.

These are the two design choices I have found using ajax so far:

1-. Have the master field index publish a topic and have the dependent
fields listen
    to that topic and trigger the execution of an action. The problem I
encountered
    here is that:
        a) The request parameters e.g. historicBook0 are empty, don't
know how to
            push them to the action, I could use javascript directly to
encode it but not sure
            if this could lead to race conditions i.e. how will the
javascript ensure to execute
            before the topic publication triggers execution of the action.
        b) The widget autocompleter seem not to understand the result
of the action. I tried
             using the json plugin and having a getter of the action
match the widget name but
             does not work ...

Below find the not working sources with the problems described above.

2-. The second choice is using JSON RPC with javascript directly but
this approach
though viable seems rather frameworkless i.e. hacky to me.

My gut feeling is that solution #1 is the one but just don't know how to
solve those
issues.

TIA,
regards,
Giovanni

************** struts.xml *********************

<package name="remote"  extends="json-default">
   <action name="Remote*"
class="com.sag.optimizer.ui.web.action.remote.Remote{1}Action">
      <result type="json"/>          
   </action>      
</package>

************* mypage.jsp *********************

<%@ page contentType="text/html; charset=UTF-8 (See http://UTF-8.ora-code.com)"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>

<s:url var="exchangeRates" action="RemoteExchangeRates.action" />

<s:form id="formAngleAlgoConfSimulation" action="%{targetAction}"
method="post" theme="%{currentTheme}">
   <sx:autocompleter tooltip="Provide the first Historic Book"
valueNotifyTopics="/changedHistoricBook0" searchType="substring"
label="Historic Book 1" cssStyle="width: 250px;" dropdownHeight="180"
name="historicBook0" list="historicBooks" listKey="id" listValue="name"
/>      
   ...
   <sx:autocompleter tooltip="Provide the Currency Rate 1"
href="%{#exchangeRates}" autoComplete="false" preload="false"
listenTopics="/changedHistoricBook0" label="Currency Rate 1"
showDownArrow="false" cssStyle="width: 250px;" name="eurosPerListedUnit0" />
   ...
   <s:submit value="%{buttonLabel}" align="center"/>
</s:form>

*********** Action ***************************

/**
* Determines the exchange rates for a Historic book pair
*/
public
class RemoteExchangeRatesAction
extends ActionSupport
{
   
//-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
   // public
   
//-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
   /**
    * @(protected) the eurosPerListedUnit0
    */
   public final double
   getEurosPerListedUnit0()
   {
        return calculateFxRate(theHistoricBook0Key);
   }

   
//-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
   /**
    * @(protected) the eurosPerListedUnit1
    */
   public final double
   getEurosPerListedUnit1()
   {      
       return calculateFxRate(theHistoricBook1Key);
   }

   
//-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
   /**
    * @(protected) aHistoricBook0Key the historicBook0Key to set
    */
   public final void
   setHistoricBook0Key(String aHistoricBook0Key)
   {
       theHistoricBook0Key = aHistoricBook0Key;
   }

   
//-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
   /**
    * @(protected) aHistoricBook1Key the historicBook1Key to set
    */
   public final void
   setHistoricBook1Key(String aHistoricBook1Key)
   {
       theHistoricBook1Key = aHistoricBook1Key;
   }
     
   
//-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
   // members
   
//-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
   private String theHistoricBook0Key;
   private String theHistoricBook1Key;
}


-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)