You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Em <ma...@yahoo.de> on 2011/11/27 01:42:54 UTC

Newbie Questions: Getting Plain HTML

Hello list,

I am absolutely new to Apache Wicket (and new to writing
java-web-frontends instead of web-services) and not sure whether it is
right for my needs.

I got some questions regarding the rendering process.
For template sharing between client and server it would be great if I
can get a wicket-tag-free template-version at processing time.

The idea:
My Wicket-template looks like:
    <wicket:panel>
      <table>
        <tr>
          <th>$userNameTitle</th>
          <th>$lastLoginTitle</th>
        </tr>

        <tr wicket:id="users">
          <td><span wicket:id="username">$userName</span></td>
          <td><span wicket:id="lastLogin">$lastLogin</span></td>
        </tr>
      </table>
    </wicket:panel>

When I am interested in the user's section, I want to do the following
(in pseudo-code):

myUserView.getTemplate();
//output is completely freed of Wicket-specific stuff:
  <tr>
    <td><span>$userName</span></td>
    <td><span>$lastLogin</span></td>
  </tr>


However I am even happy with this output:
  <tr>
    <td></td>
    <td></td>
  </tr>
NOTE: The inner wicket:id's were left. Maybe I have to call their
content seperately (and then getting their content together with the
corresponding placeholders).

What is the main idea behind that?
A collegue of mine comes from the PHP-corner. They were able to share
the template between server and backend, so that a client-side
JS-template-engine rendered the same HTML as the server's
template-engine (PHP).
On AJAX-requests they were saving a lot of traffic and ressources, since
they just needed to serialize their PHP-models to JSON and respond them
to the client.
Their JavaScript developers did not need to know about the PHP-backend.
Using Apache Wicket, I want to achieve the same with a Java-backend.

Another thing:
Using PHP and a placeholder-like template-engine that supports basic
logic (if, else, loops) their designers did not need to know about the
PHP-classes that are responsible for creating the placeholders as long
as they worked correctly.
So a designer without knowledge about the backend's language was able to
work on a template. He was able to give even and uneven rows in a table
different colours right from the template's logic.
Is this possible with Apache Wicket, too?

Any other suggestions, opinions, advices? :)

Regards,
Em

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


Re: Newbie Questions: Getting Plain HTML

Posted by Andrea Del Bene <an...@gmail.com>.
On 11/27/2011 03:40 PM, Em wrote:
> Hi Andrea,
>
> thanks for sharing your information!
>
> My answers are in the content.
>
> Am 27.11.2011 14:52, schrieb Andrea Del Bene:
>>> I already saw this Wiki-page yesterday.
>>> Well, the point is, that I want to include the markup *in* the markup
>>> (i.e. output it in some panel inside of a script-tag so that JavaScript
>>> is able to get the markup).
>>> So *while* you are rendering, you want to know the schema Wicket is
>>> rendering on to include it in some places before outputting.
>> you should have a look to method Component.renderHead(IHeaderResponse
>> response).  If you override it you can write an arbitrary string to the
>> header section. For example you could do something like:
>>
>> @Override
>>      public void renderHead(IHeaderResponse response) {
>>          super.renderHead(response);
>>
>>          response.renderJavaScript(myUserView.getMarkup().toString(true),
>> "markupUser");
>>      }
>>
>>
>> This will put the markup of myUserView inside a script tag with
>> id="markupUser".
>>
> Without the Wicket-specific tags? Sounds great!

Yes, you should be able to strip out Wicket tags.  For example the 
output for a simple form with 2 text field is:

<script type="text/javascript" id="markupJavaScript">
/*<![CDATA[*/
<form action="" wicket:id="form">
             Name <input wicket:id="name"/>
             Surname <input wicket:id="surname"/>
</form>
/*]]>*/
</script>
>>> I saw that Velocity integration is possible with Wicket and as far as I
>>> saw there are no problems or drawbacks with it - can you confirm that?
>> Have you seen this example
>> http://wicket.apache.org/learn/projects/velocity.html ? Maybe it could
>> help you.
> I saw exactly this page but thought about whether there may be some
> drawbacks (in terms of performance, security or something else) with
> this approach.
>
> Regards,
> Em

