users@glassfish.java.net

RE: Form Solution - Java or JavaScript

From: Martin Gainty <mgainty_at_hotmail.com>
Date: Fri, 16 Apr 2010 16:08:05 -0400

struts has a nice compact solution

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
    <title>UI Tags Example</title>
    <sx:head/>
</head>

<body>

<s:actionerror/>
<s:actionmessage/>
<s:fielderror />
<s:form action="exampleSubmit" enctype="multipart/form-data" javascriptTooltip="true">
    <s:checkboxlist
            tooltip="Choose your Friends"
            label="Friends"
            list="{'Patrick', 'Joe', 'Barack', 'John','Jim','Mark'}"
            name="friends"/>
</s:form>

you'll want to load the into WEB-INF/lib for org.apache.struts2.views.jsp.ui.CheckboxListTag
which is located in struts2-core-2.1.8.jar

you'll also want to append the checkBoxList descriptor into your tld e.g.
  <tag>
    <description><![CDATA[Render a list of checkboxes]]></description>
    <name>checkboxlist</name>
    <tag-class>org.apache.struts2.views.jsp.ui.CheckboxListTag</tag-class>
    <body-content>JSP</body-content>
    <attribute>
      <description><![CDATA[Set the html accesskey attribute on rendered html element]]></description>
      <name>accesskey</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[The css class to use for element]]></description>
      <name>cssClass</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[The css error class to use for element]]></description>
      <name>cssErrorClass</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[The css error style definitions for element to use]]></description>
      <name>cssErrorStyle</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[The css style definitions for element to use]]></description>
      <name>cssStyle</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Set the html disabled attribute on rendered html element]]></description>
      <name>disabled</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[HTML id attribute]]></description>
      <name>id</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Use JavaScript to generate tooltips]]></description>
      <name>javascriptTooltip</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Set the key (name, value, label) for this particular component]]></description>
      <name>key</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Label expression used for rendering an element specific label]]></description>
      <name>label</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[String that will be appended to the label]]></description>
      <name>labelSeparator</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Define label position of form element (top/left)]]></description>
      <name>labelposition</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Iterable source to populate from. If the list is a Map (key, value), the Map key will become the option 'value' parameter and the Map value will become the option body.]]></description>
      <name>list</name>
      <required>true</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[ Property of list objects to get field value from]]></description>
      <name>listKey</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Property of list objects to get field content from]]></description>
      <name>listValue</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[The name to set for element]]></description>
      <name>name</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[ Set the html onblur attribute on rendered html element]]></description>
      <name>onblur</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Set the html onchange attribute on rendered html element]]></description>
      <name>onchange</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Set the html onclick attribute on rendered html element]]></description>
      <name>onclick</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Set the html ondblclick attribute on rendered html element]]></description>
      <name>ondblclick</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Set the html onfocus attribute on rendered html element]]></description>
      <name>onfocus</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Set the html onkeydown attribute on rendered html element]]></description>
      <name>onkeydown</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Set the html onkeypress attribute on rendered html element]]></description>
      <name>onkeypress</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Set the html onkeyup attribute on rendered html element]]></description>
      <name>onkeyup</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Set the html onmousedown attribute on rendered html element]]></description>
      <name>onmousedown</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Set the html onmousemove attribute on rendered html element]]></description>
      <name>onmousemove</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Set the html onmouseout attribute on rendered html element]]></description>
      <name>onmouseout</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Set the html onmouseover attribute on rendered html element]]></description>
      <name>onmouseover</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Set the html onmouseup attribute on rendered html element]]></description>
      <name>onmouseup</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Set the html onselect attribute on rendered html element]]></description>
      <name>onselect</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[If set to true, the rendered element will indicate that input is required]]></description>
      <name>required</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Define required position of required form element (left|right)]]></description>
      <name>requiredposition</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Set the html tabindex attribute on rendered html element]]></description>
      <name>tabindex</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[The template (other than default) to use for rendering the element]]></description>
      <name>template</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[The template directory.]]></description>
      <name>templateDir</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[The theme (other than default) to use for rendering the element]]></description>
      <name>theme</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Set the html title attribute on rendered html element]]></description>
      <name>title</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Set the tooltip of this particular component]]></description>
      <name>tooltip</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Deprecated. Use individual tooltip configuration attributes instead.]]></description>
      <name>tooltipConfig</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[CSS class applied to JavaScrip tooltips]]></description>
      <name>tooltipCssClass</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Delay in milliseconds, before showing JavaScript tooltips ]]></description>
      <name>tooltipDelay</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Icon path used for image that will have the tooltip]]></description>
      <name>tooltipIconPath</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <attribute>
      <description><![CDATA[Preset the value of input element.]]></description>
      <name>value</name>
      <required>false</required>
      <rtexprvalue>false</rtexprvalue>
    </attribute>
    <dynamic-attributes>false</dynamic-attributes>
  </tag>

HTH
Martin
______________________________________________
Verzicht und Vertraulichkeitanmerkung
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.






> Date: Fri, 16 Apr 2010 06:31:10 -0700
> From: glassfish_at_javadesktop.org
> To: users_at_glassfish.dev.java.net
> Subject: Form Solution - Java or JavaScript
>
> Hello,
>
> My problem at hand is that I need to make
> a combobox in .jsp file and I would very much like to know when
> someone chooses another option in the box.
>
> So, my question is, can I listen events from the combobox with Java somehow (how?)
> or is JavaScript my only chance?
>
> Would be great if someone could point me in the right direction.
>
> Thanks.
> [Message sent by forum member 'urmas']
>
> http://forums.java.net/jive/thread.jspa?messageID=397386
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
                                               
_________________________________________________________________
The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5