Hi all, 

I can't seem to get a simple Ajax based look ahead search to work. I am
trying to use AjaxTags 1.3 (http://ajaxtags.sourceforge.net/) in my
Struts2 application. What is the correct response to return? I am also
using Tiles2.

If I write the response directly to the output stream, that's what
displays in my browser (obviously it's the response from the server) --
if I return the result, Struts complains that the mapping is not
correct. 

Here's what I have:

My form looks like this:

<form>
  Search Question Text: <input id="questionText" name="questionText"
type="text" size="30" class="form-autocomplete" />
</form>

<ajax:autocomplete
  baseUrl="${pageContext.request.contextPath}/question/get-term.action"
  source="questionText"
  target="questionText"
  parameters="qt={questionText}"
  className="autocomplete"
  indicator="throbbing"
  minimumCharacters="1" />
 
My Action looks like this:

public class QuestionAction extends BaseAction implements
ModelDriven<Question>, Preparable, ServletRequestAware,
ServletResponseAware {

        ...     

        public String getSearchTerm() throws Exception{

                System.out.println("**** Question Search Term:" + qt);
                List<Question> results=
questionService.getQuestions(qt);
                AjaxXmlBuilder builder= new AjaxXmlBuilder();
                builder.addItems(results, "questionType", "text");
                System.out.println("**** Question Search Result:" +
builder.toString());
                
                 response.setContentType("text/xml");
                 response.setHeader("Cache-Control", "no-cache");
                 ServletOutputStream out = response.getOutputStream();
                 out.print(builder.toString());
                 out.close();
                
                return SUCCESS;
        }


My struts mapping:

        <package name="question" extends="base-pkg"
namespace="/question">
                <action name="get-term" method="getSearchTerm"
class="...QuestionAction">
                        <result name="success"
type="tiles">question.panel</result>
                </action>
        </package>

The struts 2 Ajax documentation seems manic and dated. It seems the S2
Ajax implementation is tied closely to sitemesh, which I am not using.

If anyone can help me get this going I would definitely be interested in
participating in the project updating the documentation. 

Michael Griffith
Application Architect (Consultant)
Office of the Chief Information Officer
Office of the Commissioner
U.S. Food and Drug Administration
5600 Fishers Lane
Rockville, MD 20857
301.827.2381
507.581.6606 (cell) 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to