Unfortunately I didn't have the chance to work with Velocity, so I can't 
tell anything about possible drawbacks. But I think you won't find big 
issues with it.

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


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


Re: Newbie Questions: Getting Plain HTML

Posted by Em <ma...@yahoo.de>.
Hi Andrea,

thanks for sharing your information!

My answers are in the content.

Am 27.11.2011 14:52, schrieb Andrea Del Bene:
>> I already saw this Wiki-page yesterday.
>> Well, the point is, that I want to include the markup *in* the markup
>> (i.e. output it in some panel inside of a script-tag so that JavaScript
>> is able to get the markup).
>> So *while* you are rendering, you want to know the schema Wicket is
>> rendering on to include it in some places before outputting.
> 
> you should have a look to method Component.renderHead(IHeaderResponse
> response).  If you override it you can write an arbitrary string to the
> header section. For example you could do something like:
> 
> @Override
>     public void renderHead(IHeaderResponse response) {
>         super.renderHead(response);
> 
>         response.renderJavaScript(myUserView.getMarkup().toString(true),
> "markupUser");
>     }
> 
> 
> This will put the markup of myUserView inside a script tag with
> id="markupUser".
> 

Without the Wicket-specific tags? Sounds great!

>>
>> I saw that Velocity integration is possible with Wicket and as far as I
>> saw there are no problems or drawbacks with it - can you confirm that?
> 
> Have you seen this example
> http://wicket.apache.org/learn/projects/velocity.html ? Maybe it could
> help you.

I saw exactly this page but thought about whether there may be some
drawbacks (in terms of performance, security or something else) with
this approach.

Regards,
Em

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


Re: Newbie Questions: Getting Plain HTML

Posted by Andrea Del Bene <an...@gmail.com>.
Hi Em,


> Hi Josh,
>
> thanks for your feedback!
>
> I already saw this Wiki-page yesterday.
> Well, the point is, that I want to include the markup *in* the markup
> (i.e. output it in some panel inside of a script-tag so that JavaScript
> is able to get the markup).
> So *while* you are rendering, you want to know the schema Wicket is
> rendering on to include it in some places before outputting.

you should have a look to method Component.renderHead(IHeaderResponse 
response).  If you override it you can write an arbitrary string to the 
header section. For example you could do something like:

@Override
     public void renderHead(IHeaderResponse response) {
         super.renderHead(response);

         
response.renderJavaScript(myUserView.getMarkup().toString(true), 
"markupUser");
     }


This will put the markup of myUserView inside a script tag with 
id="markupUser".


>
> I saw that Velocity integration is possible with Wicket and as far as I
> saw there are no problems or drawbacks with it - can you confirm that?
>
> Regards,
> Em

Have you seen this example 
http://wicket.apache.org/learn/projects/velocity.html ? Maybe it could 
help you.

