rss· 投稿· 设为首页· 加入收藏· 繁體版
当前位置: 火魔网 » 程序开发 » JavaEE

struts2常用标签

<s:actionerror/>
<s:actionmessage/>
<s:fielderror />

<s:form action="exampleSubmit" method="post" enctype="multipart/form-data" tooltipConfig="#{'jsTooltipEnabled':'true'}">
    <s:textfield
            label="姓名"
            name="stud.stuName"
            tooltip="Enter your Name here" />
   <s:radio
     list="#{'1':'男','0':'女'}"
     name="stud.stuSex" label="性别"
     listKey="key"             listValue="value"></s:radio>

    <s:datepicker
            tooltip="Select Your Birthday"
            label="Birthday"
            name="birthday" />

    <s:textarea
            tooltip="Enter your Biography"
            label="Biograph"
            name="bio"
            cols="20"
            rows="3"/>

    <s:select
       tooltip="Choose Your Favourite Color"
     list="#session.cls"
     listKey="id"
     listValue="cname"
     name="stud.cid"
     label="班级"
     emptyOption="true"
     headerKey="None"
     headerValue="None"/>
      <s:select list="#request.cs" listKey="id" listValue="cname"
    name="cid" emptyOption="false" headerKey="0" headerValue="--请选择--"></s:select>
 //单选按钮组
     <s:checkboxlist name="skills2"
                        label="Skills 2"
                        list="#{ 1:'Java', 2: '.Net', 3: 'RoR', 4: 'PHP' }"
                        listKey="key"
                        listValue="value"
                        value="{ 1, 2, 3 }"/>
    <s:checkboxlist
  list="#session.roleslist"
  listKey="roleid"
   listValue="rolename"
    name="roles" >
    <s:checkbox
            tooltip="Confirmed that your are Over 18"
            label="Age 18+"
            name="legalAge"/>

    <s:doubleselect
            tooltip="Choose Your State"
            label="State"
            name="region" list="{'North', 'South'}"
            value="'South'"
            doubleValue="'Florida'"
            doubleList="top == 'North' ? {'Oregon', 'Washington'} : {'Texas', 'Florida'}"
            doubleName="state"
            headerKey="-1"
            headerValue="请选择"
            emptyOption="true" />

    <s:doubleselect
            tooltip="Choose your Vehical"
            label="Favourite Vehical"
            name="favouriteVehicalType"
            list="vehicalTypeList"
            listKey="key"
            listValue="description"
            value="'MotorcycleKey'"
            doubleValue="'YamahaKey'"
            doubleList="vehicalSpecificList"
            doubleListKey="key"
            doubleListValue="description"
            doubleName="favouriteVehicalSpecific" headerKey="-1"
            headerValue="请选择"
            emptyOption="true" />

    <s:file
            tooltip="Upload Your Picture"
            label="Picture"
            name="picture" />
           
    <s:optiontransferselect
            tooltip="Select Your Favourite Cartoon Characters"
            label="Favourite Cartoons Characters"
            name="leftSideCartoonCharacters"
            leftTitle="Left Title"
            rightTitle="Right Title"
            list="{'Popeye', 'He-Man', 'Spiderman'}"
            multiple="true"
            headerKey="headerKey"
            headerValue="--- Please Select ---"
            emptyOption="true"
            doubleList="{'Superman', 'Mickey Mouse', 'Donald Duck'}"
            doubleName="rightSideCartoonCharacters"
            doubleHeaderKey="doubleHeaderKey"
            doubleHeaderValue="--- Please Select ---"
            doubleEmptyOption="true"
            doubleMultiple="true" />
   
    <s:textarea
            label="Your Thougths"
            name="thoughts"
            tooltip="Enter your thoughts here" />
           
    <s:submit onclick="alert('aaaa');" />
    <s:reset onclick="alert('bbbb');" />
</s:form>
   
</body>
</html>

――――――――――――多选标签―――――――――――――――――――
<head>
    <title>Struts 2 Cool Tags - Others</title>
    <s:head />
</head>
<body>   
    <h2>Others</h2>
    <s:form action="Store" >
        <s:datetimepicker name="birthday" label="Birthday" />
        <s:updownselect
            label = "Favourite Countries"
            list="#{'england':'England', 'america':'America', 'germany':'Germany'}"
            name="prioritisedFavouriteCountries"
            headerKey="-1"
            headerValue="--- Please Order Them Accordingly ---"
            emptyOption="true" />
        <s:optiontransferselect           
            label="Favourite Cartoons Characters"
            name="leftSideCartoonCharacters"
            leftTitle="Left Title"
            rightTitle="Right Title"
            list="{'Popeye', 'He-Man', 'Spiderman'}"
            multiple="true"
            headerKey="headerKey"
            headerValue="--- Please Select ---"
            emptyOption="true"
            doubleList="{'Superman', 'Mickey Mouse', 'Donald Duck'}"
            doubleName="rightSideCartoonCharacters"
            doubleHeaderKey="doubleHeaderKey"
            doubleHeaderValue="--- Please Select ---"
            doubleEmptyOption="true"
            doubleMultiple="true" />
    </s:form>
</body>

――――――――――――――树tree――――――――――――――――――――――
<head>
        <title>Struts 2 AJAX - Tree</title>
        <s:head theme="ajax" debug="true" />
        <script type="text/javascript">
            function treeNodeSelected(arg) {
                alert(arg.source.title + ' selected');
            }
            dojo.addOnLoad(function() {               
                var s = dojo.widget.byId('parentId').selector;               
                dojo.event.connect(s, 'select', 'treeNodeSelected');
            });
        </script>
    </head>
    <body>
        <h2>
            Tree
        </h2>
        <div style="float:left; margin-right: 50px;">
            <s:tree label="parent" id="parentId" theme="ajax"
                templateCssPath="/struts/tree.css" showRootGrid="true"
                showGrid="true">
                <s:treenode theme="ajax" label="child1" id="child1Id">
                    <s:treenode theme="ajax" label="grandchild1" id="grandchild1Id" />
                    <s:treenode theme="ajax" label="grandchild2" id="grandchild2Id" />
                    <s:treenode theme="ajax" label="grandchild3" id="grandchild3Id" />
                </s:treenode>
                <s:treenode theme="ajax" label="child2" id="child2Id" />
                <s:treenode theme="ajax" label="child3" id="child3Id" />
                <s:treenode theme="ajax" label="child4" id="child4Id" />
                <s:treenode theme="ajax" label="child5" id="child5Id">
                    <s:treenode theme="ajax" label="gChild1" id="gChild1Id" />
                    <s:treenode theme="ajax" label="gChild2" id="gChild2Id" />
                </s:treenode>
            </s:tree>
        </div>
    </body>
__----------------------------------------------
动态树
 <s:head theme="ajax" debug="true" />
     <script type="text/javascript">
       function treeNodeSelected(arg) {
            alert(arg.source.title + ' selected');
        }
         dojo.addOnLoad(function() {               
         var s = dojo.widget.byId('parentId').selector;               
         dojo.event.connect(s, 'select', 'treeNodeSelected');
        });
        </script>

<s:tree label="菜单" id="parentId" theme="ajax"  templateCssPath="/struts/tree.css" showRootGrid="true" showGrid="true">         
<s:iterator id="ml" value="#session.mululist">           <s:treenode theme="ajax" label="%{#ml.mkname}" id="%{#ml.code}" /></s:iterator>     </s:tree>  

顶一下
(0)
踩一下
(0)