Hi i have a problem with the multiple select box of struts2.
<s:select name="test" id="test" multiple="true" size="2" list="testlist" theme="simple" listKey="testkey" listValue="testvalue" />
The select box name "test" is a field name in my entity.The list data is displaying and i can select multiple items and its stored in the database.But the problem is i could not retain the selected values while modification.But i have noticed that i can retain the value if i select only one item.Any idea?.
you have to define attribute "value", check the example:
<s:select label="Pets"
name="petIds"
list="petDao.pets"
listKey="id"
listValue="name"
multiple="true"
size="3"
required="true"
value="%{petDao.pets.{id}}"
/>
Related
I have a JSP page and I use Struts to build my select tag. The JSP code is the following:
<s:select
required="true"
name="form.tipologia"
label="%{getText('Enum.label')}"
list="#it........Enum#values()"
listKey="name()"
listValue="getText('Enum.' + name())"
headerKey=""
headerValue="%{getText('Enum.')}"
/>
This code produces me a select field with my Enum constants.
What I want to do is to create the field with only a subset of the Enum.
How can I do it? Is it possible?
You can use OGNL projection for this.
<s:select list="#it..Enum#values().{? #this != #it..Enum#ENUM_TO_EXCLUDE}" />
This will create a subset of all enum values except that one that you want to exclude.
If comparing enums doesn't work then you can compare strings.
<s:select list="#it..Enum#values().{? #this.toString() != 'ENUM_TO_EXCLUDE'}" />
I am following the option suggested here to dynamically adding inputtext box in my PrimeFaces v3.5 application. The only problem I am facing is that the newly added inputtext are growing vertically. Screenshot is attached.
The <h:dataTable> generates a HTML <table> element wherein each iteration generates a <tr> element which represents naturally a new row.
If you don't want to generate a table at all, then you should not be using a <h:dataTable>, but e.g. <ui:repeat>.
<h:form>
<ui:repeat value="#{bean.items}" var="item">
<h:inputText value="#{item.value}" />
</ui:repeat>
<h:commandButton value="add" action="#{bean.add}" />
<h:commandButton value="submit" action="#{bean.submit}" />
</h:form>
This doesn't generate any markup and the HTML <input> elements will by default end up in a single line.
i have a jsp page where i am displaying data in strust2 jquery Grid.
In grid column there is search facility based on the Select type(Drop down select).
<sjg:gridColumn name="subjectId" title="Subject Name" editable="true" align="center" search="true" searchtype="select"
searchoptions="{dataUrl:'%{selecturl}'}" edittype="select" editoptions="{dataUrl:'%{selecturl}'}" />
.My dropdown list is coming fine from my Class as well as it is correctly displaying on its place.
What i want exactly is a header value something like this ( ----select here--) followed by all the values populated from my class.
eg. I know how to do this(below code) in struts2 but i don't know this in struts2 jquery grid column.Now i am only able to display all list without header key & header values.
<s:select label="What's your favor search engine"
headerKey="-1" headerValue="----Select here----"
list="selecturl"
name="name" />
Please help me regarding this issue.
I have this snippet of code below. I want to pass the value of the select availabilityChoice as a second parameter to my updateAvailability javascript method.
I've tried everything (including an optionKey). How do you do this?
<label>Select Contact Availability:</label><g:select name="availabilityChoice" from="${['Inactive', 'Active']}" value=""/>
<g:actionSubmit type="button" value="Update Availability" onclick="updateAvailability('contactList', availabilityKey.value);"/>
I should add that contactList is a list of check boxes that were selected. So I need to pass that list of selected checkboxes, the value of the select box, and update those selections with the value in the select box.
Set an ID for <select> by using id attribute, and then you can refer to that element in javascript.
<label>Select Contact Availability:</label>
<g:select id="mySelect" name="availabilityChoice" from="${['Inactive', 'Active']}" value=""/>
<g:actionSubmit type="button" value="Update Availability" onclick="updateAvailability('contactList', document.getElementById('mySelect').value);"/>
Why is it that when I insert an element in between the s:textfield it gets placed on top?
Is there a way to fix that?
Thanks for helping on this.
<s:textfield label="First Name" required="true"/>
<s:textfield label="Last Name" required="true"/>
<s:text name="testing1">test1</s:text>
<s:textfield label="Address" required="false"/>
<s:textfield label="Email" required="true"/>
<s:text name="testing2">test2</s:text>
Order being displayed on browser:
test1
test2
First Name
Last Name
Address
Email
I guess my answer to this question comes too late, but I respond to this just for the record.
The reason why the text elements don't appear in between is because struts renders a table to display your input fields (and their labels). If you look at the HTML rendered by struts you will see one tag for each textfield. If you insert any other component between these, struts will not know how to format these into the table of the form, resulting in the items being displayed before the start of the table.
To avoid this behavior you can set the "theme" attribute of the form to "simple". This will result in the fact that you will need to do all formatting by yourself.
Hope this helps.