0
<s:form action="download1" name="regform" id="formSelectOne"  theme="simple">
    <td  valign="top" align="right" >
        <s:submit value="View coc1  " theme="simple" />
    </td>
</s:form>

<s:form action="download2" name="regform" id="formSelectOne"  theme="simple">
    <td  valign="top" align="center">   
         <s:submit value="View doc2" theme="simple" />
    </td>  
</s:form>

The buttons are shown side by side, but I need to display the first on the right and the second on the center. How to do that?

Roman C
  • 49,761
  • 33
  • 66
  • 176
user3359305
  • 11
  • 1
  • 1
  • 1
    Please take your time to describe better the question you are asking. Your code was messy, your description even worse. And I'm still not sure if my edit is respecting what you are actually asking (that was tagged only struts2, while struts2 fits very little, only for the theme part). And BTW, why on earth do you put your first button as first if you want it on the right ? (unless your site is RTL) – Andrea Ligios Mar 04 '14 at 09:38
  • Why dont you put forms inside the cells(`td`)? – Anupam Mar 04 '14 at 09:49
  • Why not to use links instead of empty forms with submit? – Aleksandr M Mar 04 '14 at 10:34

2 Answers2

1

It's not necessary to have two forms on the page to submit different actions (methods).

Since the beginning, Struts has a technique to dispatch submit buttons to different actions. In the latest version it's performed via the submit tag, that is used to build the action URL from the attributes such as action or method.

As you are using a simple theme on the form tag, it's inherited to all input fields. It's not necessary to apply the same theme individually.

If you are using a table HTML tag to design your form elements it's substantial to put these buttons inside the same record tr tag having white-space:nowrap; CSS style. For example

<s:form  name="regform" id="regform" theme="simple">
<table style="width:100%;" cellspacing="0" cellpadding="0" border="0">
  <tr style="white-space:nowrap;">
    <td style="width:50%;" valign="top" align="right" >
        <s:submit action="download2" value="View coc2"/>
    </td>
    <td style="width:50%;" valign="top" align="right" >
        <s:submit action="download1" value="View coc1"/>
    </td>
  </tr>
<table>
</s:form>

To have the action attribute being worked see this answer to learn how to enable an action prefix in struts.xml to be able to use action attribute of the s:submit tag.

Roman C
  • 49,761
  • 33
  • 66
  • 176
0

Add the style attribute in both forms.
because when you start a form tag it usually breaks the line and start from new line.
so adding the below attribute will help you..

style="float:left;"
Jason C
  • 38,729
  • 14
  • 126
  • 182
Prakash
  • 693
  • 5
  • 17