Re: Idea for a template component

2017-01-16 Thread Marcel Barbosa Pinto
Hi Martin,

I made this quickstart for testing the possibilities:
https://github.com/mbppower/wicketTemplateMarkupComponent

The implementation classes are located at
https://github.com/mbppower/wicketTemplateMarkupComponent/tree/master/src/main/java/org/apache/wicket/markup/html

I think this is indeed really simple, but would be nice to have it
available, since it requires some knowledge that may not be clear for new
users.
It's up to you man, just wanted to show this ;)





On Mon, Jan 16, 2017 at 5:48 AM, Martin Grigorov 
wrote:

> Hi Marcel,
>
> Thank you for your suggestion but I think it doesn't worth it to be part of
> wicket-core.
> It is as simple as
>
> @Override public void onComponentTagBody(final MarkupStream markupStream,
> final ComponentTag openTag) {
>replaceComponentTagBody(markupStream, tag, interpolate(body));
> }
>
> Same could be achieved with CompoundPropertyModel (+ component queueing if
> the hierachy should be changed frequently).
>
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Fri, Jan 13, 2017 at 2:42 PM, Marcel Barbosa Pinto <
> marcel.po...@gmail.com> wrote:
>
> > Hi guys,
> >
> > I had an idea last night and decided to implement it.
> >
> > On my wicket app I have a lot of labels that is used just to display the
> > model values to the user.
> > So my code was some thing like this:
> >
> > WebMarkupContainer container = new WebMarkupContainer("container", new
> > CompoundPropertyModel(myModel));
> > container.add(
> > new Label("prop1");
> > new Label("prop2.name");
> > new Label("prop2.lastname")
> > );
> > add(container);
> >
> > html was like this:
> > 
> > Prop1: 
> > Prop2 name: 
> > Prop2 lastname: 
> > 
> >
> > So I decided to try to simplify the HTML code and created a
> > TemplateMarkupComponent which basically uses the VariableInterpolator
> class
> > and PropertyResolver:
> >
> > java looks like this:
> >
> > TemplateMarkupContainer container = new
> > TemplateMarkupContainer("container", myModel);
> > add(container);
> >
> > Html code:
> >
> > 
> > Prop1: ${prop1}
> > Prop2 name: ${prop2.name}
> > Prop2 lastname:  ${prop2.lastname}
> > 
> >
> > To display the values the component apply the PropertyConverter, so
> fields
> > are displayed with the correct format.
> > It uses the same expressions that PropertyModel uses to get its
> properties.
> > I think this could be used to render scripts as well.
> >
> > You can just remove the expression tag from HTML without having to change
> > the java code.
> > You can choose if and Exception should be raised if the Model doesn't
> > contains the property, like the MapVariableInterpolator does.
> >
> > These two I am still thinking about:
> > You can override the onValue(String expression, Object value) in order to
> > modify the value that is rendered
> > If you pass a Model with is not an Object with properties, like just a
> > String or Int, you can render it by using ${this}
> >
> > It is just two classes:
> > ModelVariableInterpolator.java
> > TemplateMarkupContainer.java
> >
> >
> > Do you think that this could be useful?
> > What problems could be raised by this approach?
> >
> >
> > --
> >
> > Marcel Barbosa Pinto
> >
>



-- 

Marcel Barbosa Pinto
55 11 98255 8288


AW: AW: AW: AW: AW: Update ListMultipleChoice by Ajax

2017-01-16 Thread Christoph.Manig
Thank you. Now all is working fine :)


Mit freundlichen Grüßen
Christoph Manig

-Ursprüngliche Nachricht-
Von: Sven Meier [mailto:s...@meiers.net] 
Gesendet: Montag, 16. Januar 2017 11:07
An: users@wicket.apache.org
Betreff: Re: AW: AW: AW: AW: Update ListMultipleChoice by Ajax

Hi,

