tags:

views:

296

answers:

3

Hi at all...

I need some help about a little question. I make a pagination by db for my survey application. I divided my list of questions in six page. Before the pagination, when the user submit the vote, the action check a hashmap and return error on key where the resp is not present.

Now, with the pagination, I call the pages by with the param (number of page) on the request.

Is evident that now my hashmap of answers go to action null.

Now.. how can I send the partial list of answers (answers for page) without a submit ?

Hope I was clear...

p.s. I use Strut 2 Framework

A: 

Just let paging buttons submit the whole form as well. Let them do exactly the same action as your "submit" action and execute the actual paging action afterwards.

BalusC
Yes! But the problem is: can I make a submit button that call an action with parameters? My actual solution to call a specific page is : [code]<s:iterator value="numPages" status="s"> <a href="<s:url action="RenderSurvey" > <s:param name="numPage" value="#s.index+1"/> </s:url>">Pagina <s:label value="%{#s.index+1}"/> </a> </s:iterator>[/code]But the the hashmap is null.. I try the same with <s:submit>, but strange.. can't works! :)
Luigi 1982
A: 

You can send a parameter without a form like this:

  <s:url id="url" action="pageaction">
        <s:param name="page">2</s:param>
        <s:param name="resp">some_value</s:param>
    </s:url>
    <s:a href="%{url}">Next Page</s:a>
Vincent Ramdhanie
A: 

Just like the URL example:

<form method="post" action="actionName">
     <input type="hidden" name="somePageProperty" value="TEST_VALUE"/>
     <input type="submit" value="Next Page" />
</form>

If you have valid bean methods for somePageProperty (getSomePageProperty(), setSomePageProperty()) then the value will be autowired (automatically set). Struts2 will autowire input fields based on the name attribute. You can use the Struts2 property tag in the input value attribute as well, or call a method if you need to do some computation (i.e. getNextPageNumber() from the current Struts2 action).

Droo