> Am 27.11.2011 09:31, schrieb Josh Kamau:
>> Hi there,
>>
>> Look for instructions on how to remove wicket tags here:
>> https://cwiki.apache.org/WICKET/how-to-remove-wicket-markup-from-output.html.
>> Also look around to learn how to do a thousand other things in wicket.
>>
>> Kind regards.
>> Josh.
>>
>> On Sun, Nov 27, 2011 at 3:42 AM, Em<ma...@yahoo.de>  wrote:
>>
>>> Hello list,
>>>
>>> I am absolutely new to Apache Wicket (and new to writing
>>> java-web-frontends instead of web-services) and not sure whether it is
>>> right for my needs.
>>>
>>> I got some questions regarding the rendering process.
>>> For template sharing between client and server it would be great if I
>>> can get a wicket-tag-free template-version at processing time.
>>>
>>> The idea:
>>> My Wicket-template looks like:
>>>     <wicket:panel>
>>>       <table>
>>>         <tr>
>>>           <th>$userNameTitle</th>
>>>           <th>$lastLoginTitle</th>
>>>         </tr>
>>>
>>>         <tr wicket:id="users">
>>>           <td><span wicket:id="username">$userName</span></td>
>>>           <td><span wicket:id="lastLogin">$lastLogin</span></td>
>>>         </tr>
>>>       </table>
>>>     </wicket:panel>
>>>
>>> When I am interested in the user's section, I want to do the following
>>> (in pseudo-code):
>>>
>>> myUserView.getTemplate();
>>> //output is completely freed of Wicket-specific stuff:
>>>   <tr>
>>>     <td><span>$userName</span></td>
>>>     <td><span>$lastLogin</span></td>
>>>   </tr>
>>>
>>>
>>> However I am even happy with this output:
>>>   <tr>
>>>     <td></td>
>>>     <td></td>
>>>   </tr>
>>> NOTE: The inner wicket:id's were left. Maybe I have to call their
>>> content seperately (and then getting their content together with the
>>> corresponding placeholders).
>>>
>>> What is the main idea behind that?
>>> A collegue of mine comes from the PHP-corner. They were able to share
>>> the template between server and backend, so that a client-side
>>> JS-template-engine rendered the same HTML as the server's
>>> template-engine (PHP).
>>> On AJAX-requests they were saving a lot of traffic and ressources, since
>>> they just needed to serialize their PHP-models to JSON and respond them
>>> to the client.
>>> Their JavaScript developers did not need to know about the PHP-backend.
>>> Using Apache Wicket, I want to achieve the same with a Java-backend.
>>>
>>> Another thing:
>>> Using PHP and a placeholder-like template-engine that supports basic
>>> logic (if, else, loops) their designers did not need to know about the
>>> PHP-classes that are responsible for creating the placeholders as long
>>> as they worked correctly.
>>> So a designer without knowledge about the backend's language was able to
>>> work on a template. He was able to give even and uneven rows in a table
>>> different colours right from the template's logic.
>>> Is this possible with Apache Wicket, too?
>>>
>>> Any other suggestions, opinions, advices? :)
>>>
>>> Regards,
>>> Em
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


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


Re: Newbie Questions: Getting Plain HTML

Posted by Em <ma...@yahoo.de>.
Hi Josh,

thanks for your feedback!

I already saw this Wiki-page yesterday.
Well, the point is, that I want to include the markup *in* the markup
(i.e. output it in some panel inside of a script-tag so that JavaScript
is able to get the markup).
So *while* you are rendering, you want to know the schema Wicket is
rendering on to include it in some places before outputting.

I saw that Velocity integration is possible with Wicket and as far as I
saw there are no problems or drawbacks with it - can you confirm that?

Regards,
Em

Am 27.11.2011 09:31, schrieb Josh Kamau:
> Hi there,
> 
> Look for instructions on how to remove wicket tags here:
> https://cwiki.apache.org/WICKET/how-to-remove-wicket-markup-from-output.html.
> Also look around to learn how to do a thousand other things in wicket.
> 
> Kind regards.
> Josh.
> 
> On Sun, Nov 27, 2011 at 3:42 AM, Em <ma...@yahoo.de> wrote:
> 
>> Hello list,
>>
>> I am absolutely new to Apache Wicket (and new to writing
>> java-web-frontends instead of web-services) and not sure whether it is
>> right for my needs.
>>
>> I got some questions regarding the rendering process.
>> For template sharing between client and server it would be great if I
>> can get a wicket-tag-free template-version at processing time.
>>
>> The idea:
>> My Wicket-template looks like:
>>    <wicket:panel>
>>      <table>
>>        <tr>
>>          <th>$userNameTitle</th>
>>          <th>$lastLoginTitle</th>
>>        </tr>
>>
>>        <tr wicket:id="users">
>>          <td><span wicket:id="username">$userName</span></td>
>>          <td><span wicket:id="lastLogin">$lastLogin</span></td>
>>        </tr>
>>      </table>
>>    </wicket:panel>
>>
>> When I am interested in the user's section, I want to do the following
>> (in pseudo-code):
>>
>> myUserView.getTemplate();
>> //output is completely freed of Wicket-specific stuff:
>>  <tr>
>>    <td><span>$userName</span></td>
>>    <td><span>$lastLogin</span></td>
>>  </tr>
>>
>>
>> However I am even happy with this output:
>>  <tr>
>>    <td></td>
>>    <td></td>
>>  </tr>
>> NOTE: The inner wicket:id's were left. Maybe I have to call their
>> content seperately (and then getting their content together with the
>> corresponding placeholders).
>>
>> What is the main idea behind that?
>> A collegue of mine comes from the PHP-corner. They were able to share
>> the template between server and backend, so that a client-side
>> JS-template-engine rendered the same HTML as the server's
>> template-engine (PHP).
>> On AJAX-requests they were saving a lot of traffic and ressources, since
>> they just needed to serialize their PHP-models to JSON and respond them
>> to the client.
>> Their JavaScript developers did not need to know about the PHP-backend.
>> Using Apache Wicket, I want to achieve the same with a Java-backend.
>>
>> Another thing:
>> Using PHP and a placeholder-like template-engine that supports basic
>> logic (if, else, loops) their designers did not need to know about the
>> PHP-classes that are responsible for creating the placeholders as long
>> as they worked correctly.
>> So a designer without knowledge about the backend's language was able to
>> work on a template. He was able to give even and uneven rows in a table
>> different colours right from the template's logic.
>> Is this possible with Apache Wicket, too?
>>
>> Any other suggestions, opinions, advices? :)
>>
>> Regards,
>> Em
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 

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