by default ListMultipleChoice passes the index of an item to the 
choiceRenderer. If your items do not implements #equals() and #hashcode(), the 
index will be -1 (see ListMultipleChoice#getModelValue()).

Note that IChoiceRenderer has a note about this in the javadoc.

Since you are using this index, the currently selected items are not identified 
- i.e. no item has an index==-1.

Hope this helps
Sven


On 16.01.2017 07:59, christoph.ma...@t-systems.com wrote:
> Can you explain what these methods equals() and hashCode() have to do?
>
>
> Mit freundlichen Grüßen
> Christoph Manig
>
> -Ursprüngliche Nachricht-
> Von: Sven Meier [mailto:s...@meiers.net]
> Gesendet: Freitag, 13. Januar 2017 13:41
> An: users@wicket.apache.org
> Betreff: Re: AW: AW: AW: Update ListMultipleChoice by Ajax
>
> Ah, it didn't have anything to do with Ajax or models after all:
>
> - PasswordTextField#setResetPassword(false) lets it render the 
> password (you don't have a login form here, so it's safe)
>
> - Group has to implement #equals() and #hashCode() *or* you have to 
> use an id value other than index (which is ChoiceRenderer's default)
>
> Have fun
> Sven
>
>
> On 13.01.2017 11:18, christoph.ma...@t-systems.com wrote:
>> Ok I created an Account on GitHub. Here is the example:
>> https://github.com/CManig/WicketChoiceExample
>>
>>
>> Mit freundlichen Grüßen
>> Christoph Manig
>>
>>
>> -Ursprüngliche Nachricht-
>> Von: Maxim Solodovnik [mailto:solomax...@gmail.com]
>> Gesendet: Freitag, 13. Januar 2017 10:48
>> An: users@wicket.apache.org
>> Betreff: Re: AW: AW: Update ListMultipleChoice by Ajax
>>
>> you can use any publicaly available project hosting (your SVN, 
>> bitbucket, github etc.) Or you can create JIRA issue and attach your 
>> quickstart (I would use this option only if I know for sure it is 
>> JIRA
>> bug)
>>
>> On Fri, Jan 13, 2017 at 4:07 PM,   wrote:
>>> I've only have a GitLab Account will this also work for you? Can you send 
>>> me a link to the right place in Jira?
>>>
>>>
>>> Mit freundlichen Grüßen
>>> Christoph Manig
>>>
>>> -Ursprüngliche Nachricht-
>>> Von: Maxim Solodovnik [mailto:solomax...@gmail.com]
>>> Gesendet: Freitag, 13. Januar 2017 10:05
>>> An: users@wicket.apache.org
>>> Betreff: Re: AW: AW: Update ListMultipleChoice by Ajax
>>>
>>> You can share github link
>>> or attach it to JIRA :)
>>>
>>> On Fri, Jan 13, 2017 at 4:02 PM,   wrote:
 I created a small example. How can I send this to you?


 Mit freundlichen Grüßen
 Christoph Manig
 Systems Engineer

 T-Systems International GmbH
 Systems Integration - SC Travel, Transport & Logistics Annenstr. 5
 01067 Dresden
 tel.:   +49 (0) 351 / 4744 - 188
 fax:+49 (0) 351 / 4744 - 209
 email:  christoph.ma...@t-systems.com

 T-SYSTEMS INTERNATIONAL GMBH
 Aufsichtsrat: Thomas Dannenfeldt (Vorsitzender)
 Geschäftsführung: Reinhard Clemens (Vorsitzender), Dr. Ferri 
 Abolhassan, Thilo Kusch, Dr. Markus Müller, Georg Pepping, Hagen 
 Rickmann
 Handelsregister: Amtsgericht Frankfurt am Main HRB 55933 Sitz der
 Gesellschaft: Frankfurt am Main WEEE-Reg.-Nr. DE50335567


 -Ursprüngliche Nachricht-
 Von: Sven Meier [mailto:s...@meiers.net]
 Gesendet: Freitag, 13. Januar 2017 08:16
 An: users@wicket.apache.org
 Betreff: Re: AW: AW: Update ListMultipleChoice by Ajax

 Hi Christoph,

 a https://wicket.apache.org/start/quickstart.html allows us to debug the 
 problem.

 You've probably got your model usage wrong, that will be hard to analyze 
 without seeing more code.

 Regards
 Sven


 On 13.01.2017 08:08, christoph.ma...@t-systems.com wrote:
> After refreshing the page I see the same page. Its not a listView it is a 
> ListMultipleChoice.
>
> What do you mean with a quickstart.
>
>
> Mit freundlichen Grüßen
> Christoph Manig
>
> -Ursprüngliche Nachricht-
> Von: Sven Meier [mailto:s...@meiers.net]
> Gesendet: Donnerstag, 12. Januar 2017 22:51
> An: users@wicket.apache.org
> Betreff: Re: AW: Update ListMultipleChoice by Ajax
>
> Hm, with CompoundPropertyModel all inherited models after dropped on 
> detach and re-acquired on following access.
>
> So in theory that should work.
>
> What happens if you refresh the page (F5) after clicking the Ajax link?
> Does the new data show up in the listView and passwordField?
>
> Could you build a quickstart for a deeper look?
>
> Regards
> Sven
>
>

Re: AW: AW: AW: AW: Update ListMultipleChoice by Ajax

2017-01-16 Thread Sven Meier

Hi,

by default ListMultipleChoice passes the index of an item to the 
choiceRenderer. If your items do not implements #equals() and 
#hashcode(), the index will be -1 (see ListMultipleChoice#getModelValue()).


Note that IChoiceRenderer has a note about this in the javadoc.

Since you are using this index, the currently selected items are not 
identified - i.e. no item has an index==-1.


Hope this helps
Sven


On 16.01.2017 07:59, christoph.ma...@t-systems.com wrote:

Can you explain what these methods equals() and hashCode() have to do?


Mit freundlichen Grüßen
Christoph Manig

-Ursprüngliche Nachricht-
Von: Sven Meier [mailto:s...@meiers.net]
Gesendet: Freitag, 13. Januar 2017 13:41
An: users@wicket.apache.org
Betreff: Re: AW: AW: AW: Update ListMultipleChoice by Ajax

Ah, it didn't have anything to do with Ajax or models after all:

- PasswordTextField#setResetPassword(false) lets it render the password (you 
don't have a login form here, so it's safe)

