You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by meduolis <me...@gmail.com> on 2013/10/26 11:41:10 UTC

Elegant way to modify parent component tag if child has errors

Hello, I want to *modify parent tag* class attribute if it's *child has
validation errors*.

Let's say I have structure like this:

Java code:

Markup:


To *achieve* my *goal* I do:


Is there any *more elegant way* to do this? 

P.S. *ValidationMessageBehavior* adds span with error message to response
after render.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Elegant-way-to-modify-parent-component-tag-if-child-has-errors-tp4661983.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Elegant way to modify parent component tag if child has errors

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
There is a renderHead on behavior: you can use it to contribute JavaScript.
Sooner than later, if you want to have complex user interaction at client
side, you will end up using extra JavaScript features. There are many
examples out there of JavaScript integration with Wicket


On Sat, Oct 26, 2013 at 12:14 PM, meduolis <me...@gmail.com> wrote:

> When/how should I trigger JS to update attribute? I have never used pure JS
> in my Wicket applications. I always try to use Wicket components/behaviors.
>
> Also, to avoid problem you mentioned about path to child I can pass it as a
> parameter which would be static field for both child component and behavior
> parameter:
>
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Elegant-way-to-modify-parent-component-tag-if-child-has-errors-tp4661983p4661985.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Regards - Ernesto Reinaldo Barreiro

Re: Elegant way to modify parent component tag if child has errors

Posted by meduolis <me...@gmail.com>.
When/how should I trigger JS to update attribute? I have never used pure JS
in my Wicket applications. I always try to use Wicket components/behaviors.

Also, to avoid problem you mentioned about path to child I can pass it as a
parameter which would be static field for both child component and behavior
parameter:




--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Elegant-way-to-modify-parent-component-tag-if-child-has-errors-tp4661983p4661985.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Elegant way to modify parent component tag if child has errors

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
I would do this with JavaScritpt

<div class="PlaceHolder">
	<input type="text" wicket:id="userName" />
</div>


with a behaviors attached to to userName that whenever the field has
errors it finds a parent with class "PlaceHolder" and adds "Error"
class. And remove it if not. No need for a component for
userNamePlaceholder or find a component with a given name (e.g. if you
rename userName you will have to remember changing your behavior).