Re: Newbie Questions: Getting Plain HTML

Posted by Josh Kamau <jo...@gmail.com>.
Hi there,

Look for instructions on how to remove wicket tags here:
https://cwiki.apache.org/WICKET/how-to-remove-wicket-markup-from-output.html.
Also look around to learn how to do a thousand other things in wicket.

Kind regards.
Josh.

On Sun, Nov 27, 2011 at 3:42 AM, Em <ma...@yahoo.de> wrote:

> Hello list,
>
> I am absolutely new to Apache Wicket (and new to writing
> java-web-frontends instead of web-services) and not sure whether it is
> right for my needs.
>
> I got some questions regarding the rendering process.
> For template sharing between client and server it would be great if I
> can get a wicket-tag-free template-version at processing time.
>
> The idea:
> My Wicket-template looks like:
>    <wicket:panel>
>      <table>
>        <tr>
>          <th>$userNameTitle</th>
>          <th>$lastLoginTitle</th>
>        </tr>
>
>        <tr wicket:id="users">
>          <td><span wicket:id="username">$userName</span></td>
>          <td><span wicket:id="lastLogin">$lastLogin</span></td>
>        </tr>
>      </table>
>    </wicket:panel>
>
> When I am interested in the user's section, I want to do the following
> (in pseudo-code):
>
> myUserView.getTemplate();
> //output is completely freed of Wicket-specific stuff:
>  <tr>
>    <td><span>$userName</span></td>
>    <td><span>$lastLogin</span></td>
>  </tr>
>
>
> However I am even happy with this output:
>  <tr>
>    <td></td>
>    <td></td>
>  </tr>
> NOTE: The inner wicket:id's were left. Maybe I have to call their
> content seperately (and then getting their content together with the
> corresponding placeholders).
>
> What is the main idea behind that?
> A collegue of mine comes from the PHP-corner. They were able to share
> the template between server and backend, so that a client-side
> JS-template-engine rendered the same HTML as the server's
> template-engine (PHP).
> On AJAX-requests they were saving a lot of traffic and ressources, since
> they just needed to serialize their PHP-models to JSON and respond them
> to the client.
> Their JavaScript developers did not need to know about the PHP-backend.
> Using Apache Wicket, I want to achieve the same with a Java-backend.
>
> Another thing:
> Using PHP and a placeholder-like template-engine that supports basic
> logic (if, else, loops) their designers did not need to know about the
> PHP-classes that are responsible for creating the placeholders as long
> as they worked correctly.
> So a designer without knowledge about the backend's language was able to
> work on a template. He was able to give even and uneven rows in a table
> different colours right from the template's logic.
> Is this possible with Apache Wicket, too?
>
> Any other suggestions, opinions, advices? :)
>
> Regards,
> Em
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>