You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by arterzatij <ar...@gmail.com> on 2012/09/08 01:57:22 UTC

AjaxFormLoop

Hi all,

  Now I'm getting some particular issue, when I submit the form from an
ajaxformloop I loose the information on the server side, all information I
provide turns to null values... 

I have next:

Java file:

	@Property
	@Persist
	private List<Expense> expenses;


@OnEvent(value = EventConstants.ADD_ROW, component = "relation")
	public Object onAddRowFromExpenses() {

		Expense _new = expensesService.addExpense(expensesRelation);
		expenses.add(_new);
		return _new;

	}

	@OnEvent(value = EventConstants.REMOVE_ROW, component = "relation")
	void onRemoveRowFromExpenses(Expense expenseToDelete) {
		
		expenses.remove(expenseToDelete);

	}


		return new ValueEncoder<Expense>() {

			@Override
			public Expense toValue(String clientValue) {

				return expensesService.getExpense(Long.parseLong(clientValue));
						
			}

			@Override
			public String toClient(Expense value) {
				return String.valueOf(value.getId());
			}

		};

	}

        public Object onSuccess() {

		expensesService.processExpenses(expenses, expensesRelation);
		
		manager.alert(Duration.TRANSIENT, Severity.INFO,
				messages.get("stored-relations"));
		
		expenses = null;
		
		return this;

	}

tml file:


<t:datefield t:id="date" value="expense.date" style="width: 7em;" />
<t:textfield t:id="bill" value="expense.bill" style="width: 7em;" />
<t:textfield t:id="amount" value="expense.amount"
			style="width: 7em;" />
<t:textfield t:id="company" value="expense.company"
			style="width: 7em;" />
<t:select t:id="terms" value="expense.terms" />
<t:textfield t:id="ot" value="expense.ot" style="width: 7em;" />
<t:removerowlink style="color: #E17009; width: 7em;">
		${message:removeExp}
</t:removerowlink>
<p:addRow>
 	
 <t:addRowLink style="color: #E17009;">
 ${message:addExp}
</t:addRowLink>

 </p:addRow>


Log information:

INFO http-thread-pool-8080(5) services.ExpensesService - ------ [Processing
expenses relation {}] ------
INFO http-thread-pool-8080(5) services.ExpensesService - ------ [Save
Expense [id=0, date=null, bill=null, amount=null, company=null, terms=null,
ot=null]] ------
INFO http-thread-pool-8080(5) services.ExpensesService - ------ [Delete
Expense [id=7, date=null, bill=null, amount=null, company=null, terms=null,
ot=null]] ------
INFO http-thread-pool-8080(5) services.ExpensesService - ------ [Update
Expense [id=8, date=null, bill=null, amount=null, company=null, terms=null,
ot=null]] ------
INFO http-thread-pool-8080(5) services.ExpensesService - ------ [Delete
Expense [id=9, date=null, bill=null, amount=null, company=null, terms=null,
ot=null]] ------



Thanks in advance!



--
View this message in context: http://tapestry.1045711.n5.nabble.com/AjaxFormLoop-tp5716130.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: AjaxFormLoop

Posted by arterzatij <ar...@gmail.com>.
Fixed thansk for all!

The problem was in the encoder object, I was requesting information to the
db instead of the object flashed on the page.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/AjaxFormLoop-tp5716130p5716205.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org