- Group has to implement #equals() and #hashCode() *or* you have to use an id 
value other than index (which is ChoiceRenderer's default)

Have fun
Sven


On 13.01.2017 11:18, christoph.ma...@t-systems.com wrote:

Ok I created an Account on GitHub. Here is the example:
https://github.com/CManig/WicketChoiceExample


Mit freundlichen Grüßen
Christoph Manig


-Ursprüngliche Nachricht-
Von: Maxim Solodovnik [mailto:solomax...@gmail.com]
Gesendet: Freitag, 13. Januar 2017 10:48
An: users@wicket.apache.org
Betreff: Re: AW: AW: Update ListMultipleChoice by Ajax

you can use any publicaly available project hosting (your SVN,
bitbucket, github etc.) Or you can create JIRA issue and attach your
quickstart (I would use this option only if I know for sure it is JIRA
bug)

On Fri, Jan 13, 2017 at 4:07 PM,   wrote:

I've only have a GitLab Account will this also work for you? Can you send me a 
link to the right place in Jira?


Mit freundlichen Grüßen
Christoph Manig

-Ursprüngliche Nachricht-
Von: Maxim Solodovnik [mailto:solomax...@gmail.com]
Gesendet: Freitag, 13. Januar 2017 10:05
An: users@wicket.apache.org
Betreff: Re: AW: AW: Update ListMultipleChoice by Ajax

You can share github link
or attach it to JIRA :)

On Fri, Jan 13, 2017 at 4:02 PM,   wrote:

I created a small example. How can I send this to you?


Mit freundlichen Grüßen
Christoph Manig
Systems Engineer

T-Systems International GmbH
Systems Integration - SC Travel, Transport & Logistics Annenstr. 5
01067 Dresden
tel.:   +49 (0) 351 / 4744 - 188
fax:+49 (0) 351 / 4744 - 209
email:  christoph.ma...@t-systems.com

T-SYSTEMS INTERNATIONAL GMBH
Aufsichtsrat: Thomas Dannenfeldt (Vorsitzender)
Geschäftsführung: Reinhard Clemens (Vorsitzender), Dr. Ferri
Abolhassan, Thilo Kusch, Dr. Markus Müller, Georg Pepping, Hagen
Rickmann
Handelsregister: Amtsgericht Frankfurt am Main HRB 55933 Sitz der
Gesellschaft: Frankfurt am Main WEEE-Reg.-Nr. DE50335567


-Ursprüngliche Nachricht-
Von: Sven Meier [mailto:s...@meiers.net]
Gesendet: Freitag, 13. Januar 2017 08:16
An: users@wicket.apache.org
Betreff: Re: AW: AW: Update ListMultipleChoice by Ajax

Hi Christoph,

a https://wicket.apache.org/start/quickstart.html allows us to debug the 
problem.

You've probably got your model usage wrong, that will be hard to analyze 
without seeing more code.

Regards
Sven


On 13.01.2017 08:08, christoph.ma...@t-systems.com wrote:

After refreshing the page I see the same page. Its not a listView it is a 
ListMultipleChoice.

What do you mean with a quickstart.


Mit freundlichen Grüßen
Christoph Manig

-Ursprüngliche Nachricht-
Von: Sven Meier [mailto:s...@meiers.net]
Gesendet: Donnerstag, 12. Januar 2017 22:51
An: users@wicket.apache.org
Betreff: Re: AW: Update ListMultipleChoice by Ajax

Hm, with CompoundPropertyModel all inherited models after dropped on detach and 
re-acquired on following access.

So in theory that should work.

What happens if you refresh the page (F5) after clicking the Ajax link?
Does the new data show up in the listView and passwordField?

Could you build a quickstart for a deeper look?

Regards
Sven



On 12.01.2017 15:35, christoph.ma...@t-systems.com wrote:

