I am making some progress. I my AjaxBasic.tml file I have a <script> section
which has

var url = "ajaxbasic/" + encodeURIComponent(idField.value);

This idField gets from
<input type="text" id="userid" name="id" onkeyup="validate();"/>

In my AjaxBasic.java I have
public class AjaxBasic {

    private HttpServletRequest request;
    private HttpServletResponse response;

    @Inject
    private RequestGlobals _requestGlobals;

    private HashMap<String, String> users = new HashMap<String, String>();

    void pageLoaded() {
        System.out.println("AjaxBasic PageLoaded");
        users.put("greg", "account data");
        users.put("duke", "account data");
    }

    void onActivate(String id) throws IOException {
        request = _requestGlobals.getHTTPServletRequest();
        response = _requestGlobals.getHTTPServletResponse();
        System.out.println("AjaxBasic onActivate");
        System.out.println("id: " + id);
        if ((id != null) && users.containsKey(id.trim())) {
            response.setContentType("text/xml");
            response.setHeader("Cache-Control", "no-cache");
            response.getWriter().write("<message>valid</message>");
        } else {
            response.setContentType("text/xml");
            response.setHeader("Cache-Control", "no-cache");
            response.getWriter().write("<message>invalid</message>");
        }
    }
}

The problem is, that the response is not only the <message>valid</message>
or <message>invalid</message>

but the whole page's html is appended. How to prevent that?

Thanks,
Borut



2007/10/3, Thiago H. de Paula Figueiredo <[EMAIL PROTECTED]>:
>
> Em Wed, 03 Oct 2007 15:59:57 -0300, Borut Bolčina
> <[EMAIL PROTECTED]> escreveu:
>
> > Hello,
> > How should a url look like to be T5-ish in this javascript function:
>
> What about . . .
>
> > function validate() {
> >    var idField = document.getElementById("userid");
> >    var url = "validate/111=" + encodeURIComponent(idField.value);
>                          ^^^^
>
> This way, we could use the activation context and make it very T5-ish. :)
>
> Thiago
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to