Re: Possible bug in ListView [Cannot change attributes in ListView div]

2013-02-24 Thread Gonzalo Aguilar Delgado
Hello Sven, 

I'm stupid. Sorry for the question. I read a lot of times it in the
forums, saw examples, but really 
never realized that the main div was the item that get passed to the
populateItem.

It made me uncofortable someway. I don't know why. :D

Thank you a lot. 


El dom, 24-02-2013 a las 09:01 +0100, Sven Meier escribió:

> Short answer is in ListView's javadoc:
> 
>   * 
>   * NOTE:
>   *
>   * When you want to change the default generated markup it is important 
> to realize that the ListView
>   * instance itself does not correspond to any markup, however, the 
> generated ListItems do.
>   *
>   * This means that methods like {@link #setRenderBodyOnly(boolean)} and
>   * {@link #add(org.apache.wicket.behavior.Behavior...)} should be 
> invoked on the {@link ListItem}
>   * that is given in {@link #populateItem(ListItem)} method.
>   * 
> 
> Sven
> 
> On 02/24/2013 02:40 AM, Gonzalo Aguilar Delgado wrote:
> > Hello,
> >
> > I think I found something that may not be working right.
> >
> > I have an html that looks like:
> >
> > 
> > 
> > 
> >
> >
> > regionOne will be a listview and regionWidget will be one panel
> > populated on populateItem.
> >
> >
> > This is how it looks the class that will go to regionOne (listview)
> >
> > public class RegionWidgetContainer extends ListView {
> > /**
> >  *
> >  */
> > private static final long serialVersionUID = 1L;
> > final static Logger logger =
> > LoggerFactory.getLogger(RegionWidgetContainer.class);
> > private static int regionCounter = 1;
> >
> > private int regionIdx=0;
> >
> > public RegionWidgetContainer(String id, final Region region, PageUser
> > pageUser) {
> > super(id, new IModel>(){
> >
> > /**
> >  *
> >  */
> > private static final long serialVersionUID = 1L;
> >
> > @Override
> > public void detach() {
> > // TODO Auto-generated method stub
> > }
> >
> > @Override
> > public List getObject() {
> > return region.getRegionWidgets();
> > }
> >
> > @Override
> > public void setObject(List object) {
> > }
> > 
> > });
> > regionIdx = RegionWidgetContainer.nextCounter();
> > buildCssClassAttributes(region,pageUser);
> > this.setMarkupId("region-" + region.getId() + "-id");   
> > this.setOutputMarkupId(true);
> > }
> > 
> > protected void buildCssClassAttributes(Region region, PageUser
> > pageUser)
> > {
> > String cssClass = "region";
> > if(region.isLocked() || !pageUser.isEditor())
> > {
> > cssClass += " region-locked";
> > }
> > 
> > cssClass += " " + region.getPage().getPageLayout().getCode() + 
> > "_" +
> > String.valueOf(regionIdx);
> > cssClass += " regionNonDragging";
> > 
> > 
> > this.add(new AttributeAppender("class", cssClass));
> > }
> > ...
> > }
> >
> >
> >
> > As you can see it will add the class via AttributeAppender and will set
> > the markup id.
> >
> >
> > But it does not work. Any of two. The div is rendered like this...
> >
> > 
> > ...
> > 
> >
> >
> > So, is this a bug or a feature?
> >
> >
> 
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 


Re: Possible bug in ListView [Cannot change attributes in ListView div]

2013-02-24 Thread Sven Meier

Short answer is in ListView's javadoc:

 * 
 * NOTE:
 *
 * When you want to change the default generated markup it is important 
to realize that the ListView
 * instance itself does not correspond to any markup, however, the 
generated ListItems do.

 *
 * This means that methods like {@link #setRenderBodyOnly(boolean)} and
 * {@link #add(org.apache.wicket.behavior.Behavior...)} should be 
invoked on the {@link ListItem}

 * that is given in {@link #populateItem(ListItem)} method.
 * 

Sven

On 02/24/2013 02:40 AM, Gonzalo Aguilar Delgado wrote:

Hello,

I think I found something that may not be working right.

I have an html that looks like:






regionOne will be a listview and regionWidget will be one panel
populated on populateItem.


This is how it looks the class that will go to regionOne (listview)

public class RegionWidgetContainer extends ListView {
/**
 *
 */
private static final long serialVersionUID = 1L;
final static Logger logger =
LoggerFactory.getLogger(RegionWidgetContainer.class);
private static int regionCounter = 1;

private int regionIdx=0;

public RegionWidgetContainer(String id, final Region region, PageUser
pageUser) {
super(id, new IModel>(){

/**
 *
 */
private static final long serialVersionUID = 1L;

@Override
public void detach() {
// TODO Auto-generated method stub
}

@Override
public List getObject() {
return region.getRegionWidgets();
}

@Override
public void setObject(List object) {
}

});
regionIdx = RegionWidgetContainer.nextCounter();
buildCssClassAttributes(region,pageUser);
this.setMarkupId("region-" + region.getId() + "-id");   
this.setOutputMarkupId(true);
}

protected void buildCssClassAttributes(Region region, PageUser
pageUser)
{
String cssClass = "region";
if(region.isLocked() || !pageUser.isEditor())
{
cssClass += " region-locked";
}

cssClass += " " + region.getPage().getPageLayout().getCode() + 
"_" +
String.valueOf(regionIdx);
cssClass += " regionNonDragging";


this.add(new AttributeAppender("class", cssClass));
}
...
}



As you can see it will add the class via AttributeAppender and will set
the markup id.


But it does not work. Any of two. The div is rendered like this...


...



So, is this a bug or a feature?





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



Re: Possible bug in ListView [Cannot change attributes in ListView div]

2013-02-23 Thread Ernesto Reinaldo Barreiro
Try






On Sun, Feb 24, 2013 at 2:40 AM, Gonzalo Aguilar Delgado <
gagui...@aguilardelgado.com> wrote:

> Hello,
>
> I think I found something that may not be working right.
>
> I have an html that looks like:
>
> 
> 
> 
>
>
> regionOne will be a listview and regionWidget will be one panel
> populated on populateItem.
>
>
> This is how it looks the class that will go to regionOne (listview)
>
> public class RegionWidgetContainer extends ListView {
> /**
>  *
>  */
> private static final long serialVersionUID = 1L;
> final static Logger logger =
> LoggerFactory.getLogger(RegionWidgetContainer.class);
> private static int regionCounter = 1;
>
> private int regionIdx=0;
>
> public RegionWidgetContainer(String id, final Region region,
> PageUser
> pageUser) {
> super(id, new IModel>(){
>
> /**
>  *
>  */
> private static final long serialVersionUID = 1L;
>
> @Override
> public void detach() {
> // TODO Auto-generated method stub
> }
>
> @Override
> public List getObject() {
> return region.getRegionWidgets();
> }
>
> @Override
> public void setObject(List object) {
> }
>
> });
> regionIdx = RegionWidgetContainer.nextCounter();
> buildCssClassAttributes(region,pageUser);
> this.setMarkupId("region-" + region.getId() + "-id");
> this.setOutputMarkupId(true);
> }
>
> protected void buildCssClassAttributes(Region region, PageUser
> pageUser)
> {
> String cssClass = "region";
> if(region.isLocked() || !pageUser.isEditor())
> {
> cssClass += " region-locked";
> }
>
> cssClass += " " +
> region.getPage().getPageLayout().getCode() + "_" +
> String.valueOf(regionIdx);
> cssClass += " regionNonDragging";
>
>
> this.add(new AttributeAppender("class", cssClass));
> }
> ...
> }
>
>
>
> As you can see it will add the class via AttributeAppender and will set
> the markup id.
>
>
> But it does not work. Any of two. The div is rendered like this...
>
> 
> ...
> 
>
>
> So, is this a bug or a feature?
>
>


-- 
Regards - Ernesto Reinaldo Barreiro
Antilia Soft
http://antiliasoft.com/ 


Possible bug in ListView [Cannot change attributes in ListView div]

2013-02-23 Thread Gonzalo Aguilar Delgado
Hello, 

I think I found something that may not be working right. 

I have an html that looks like:






regionOne will be a listview and regionWidget will be one panel
populated on populateItem.


This is how it looks the class that will go to regionOne (listview)

public class RegionWidgetContainer extends ListView {
/**
 * 
 */
private static final long serialVersionUID = 1L;
final static Logger logger =
LoggerFactory.getLogger(RegionWidgetContainer.class);
private static int regionCounter = 1;

private int regionIdx=0;

public RegionWidgetContainer(String id, final Region region, PageUser
pageUser) {
super(id, new IModel>(){

/**
 * 
 */
private static final long serialVersionUID = 1L;

@Override
public void detach() {
// TODO Auto-generated method stub
}

@Override
public List getObject() {
return region.getRegionWidgets();
}

@Override
public void setObject(List object) {
}

});
regionIdx = RegionWidgetContainer.nextCounter();
buildCssClassAttributes(region,pageUser);
this.setMarkupId("region-" + region.getId() + "-id");   
this.setOutputMarkupId(true);
}

protected void buildCssClassAttributes(Region region, PageUser
pageUser)
{
String cssClass = "region";
if(region.isLocked() || !pageUser.isEditor())
{
cssClass += " region-locked";
}

cssClass += " " + region.getPage().getPageLayout().getCode() + 
"_" +
String.valueOf(regionIdx);
cssClass += " regionNonDragging";


this.add(new AttributeAppender("class", cssClass));
}
...
}



As you can see it will add the class via AttributeAppender and will set
the markup id. 


But it does not work. Any of two. The div is rendered like this...


...



So, is this a bug or a feature?