[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

5.2

Struts 2 s:select tag list property populate

Asked by majkic in Jakarta Struts

Tags: struts, select, 2, tag

I have problem with populating select values using Struts 2. It is simple sample application that I am writing with purpose to learn Struts 2. Notice part:
<s:select label="Select owner" name="owners" headerKey="-1" headerValue="-- Please Select --" list="persons" listValue="firstName" listKey="id" emptyOption="true" />
I have list persons (java.util.List<Person>) in mystuff.action.PersonAction.

This doesn't work, causing error about list location. Exact question:

How to bind any list (in s:select tag) with some list in some class. I would appriciate some example please.

Here is part of code that I use:

<%@ taglib prefix="s" uri="/struts-tags"%>
<%@page import="mystuff.action.PersonAction"%>
<%@page import="mystuff.service.PersonServiceImpl"%>
<html>
      <head>
            <s:head theme="ajax" debug="true"/>
            <script type="text/javascript">
                  dojo.event.topic.subscribe("/savePerson", function(data, type, request) {
                      if(type == "load") {
                              dojo.byId("personId").value = "";
                              dojo.byId("firstName").value = "";
                              dojo.byId("lastName").value = "";
                              dojo.byId("email").value = "";
                        }
                  });
                  
                  dojo.event.topic.subscribe("/editPerson", function(data, type, request) {
                      if(type == "before") {
                              var id = data.split("_")[1];

                              var tr = dojo.byId("personRow_"+id);
                              var tds = tr.getElementsByTagName("td");

                              dojo.byId("personId").value = id;
                              dojo.byId("firstName").value = dojo.string.trim(dojo.dom.textContent(tds[0]));
                              dojo.byId("lastName").value = dojo.string.trim(dojo.dom.textContent(tds[1]));
                              dojo.byId("email").value = dojo.string.trim(dojo.dom.textContent(tds[2]));
                        }
                  });
                  
                  dojo.event.topic.subscribe("/saveBook", function(data, type, request) {
                      
                      if(type == "load") {
                            dojo.byId("bookId").value = "";
                              dojo.byId("title").value = "";
                              dojo.byId("author").value = "";
                              dojo.byId("pagesNo").value = "";
                        }
                  });
                  
                  dojo.event.topic.subscribe("/editBook", function(data, type, request) {
                      
                      if(type == "before") {
                              var id = data.split("_")[1];

                              var tr = dojo.byId("bookRow_"+id);
                              var tds1 = tr.getElementsByTagName("td");

                              dojo.byId("bookId").value = id;
                              dojo.byId("title").value = dojo.string.trim(dojo.dom.textContent(tds1[0]));
                              dojo.byId("author").value = dojo.string.trim(dojo.dom.textContent(tds1[1]));
                              dojo.byId("pagesNo").value = dojo.string.trim(dojo.dom.textContent(tds1[2]));
                        }
                  });
                  
            </script>
      </head>
      <body>
            <s:url action="listPerson" id="descrsUrl"/>
          <s:url action="listBook" id="descrsUrlBook"/>
          <s:url action="selectTag" id="descrsUrlTag"/>
          <table border="1" cellspacing="3">
            <tr>
                  <td>
                        <!-- First tag only define link for refresh and signal that will be sent when link is followed -->
                    <div style="text-align: right;">
                            <s:a theme="ajax" notifyTopics="/refreshPerson">Refresh</s:a>
                      </div>
                      <!-- This link defines ajax div that will be loaded on the page load and every time that listen topic signal is received
                            href is referenced by earlier defined descrsUrl=listenPerson. Action listenPerson is defined in struts.xml, as well as its result
                      -->
                      <s:div id="persons" theme="ajax" href="%{descrsUrl}" loadingText="Loading..." listenTopics="/refreshPerson"/>
              </td>
              <td>
                    <div style="text-align: right;">
                            <s:a theme="ajax" notifyTopics="/refreshBook">Refresh</s:a>
                      </div>
                      <s:div id="books" theme="ajax" href="%{descrsUrlBook}" loadingText="Loading..." listenTopics="/refreshBook"/>
              </td>
              
        </tr>

            <tr>
                  <td>
                        <p>Person Data</p>
                        <s:form action="savePerson" validate="true">
                            <s:textfield id="personId" name="person.id" cssStyle="display:none"/>
                              <s:textfield id="firstName" label="First Name" name="person.firstName"/>
                              <s:textfield id="lastName" label="Last Name" name="person.lastName"/>
                              <s:textfield id="email" label="E-mail" name="person.email"/>
                              <s:submit theme="ajax" targets="persons" notifyTopics="/savePerson"/>
                        </s:form>
                  </td>
                  <td>
                        <p>Book Data</p>
                        <s:form action="saveBook" validate="true">
                            <s:textfield id="bookId" name="book.id" cssStyle="display:none"/>
                              <s:textfield id="title" label="Book Title" name="book.title"/>
                              <s:textfield id="author" label="Book Author" name="book.author"/>
                              <s:textfield id="pagesNo" label="Book pages no" name="book.pagesNo"/>
                              <s:submit theme="ajax" targets="books" notifyTopics="/saveBook"/>
                              
                              <s:select label="Select owner" name="owners" headerKey="-1" headerValue="-- Please Select --" list="persons" listValue="firstName" listKey="id" emptyOption="true" />
                              
                        </s:form>
                  </td>
                  
            </tr>
            </table>
      </body>
</html>
 
Loading Advertisement...
 
[+][-]08/29/07 10:18 PM, ID: 19797618Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/29/07 11:17 PM, ID: 19797812Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/30/07 12:22 AM, ID: 19798034Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/30/07 12:39 AM, ID: 19798097Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/30/07 01:07 AM, ID: 19798188Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/30/07 02:13 AM, ID: 19798476Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/30/07 02:50 AM, ID: 19798627Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/30/07 02:57 AM, ID: 19798661Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/30/07 03:15 AM, ID: 19798725Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/30/07 03:21 AM, ID: 19798743Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/30/07 11:20 PM, ID: 19806286Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/04/07 05:11 AM, ID: 19824570Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Jakarta Struts
Tags: struts, select, 2, tag
Sign Up Now!
Solution Provided By: majkic
Participating Experts: 1
Solution Grade: B
 
[+][-]09/07/07 03:17 AM, ID: 19846488Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]09/11/07 03:56 AM, ID: 19867405Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]09/11/07 03:56 AM, ID: 19867406Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89 / EE_QW_1_20070628