I have this radio button in html
<input type="radio" name="group1" value="1"> Gray Scale<br>
</td>
</tr>
<tr><td align="left" valign="top" width="200">
<input type="radio" name="group1" value="2"> Old Style<br>
</td><td align="left" valign="top" width="200">
<input type="radio" name="group1" value="3"> Sharpening<br></td></tr>
but I using this Struts code will give me all over the place with no size and anything <s:radio name="option" list="#{'1':'Gray Scale', '2':'Old Style','3':'Sharpening'}" value="1" />
How can I have this radio button for struts 2s individually?
If you want to <s:radio> tag to render exactly as you want, you have to modify the Struts2 theme that you are using.
Here you have an example from a guy that solves a similar problem: Struts 2 How To Customize The Theme That Controls How A Struts 2 Tag Is Displayed In The Browser
Just to make it more clear what already have been described in good way by Pigueiras,Struts2 uses theme concept to render the HTML for the Struts2 based tags and internally it uses freemarker tempelates to generate HTML for you.
out of the box S2 comes with following three themes
xhtml
css_xhtml theme
simple
ajax (with deprecated DOJO tags)
By default S2 uses xhtml theme to render the HTML and under this theme it will generate certain tables to render the view.
it provides a way to customize the theme or you can define your own theme and can control the way HTML is being generated by the S2.
have a look at following doc for more details
struts-2-themes
themes-and-templates
creating_a_theme
Related
I want to post checkbox values to server using html. But my code retrieves nothing. Please help.
<form action="Default2.aspx" method="post" >
<input type="checkbox" name="attempt" value="101"> I'st attempt<br>
<input type="checkbox" name="attempt" value="102" checked> 2nd attempt<br>
<input type="submit" value="Submit">
</form>
They need ID's so they can be referred to and if this is a Web Forms website you need to also have the attribute runat="server" for both of them otherwise you won't be able to access them.
ASP.NET Page already has form element in the root, and you don't have insert it by self. If you use native HTML element in your ASP.NET page or control, you can get their values by using Request Object. See simple example here How-get-input-text-value-server-side-c.aspx
In plain HTML forms, checkbox input controls don't get included in the submission at all if the user left them unchecked. See this question: Does <input type="checkbox" /> only post data if it's checked?
I am developing a Web page on struts2 If I am correct theme in Struts2 is set such that all the tags will eventually be inside a table so all tags will be aligned one below other.
In My web page i have login page with Submit and Reset button I want both side by side (next each other) rather than in separate line.I Tried googling i got some answer like { display : inline; } in CSS and also { position : float} and theme="simple" in form. Nothing worked
<table><tr><td><s:submit method="CheckUser" value="Login" align="center" /></td><td><s:reset value="Clear" align="center" /></td></tr>
In case if i set i get the 2 buttons(submit+reset) as required
but though label="User Id" is given i get only text field without label
<tr><td><s:textfield name="userid" label="User Id" size="25" /></td></tr>
<tr><td><s:password name="password" label="Password" size="25" /></td></tr>
Please do suggest me where I am going wrong and how to get both label to text field and also submit_Reset button side by side
Just leave default Struts2 theme, which is xhtml by the way, as it is and change only your <s:submit> and <s:reset> tags adding to them theme attribute with value simple.
<s:form>
...
<tr>
<td colspan="2">
<s:submit value="Login" theme="simple"/>
<s:reset value="Clear" theme="simple"/>
</td>
</tr>
</s:form>
In struts.xml set the theme to simple
<struts>
...
<constant name="struts.ui.theme" value="simple" />
...
<struts>
Now things will work as you expect.
The theme can also be scoped in other ways if you don't want the simple to to be default (page and per tag are common) see here: http://struts.apache.org/2.3.8/docs/selecting-themes.html
Is there any way is XSL to align the following element to the right of the page after page generation and XSLT?
<RadioButton>
<Name>myRadio</Name>
</RadioButton>
Where RadioButton is a template defined as <input radio...etc>
once the page is generated you will need to do cosmetic alignments using cascading style sheets or something.
so in your xsl you might have template to make it like
<input type="radio" name="blah" class="moo" value="blah" />
and in .css have
.moo{
float:right;
}
or you can use an inline style like
<input type="radio" name="blah" style="float:left;" value="blah" />
Hello,
I am wondering if it is possible to change the wicket output html code. e.g. for the component "CheckBoxMultipleChoice" you will get the following html output.
<span wicket:id="letters">
<input name="letters" type="checkbox" value="0" id="letters_0"/><label for="letters_0">fff</label><br/>
<input name="letters" type="checkbox" value="1" id="letters_1"/><label for="letters_1">aaa</label><br/>
<input name="letters" type="checkbox" value="2" id="letters_2"/><label for="letters_2">bbb</label><br/>
<input name="letters" type="checkbox" value="3" id="letters_3"/><label for="letters_3">ccc</label><br/>
<input name="letters" type="checkbox" value="4" id="letters_4"/><label for="letters_4">ddd</label><br/>
</span>
if i dont want the <br/> tag, what can i do?
regards
It depends on the component.
For anything Panel-based, you can always subclass the component (MyPanel.java) and supply a different markup file (MyPanel.html). As long as you have the same wicket:ids in there, it works fine.
For built-in Wicket components that have markup elements embedded in their source code, like CheckBoxMultipleChoice, you're at the mercy of the custom API of the component. In your case it looks like you want CheckBoxMultipleChoice#setSuffix.
No, extract from the documentation
Components may alter their referring tag, replace the tag's body or insert markup after the tag. But components cannot remove tags from the markup stream. This is an important guarantee because graphic designers may be setting attributes on component tags that affect visual presentation.
however if you want add/remove new line spaces between your components you can change the display of component to block/inline
#Override
protected void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);
//block or inline
tag.put("style", "display:block");
}
or use a CSS class
I know by reading the W3C documentation for HTML4.01 and HTML5 that the "name" attribute originally existed as a property of the <a> tag to permit people to link to an anchor point within a document.
However, now that all major browser vendors allow linking to any HTML element within a document via the "id" attribute, is there still any real use for the "name" attribute? If so, how should I be using the "name" attribute?
One thing that comes to mind are radio buttons: you have to use name to specify which ones are part of the same group.
<form>
<input type="radio" name="sex" value="male" /> Male<br />
<input type="radio" name="sex" value="female" /> Female
</form>
The name attribute is required, I think, on input elements (and their friends)...
<input type="text" name="email" value="" />
Good question... As mentioned in other answers one obvious use is for radio buttons so that only one radio button can be selected at a time, as you can see in jQuery radio buttons - choose only one?
Along with this, in ASP.Net MVC I have found another use of the name attribute. Refer
MVC which submit button has been pressed
<input name="submit" type="submit" id="submit" value="Save" />
<input name="submit" type="submit" id="process" value="Process" />
From http://www.w3schools.com/tags/att_button_name.asp
The name attribute specifies the name for a element.
The name attribute is used to reference form-data after the form has been submitted, or to reference the element in a JavaScript.
Tip: Several elements can share the same name. This allows you to have several buttons with equal names, which can submit different values when used in a form.
Other References
HTML5 How To Skip Navigation When Name Attribute Is Obsolete
HTML5 Obsolete features
HTML input - name vs. id