• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dropdown event to display data in text

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good afternoon everyone,
Here goes:

To start I've got a a DAO class that pumps the results from a a PROC into a list. The results include manufacturer data: mfgLongName, mfgShortName, Entity and Status.

When I fire off my action, I call the DAO class to return the List and then I put the List into scope:


*********************************************************
public class MfrAdminToolAction extends BaseAction{

public ActionForward doPerform(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception
{
MfrAdminToolDDInfo mfrInfo = new MfrAdminToolDDInfo();
mfrInfo.setServletContext(getServlet().getServletContext());

try {
request.setAttribute(IWSConstants.MFR_MANU_LIST, getMFRforDropdown(mfrInfo));

} catch (Exception ex)
{
WSUtils.getSystemLogger().error("", ex);
}

return mapping.findForward("success");

}

public List getMFRforDropdown(MfrAdminToolDDInfo mfrInfo) throws NullParameterError, BlankParameterError, ServiceFailure
{
MfrAdminToolDAOSQLServer daoSQLServer = new MfrAdminToolDAOSQLServer();
List searchResults = daoSQLServer.getMFRforDropdown(mfrInfo);

return searchResults;
}
}

**************************************************************

I now populate my dropdown with a var from my scope object in JSP.


**************************************************************
<td>
<c:if test="${empty requestScope.mfrManuList}" >
<div style="text-align: left">
<fmt:message key="prompt.eps.noresultstodisplay"/>
</div>
</c:if>
<html:select property="<%=IWSPageDefs.MFG_LONG_NAME %>">
<html:options collection="<%=IWSConstants.MFR_MANU_LIST %>" property="<%=IWSPageDefs.MFG_LONG_NAME %>" labelProperty="<%=IWSPageDefs.MFG_LONG_NAME %>"/>
</html:select>
</td>
*************************************************************

My question is how do I pull the record data from my scope object associated to the MFG_LONG_NAME selected from from the dropdown. Also, do I use the onchange event for the dropdown to fire off some javascript to do this? I want to display the related data in the following controls:

****************************************************************
<td valign="TOP">
<html:text property="<%=IWSPageDefs.ENTITY %>" size="32,1" maxlength="50"/>
</td>
<td>
<html:checkbox property="<%=IWSPageDefs.STATUS%>" value="yes" />  
</td>


*****************************************************************

Thanks in advance,
Chris G
 
Ranch Hand
Posts: 83
Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure if this is what you are looking for .... See the struts 2 Example Code which demonstrates population of a new list based on selection of one list. Basically you need to capture the events.

Hope this helps.... if you are using Struts 1.x then you also you may do it by some javascript call at onChange event.

Hope this helps...
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't forget that all JSP tags can do is format data to be displayed before it is sent to the browser. If you want to provide new data based on a value the user selects in the browser, you can't use JSP tags to do that.

If the list of manufacturers isn't very long (say under 100), you could do this by creating JavaScript arrays that contain the data you want to display and then use the onchange event of the dropdown to call a JavaScript function that would search the arrays based on the value selected by the user and then modify the contents of the page to display the values using DOM functions.

If the list is large, you would need to use AJAX techniques to retrieve the values from the server based on the value selected.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic