You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Dirk Forchel <di...@exedio.com> on 2013/08/29 14:29:05 UTC

Wicket and microdata

I'm currently try to add some kind of microdata
(http://en.wikipedia.org/wiki/Microdata_%28HTML%29) to our project. Exists a
wicketstuff project dealing with this problem?
What is the preferred way to add "valueless" attributes to HTML tags? E.g. I
have to add the following attributes to the body tag:

<body id="foo" itemscope itemtype="http://scheme.org/WebPage">

</body>

At the base page class I've added a TransparentMarkupContainer the following
way:

this.body = new TransparentWebMarkupContainer("body");
this.body.setOutputMarkupId(true);

HTML:

<body wicket:id="body">
   <wicket:child/>
</body>

At a subclass I did:

getBody().setMarkupId("foo").add( AttributeModifier.append("itemscope",
AttributeModifier.VALUELESS_ATTRIBUTE_ADD ) ).add( AttributeModifier.append(
"itemtype", Model.of( "http://scheme.org/WebPage" ) ) );

Is this the preferred way to add "valueless" attributes to a tag (I've never
seen this before)? Or is this marker value for internal use only? At least
the generated HTML code looks like intended.
I would like to know whether there is a kind of general solution to deal
with "microdata", say a bunch of Behavior-classes to add this kind of data.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-and-microdata-tp4661135.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: Wicket and microdata

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

On Thu, Nov 20, 2014 at 7:03 AM, Hendy Irawan <he...@soluvas.com> wrote:

> Hi Dirk and Martin,
>
>
> Dirk Forchel wrote
> >
> > Martin Grigorov-4 wrote
> >> Another way is to add these attributes directly in the markup. No need
> to
> >> add Behavior to the components for something that is always true.
> > Yes, but I prefer the "dynamic" way. A Component/Page provides some kind
> > of "microdata" and implements an interface. The AttributeAppender takes
> > the information and writes the appropriate attribute at the tag.
>
> I agree. Some markups are customizable by designers, I'd rather let them
> worry about presentation structure rather than semantic data, which are
> closer to the model.
>
>
> Martin Grigorov-4 wrote
> >> seen this before)? Or is this marker value for internal use only? At
> >> least
> >> the generated HTML code looks like intended.
> >> I would like to know whether there is a kind of general solution to deal
> >> with "microdata", say a bunch of Behavior-classes to add this kind of
> >> data.
> >>
> >
> > AttributeModifier is a Behavior itself.
> > There is no special code in Wicket for microdata. This specification is
> > not
> > broadly used.
>
> I thought someone has had the same requirements within his project and came
> with a general solution for this specification. Okay, fair enough.
>
>
> Martin, "This [microdata] specification is not broadly used." some of us
> disagree with that ("some" refers to Google, Bing, and Yahoo, for a start)
> ;-) : https://blog.kissmetrics.com/get-started-using-schema/


Feel free to contribute your code as a module at
https://github.com/wicketstuff/core if you think it would be useful for
others and it is reusable.
Thanks !


>
>
> Dirk, yes I have exactly the same requirements as yours for  Bippo
> <http://www.bippo.co.id/>  . Do you share your solution somewhere?
>
> I'm planning to put my work as part of  soluvas-web project on GitHub
> <https://github.com/soluvas/soluvas-web>   since it's most comfortable
> within our build environment, but if anybody wants it in wicketstuff I can
> also contribute.
>
> Thanks.
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Wicket-and-microdata-tp4661135p4668468.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: Wicket and microdata

Posted by Hendy Irawan <he...@soluvas.com>.
Here's what I came up with :
https://github.com/soluvas/soluvas-web/commit/8cfbe121bc8589502154bf72fff9bd94762dd7cb

While my usage is for e-commerce websites, with sufficient definitions it's
usable for any kind of site, primarily using schema.org vocabulary. IMHO
it's quite convenient (thanks to Wicket's Behavior programming model, yay!)
and also type-safe (no Strings, ma!).

Usage examples:

final WebMarkupContainer productDiv = new WebMarkupContainer("productDiv");
productDiv.add(new ItemScopeBehavior(SchemaOrgClass.PRODUCT));

...

protected void populateItem(final ListItem<ProductImage> imageItem) {
	imageItem.add(new ImageMicrodataBehavior());

...

final Label descLabel = new Label("descriptionHtml", new
PropertyModel<String>(model, "descriptionHtml"));
descLabel.add(new ItemPropBehavior(SchemaOrgProperty.DESCRIPTION));

...

inStockLabel = new Label("inStockStatus", "In Stock");
inStockLabel.add(new ItemPropEnumBehavior(SchemaOrgProperty.AVAILABILITY,
ItemAvailability.IN_STOCK));
add(inStockLabel);
outOfStockLabel = new Label("outOfStockStatus", "Out of Stock");
outOfStockLabel.add(new ItemPropEnumBehavior(SchemaOrgProperty.AVAILABILITY,
ItemAvailability.OUT_OF_STOCK));
add(outOfStockLabel);

...

currencyPriceAfterDiscountLbl.add(new
ItemPropContentBehavior(SchemaOrgProperty.PRICE_CURRENCY, 
		new PropertyModel<CurrencyUnit>(selectedProductModel, "currency")));
add(currencyPriceAfterDiscountLbl);
final Label priceAfterDiscountsLabel = new MoneyLabel("price",
priceAfterDiscountsModel);
priceAfterDiscountsLabel.add(new
ItemPropContentBehavior(SchemaOrgProperty.PRICE, 
		priceAfterDiscountsModel));

...

localSkuCtr.add(new Label("localSkuValue", new PropertyModel<>(productModel,
"localSku"))
	.add(new ItemPropBehavior(SchemaOrgProperty.SKU)) );

Hendy


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-and-microdata-tp4661135p4668470.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: Wicket and microdata

Posted by Hendy Irawan <he...@soluvas.com>.
Hi Dirk and Martin,


Dirk Forchel wrote
> 
> Martin Grigorov-4 wrote
>> Another way is to add these attributes directly in the markup. No need to
>> add Behavior to the components for something that is always true.
> Yes, but I prefer the "dynamic" way. A Component/Page provides some kind
> of "microdata" and implements an interface. The AttributeAppender takes
> the information and writes the appropriate attribute at the tag.

I agree. Some markups are customizable by designers, I'd rather let them
worry about presentation structure rather than semantic data, which are
closer to the model.


Martin Grigorov-4 wrote
>> seen this before)? Or is this marker value for internal use only? At
>> least
>> the generated HTML code looks like intended.
>> I would like to know whether there is a kind of general solution to deal
>> with "microdata", say a bunch of Behavior-classes to add this kind of
>> data.
>>
> 
> AttributeModifier is a Behavior itself.
> There is no special code in Wicket for microdata. This specification is
> not
> broadly used.

I thought someone has had the same requirements within his project and came
with a general solution for this specification. Okay, fair enough.


Martin, "This [microdata] specification is not broadly used." some of us
disagree with that ("some" refers to Google, Bing, and Yahoo, for a start)
;-) : https://blog.kissmetrics.com/get-started-using-schema/

Dirk, yes I have exactly the same requirements as yours for  Bippo
<http://www.bippo.co.id/>  . Do you share your solution somewhere?

I'm planning to put my work as part of  soluvas-web project on GitHub
<https://github.com/soluvas/soluvas-web>   since it's most comfortable
within our build environment, but if anybody wants it in wicketstuff I can
also contribute.

Thanks.


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-and-microdata-tp4661135p4668468.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: Wicket and microdata

Posted by Dirk Forchel <di...@exedio.com>.
Martin Grigorov-4 wrote
> Hi,
> 
> 
> On Thu, Aug 29, 2013 at 3:29 PM, Dirk Forchel &lt;

> dirk.forchel@

