You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by resign <se...@yahoo.de> on 2012/04/12 13:10:11 UTC

T5.2.6 mixins example

Hi,
i search an example how to create and use mixins.
Unfortunately, i cannot found anything to become smarter.
My idea - i write a mixin which set TextField disabled or not depends on
logged user.

My example code

class FieldMixin{
@Inject
private ComponentResources  resources;

private Element element;

@SessionState(create = false)
private WebUser         user;

void beginRender(MarkupWriter writer){
  element = writer.getElement();
  if(user.getName().equels("admin"){
     element.attribute("disabled", "disabled");
  }
}
}

TML
...
<t:textfield t:id="fieldA" t:mixin="FieldMixin" />
...


Is this the right way?
How can i get it running?

greeting,
resign


--
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-2-6-mixins-example-tp5635318p5635318.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: T5.2.6 mixins example

Posted by resign <se...@yahoo.de>.
YOU ARE MY HERO !!!



--
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-2-6-mixins-example-tp5635318p5635438.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: T5.2.6 mixins example

Posted by Emmanuel DEMEY <de...@gmail.com>.
I have just tested. You should add the @MixinAfter annotation to your Mixin
class.

2012/4/12 resign <se...@yahoo.de>

> exaclty my idea :-)
>
> doesn't work too
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/T5-2-6-mixins-example-tp5635318p5635403.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
>
>


-- 
Emmanuel DEMEY
Ingénieur Etude et Développement
ATOS Worldline
+33 (0)6 47 47 42 02
demey.emmanuel@gmail.com
http://emmanueldemey.fr

Twitter : @gillespie59

Re: T5.2.6 mixins example

Posted by resign <se...@yahoo.de>.
exaclty my idea :-)

doesn't work too 


--
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-2-6-mixins-example-tp5635318p5635403.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: T5.2.6 mixins example

Posted by Emmanuel DEMEY <de...@gmail.com>.
I think, setting the disabled property in the beginRender phase is to
early, because the textfield is not rendered yet. So the current element is
th <td>.

Do it in the afterRender phase.

Manu

2012/4/12 resign <se...@yahoo.de>

> following:
>
> my textField is in table cell.
> If i view into generated html, i can see that the <td> - element is
> "disabled"...
>
> ....
> <td colspan="2">
>    <input t:type="TextField"
>           t:id="manualCoordinates"
>           value="myObject.manualCoordinates"
>           t:mixins="FieldRightsMixin"
>           idTag="literal:manualCoordinates"
>           processEdit="isEditable"
>   />
> </td>
> ....
>
> and generated HTML looks like
> ..
> <td disabled="disabled" colSpan="2">
>  <input name="manualCoordinates"  type="text" value="12345"/>
> </td>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/T5-2-6-mixins-example-tp5635318p5635389.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
>
>


-- 
Emmanuel DEMEY
Ingénieur Etude et Développement
ATOS Worldline
+33 (0)6 47 47 42 02
demey.emmanuel@gmail.com
http://emmanueldemey.fr

Twitter : @gillespie59

Re: T5.2.6 mixins example

Posted by resign <se...@yahoo.de>.
following:

my textField is in table cell.
If i view into generated html, i can see that the <td> - element is
"disabled"...

....
<td colspan="2">
    <input t:type="TextField" 
	   t:id="manualCoordinates" 
	   value="myObject.manualCoordinates" 
	   t:mixins="FieldRightsMixin"
	   idTag="literal:manualCoordinates" 
	   processEdit="isEditable"
   />
</td>
....

and generated HTML looks like
..
<td disabled="disabled" colSpan="2">
  <input name="manualCoordinates"  type="text" value="12345"/>
</td>

--
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-2-6-mixins-example-tp5635318p5635389.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: T5.2.6 mixins example

Posted by Emmanuel DEMEY <de...@gmail.com>.
Does the disabled attribute alread exist in your template.
If it is, according to the JavaDoc, the attribute method will not work. Try
with the forceAttributes method.

Can you also check if your SessionsState-annotated variable is correct, and
also the current element.

2012/4/12 resign <se...@yahoo.de>

> Hi,
> your' right... but it still doesn't work
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/T5-2-6-mixins-example-tp5635318p5635342.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
>
>


-- 
Emmanuel DEMEY
Ingénieur Etude et Développement
ATOS Worldline
+33 (0)6 47 47 42 02
demey.emmanuel@gmail.com
http://emmanueldemey.fr

Twitter : @gillespie59

Re: T5.2.6 mixins example

Posted by resign <se...@yahoo.de>.
Hi,
your' right... but it still doesn't work

--
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-2-6-mixins-example-tp5635318p5635342.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: T5.2.6 mixins example

Posted by Emmanuel DEMEY <de...@gmail.com>.
The right syntax is :
<t:textfield t:id="fieldA" t:mixins="FieldMixin" />

2012/4/12 resign <se...@yahoo.de>

> Hi,
> i search an example how to create and use mixins.
> Unfortunately, i cannot found anything to become smarter.
> My idea - i write a mixin which set TextField disabled or not depends on
> logged user.
>
> My example code
>
> class FieldMixin{
> @Inject
> private ComponentResources  resources;
>
> private Element element;
>
> @SessionState(create = false)
> private WebUser         user;
>
> void beginRender(MarkupWriter writer){
>  element = writer.getElement();
>  if(user.getName().equels("admin"){
>     element.attribute("disabled", "disabled");
>  }
> }
> }
>
> TML
> ...
> <t:textfield t:id="fieldA" t:mixin="FieldMixin" />
> ...
>
>
> Is this the right way?
> How can i get it running?
>
> greeting,
> resign
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/T5-2-6-mixins-example-tp5635318p5635318.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
>
>


-- 
Emmanuel DEMEY
Ingénieur Etude et Développement
ATOS Worldline
+33 (0)6 47 47 42 02
demey.emmanuel@gmail.com
http://emmanueldemey.fr

Twitter : @gillespie59