They are member of a form and this has a CompoundPropertyModel.

setDefaultModel(new CompoundPropertyModel(new
UserModel()));

And this holds all data which are relevant for user. The other components of 
the form show the data of the user which I set as the default model.

Mit freundlichen Grüßen
Christoph Manig

-Ursprüngliche Nachricht-
Von: Sven Meier [mailto:s...@meiers.net]
Gesendet: Donnerstag, 12. Januar 2017 14:20
An: users@wicket.apache.org
Betreff: Re: Update ListMultipleChoice by Ajax

Hi,

your components probably hold a reference to the former model.

Where do 'groups' and 'password' get their model from?

Have fun
Sven


On 12.01.2017 12:37, christoph.ma...@t-systems.com wrote:

Hello,

I have a form which contains a 

Re: Encrypt selected form data before submitting the request to Server

2017-01-16 Thread James Selvakumar
Hi Rob,

Thanks for taking time to reply. And many thanks for the detailed example.
Yes, having the secret rendered makes this approach questionable while
using encryption.
But what you've shared will be sufficient if one were to use other
techniques like hashing etc.

On Mon, Jan 16, 2017 at 4:18 PM, Rob Audenaerde 
wrote:

> >
> > Thanks Martin.
> > Hi Rob, your approach looks interesting.
> > Can you please elaborate on that?
> >
>
> Yes. Although I don't really see the point. The secret that is passed on
> will be readable by an attacker if the attacker could otherwise access the
> fields in the form, effectively rendering this 'security by obscuriry'. The
> only way around this is to pass the secret by other means to the client and
> have them provide it in the form, or use some other type of PKI (which is
> what HTTPS is supposed to do).
>
> -
>
> I would create a Form with a hidden field and an extra attrribute, the
> secret:
>
> Form secretForm = new Form ( ) {  ... };
>
> secretForm.setOutputMarkupId(true);
> IModel encodedResult = new Model<>();
> secretForm.add(AttributeModifier.append("secret",
> Model.of("SuperDuperSecret"));
> secretForm.add(new HiddenField("secret", encodedResult));
> secretForm.add(AjaxButton asb= new AjaxButton("submit")
> {
> @Override
> protected void updateAjaxAttributes( AjaxRequestAttributes attributes )
> {
> super.updateAjaxAttributes( attributes );
> attributes.getAjaxCallListeners().add( new AjaxCallListener()
> {
> @Override
> public CharSequence getBeforeHandler( Component component )
> {
> //I think you should do the encoding here, something with JSON, JQuery,
> return "encryptFormToHiddenField( " + secretForm.getMarkupId() + " ) " ;
> }
> } );
> }
> }; );
>
>
> In the onSubmit() of the form you can access the contents of the
> encodedResult, use the ''SuperDuperSecret" to decode it.
>
> Now that I'm writing it, I think you also want to prevent the other values
> from being sent.. Maybe you could empy the values using JavaScript?
>
>
>
> -Rob
>



-- 
Thanks & regards
James Selvakumar


Re: Encrypt selected form data before submitting the request to Server

2017-01-16 Thread Rob Audenaerde
>
> Thanks Martin.
> Hi Rob, your approach looks interesting.
> Can you please elaborate on that?
>

Yes. Although I don't really see the point. The secret that is passed on
will be readable by an attacker if the attacker could otherwise access the
fields in the form, effectively rendering this 'security by obscuriry'. The
only way around this is to pass the secret by other means to the client and
have them provide it in the form, or use some other type of PKI (which is
what HTTPS is supposed to do).

-

I would create a Form with a hidden field and an extra attrribute, the
secret:

Form secretForm = new Form ( ) {  ... };

secretForm.setOutputMarkupId(true);
IModel encodedResult = new Model<>();
secretForm.add(AttributeModifier.append("secret",
Model.of("SuperDuperSecret"));
secretForm.add(new HiddenField("secret", encodedResult));
secretForm.add(AjaxButton asb= new AjaxButton("submit")
{
@Override
protected void updateAjaxAttributes( AjaxRequestAttributes attributes )
{
super.updateAjaxAttributes( attributes );
attributes.getAjaxCallListeners().add( new AjaxCallListener()
{
@Override
public CharSequence getBeforeHandler( Component component )
{
//I think you should do the encoding here, something with JSON, JQuery,
return "encryptFormToHiddenField( " + secretForm.getMarkupId() + " ) " ;
}
} );
}
}; );


In the onSubmit() of the form you can access the contents of the
encodedResult, use the ''SuperDuperSecret" to decode it.

Now that I'm writing it, I think you also want to prevent the other values
from being sent.. Maybe you could empy the values using JavaScript?



-Rob