> &gt;wrote:
> 
>> I'm currently try to add some kind of microdata
>> (http://en.wikipedia.org/wiki/Microdata_%28HTML%29) to our project.
>> Exists a
>> wicketstuff project dealing with this problem?
>>
> 
> I'm not aware of such.
> 
> 
>> What is the preferred way to add "valueless" attributes to HTML tags?
>> E.g.
>> I
>> have to add the following attributes to the body tag:
>>
>> 
> <body id="foo" itemscope itemtype="http://scheme.org/WebPage">
>>
>> 
> </body>
>>
>> At the base page class I've added a TransparentMarkupContainer the
>> following
>> way:
>>
>> this.body = new TransparentWebMarkupContainer("body");
>> this.body.setOutputMarkupId(true);
>>
>> HTML:
>>
>> 
> <body wicket:id="body">
>>    
> <wicket:child/>
>> 
> </body>
>>
>> At a subclass I did:
>>
>> getBody().setMarkupId("foo").add( AttributeModifier.append("itemscope",
>> AttributeModifier.VALUELESS_ATTRIBUTE_ADD ) ).add(
>> AttributeModifier.append(
>> "itemtype", Model.of( "http://scheme.org/WebPage" ) ) );
>>
>> Is this the preferred way to add "valueless" attributes to a tag (I've
>> never
>>
> 
> Yes. This is the way to tell Wicket to not add a value for the attribute.

Okay. I've never seen this before. That's why I was asking.


Martin Grigorov-4 wrote
> Another way is to add these attributes directly in the markup. No need to
> add Behavior to the components for something that is always true.

Yes, but I prefer the "dynamic" way. A Component/Page provides some kind of
"microdata" and implements an interface. The AttributeAppender takes the
information and writes the appropriate attribute at the tag.


Martin Grigorov-4 wrote
>> seen this before)? Or is this marker value for internal use only? At
>> least
>> the generated HTML code looks like intended.
>> I would like to know whether there is a kind of general solution to deal
>> with "microdata", say a bunch of Behavior-classes to add this kind of
>> data.
>>
> 
> AttributeModifier is a Behavior itself.
> There is no special code in Wicket for microdata. This specification is
> not
> broadly used.

I thought someone has had the same requirements within his project and came
with a general solution for this specification. Okay, fair enough. 




--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-and-microdata-tp4661135p4661153.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: Wicket and microdata

Posted by Martin Grigorov <mg...@apache.org>.
Hi,


On Thu, Aug 29, 2013 at 3:29 PM, Dirk Forchel <di...@exedio.com>wrote:

> I'm currently try to add some kind of microdata
> (http://en.wikipedia.org/wiki/Microdata_%28HTML%29) to our project.
> Exists a
> wicketstuff project dealing with this problem?
>

I'm not aware of such.


> What is the preferred way to add "valueless" attributes to HTML tags? E.g.
> I
> have to add the following attributes to the body tag:
>
> <body id="foo" itemscope itemtype="http://scheme.org/WebPage">
>
> </body>
>
> At the base page class I've added a TransparentMarkupContainer the
> following
> way:
>
> this.body = new TransparentWebMarkupContainer("body");
> this.body.setOutputMarkupId(true);
>
> HTML:
>
> <body wicket:id="body">
>    <wicket:child/>
> </body>
>
> At a subclass I did:
>
> getBody().setMarkupId("foo").add( AttributeModifier.append("itemscope",
> AttributeModifier.VALUELESS_ATTRIBUTE_ADD ) ).add(
> AttributeModifier.append(
> "itemtype", Model.of( "http://scheme.org/WebPage" ) ) );
>
> Is this the preferred way to add "valueless" attributes to a tag (I've
> never
>

Yes. This is the way to tell Wicket to not add a value for the attribute.

Another way is to add these attributes directly in the markup. No need to
add Behavior to the components for something that is always true.


> seen this before)? Or is this marker value for internal use only? At least
> the generated HTML code looks like intended.
> I would like to know whether there is a kind of general solution to deal
> with "microdata", say a bunch of Behavior-classes to add this kind of data.
>

AttributeModifier is a Behavior itself.
There is no special code in Wicket for microdata. This specification is not
broadly used.


>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Wicket-and-microdata-tp4661135.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
>
>