You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by George Christman <gc...@cardaddy.com> on 2012/05/21 17:11:55 UTC

Pass component parameter back to method - Exception

Hello, I'm trying to pass back a component id to a backend method as Thiago
suggested in another post, however it's resulting in the following exception
before the method is even called. I have a work around passing back the id
as a String which works without any issues providing the field id's are
static. However it breaks if your using add row or any other dynamically
generated id's.  

java.lang.RuntimeException
Error parsing property expression
'getFieldValidatorTest(component:shiptoContactName)': line 1:21 no viable
alternative at input '('.
java.lang.RuntimeException
line 1:21 no viable alternative at input '('

The code I'm using is as followed. 

<t:TextField t:id="shiptoContactName" value="pr.shiptoContactName"
t:validate="prop:getFieldValidator(component:shiptoContactName)"/>


public FieldValidator getFieldValidatorTest(Field field) {
     return null;
}

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Pass-component-parameter-back-to-method-Exception-tp5712975.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: Pass component parameter back to method - Exception

Posted by George Christman <gc...@cardaddy.com>.
Sorry, my I posted the wrong backend method in my question. 

public FieldValidator getFieldValidator(Field field) {
     return null;
} 

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Pass-component-parameter-back-to-method-Exception-tp5712975p5712977.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: Pass component parameter back to method - Exception

Posted by George Christman <gc...@cardaddy.com>.
Nevermind, Resolved this with field.getControlName rather than
field.getClientId. 

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Pass-component-parameter-back-to-method-Exception-tp5712975p5713007.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: Pass component parameter back to method - Exception

Posted by George Christman <gc...@cardaddy.com>.
I managed to get the page to render without issue. At render it calls my
FieldValidator method and I can see the field.clientId(). However onSubmit,
the field.getClientId() becomes null. Any ideas? 

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Pass-component-parameter-back-to-method-Exception-tp5712975p5713005.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: Pass component parameter back to method - Exception

Posted by George Christman <gc...@cardaddy.com>.
Thanks Rebert for the explanation. Wasn't quite the answer I was hoping for
since I was trying to keep the backend clean, but looks as if this is the
only way to get this working dynamically. Once again, thanks. 

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Pass-component-parameter-back-to-method-Exception-tp5712975p5713000.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: Pass component parameter back to method - Exception

Posted by Robert Zeigler <ro...@roxanemy.com>.
Hi George,

The problem is with the "component:shiptoContactName" piece of the expression.
Specifying the property prefix (eg: prop:, component:, validate:, etc.) only
works at the beginning of the expression, and it is applied to the entire expression.

The thing to do in this case is:

.tml:

<t:textfield ... t:validate="prop:getFieldValidator(shipttoContactName)"/>

.java:

@InjectComponent
@Property
private TextField shiptoContactName;


Now you've injected the component into the page class and made it a property of the class, so you can reference it directly in the property expression.

Cheers,

Robert

On May 21, 2012, at 5/2110:11 AM , George Christman wrote:

> Hello, I'm trying to pass back a component id to a backend method as Thiago
> suggested in another post, however it's resulting in the following exception
> before the method is even called. I have a work around passing back the id
> as a String which works without any issues providing the field id's are
> static. However it breaks if your using add row or any other dynamically
> generated id's.  
> 
> java.lang.RuntimeException
> Error parsing property expression
> 'getFieldValidatorTest(component:shiptoContactName)': line 1:21 no viable
> alternative at input '('.
> java.lang.RuntimeException
> line 1:21 no viable alternative at input '('
> 
> The code I'm using is as followed. 
> 
> <t:TextField t:id="shiptoContactName" value="pr.shiptoContactName"
> t:validate="prop:getFieldValidator(component:shiptoContactName)"/>
> 
> 
> public FieldValidator getFieldValidatorTest(Field field) {
>     return null;
> }
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Pass-component-parameter-back-to-method-Exception-tp5712975.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
> 


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