简体   繁体   中英

Mixing HTML and STRUTS2 tags

I have a form which has both HMTL tags and struts tags. I use the HTML tags because of alignment issues with struts tags.

<s:form action = "setNode" name = "processing" method ="POST">



      <script>
      <!--
      createTree(catArray);

      </script>
      <br/>
      <s:radio name="processOption" label="" list="{'Add','Move','Delete'}" ></s:radio>

      <s:textfield name="node" ></s:textfield>

      <s:submit name="Go" value="              Go                " align="center" />
      </s:form>

the createTree function creates a tree form with HTML checkbox input types.

The action triggers a java function. How do i see which checkboxes are checked?

Bad approach, I'd say.

First, have you taken a look at the generated html? (generated by struts, at least - if possible also generated by you javascript). It's the first thing to do, always. Can you post it ?

Second, are you aware of "themes" in struts2 forms ? If you are using the default ("xhtml"), the form will be inside a table, and, if you are going to add some non-struts2 elements inside, you must be aware of that - for example, your <br/> tag seems out of place.

Third, Struts2 tags are always mixed with html tags, that their point. I guess you mean you are mixing input html tags (form elements) generated in javascript with others generated by the struts2 tags. In general, this is messy, you should try to avoid this. Even more when your tags are generated by a black-box javascript function as yours (with document.write() I guess). You should try (except very special scenarios) to generate those checkboxes with struts2.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM