HtmlCommandButton - created programmatically - will not be displayed
andreas.milinski Sep 16, 2010 1:31 PMHi guys,
I need your help. Can't find any hints for a solution.
At first same relevant informations:
I'm using jbosseap-5.0.0-GA, Icefaces 1.8.2, Seam 2.0.
Now to my problem:
I want to create a HmtlCommandButton programmatically and bind it via component binding within a template. The get-methode for the HtmlCommandButton will be called two times within the render-response phase, but the button will not be displayed. When I change the get-method in that way, that it will return a new instance of HtmlCommandButton on calling the get-method the second time, the button will be displayed.
Now to my questions:
1. Is it a solid matter of the seam/jsf lifecycle, that the get-method of the created htmlcommandbutton will be called two times?
2. What is the error?
The code:
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import org.jboss.seam.annotations.Create;
import com.icesoft.faces.component.ext.HtmlCommandButton;
import de.hpa.bpe.client.web.adm.model.PortalVO;
import de.hpa.bpe.client.web.bik.remote.IServiceRemote;
import de.hpa.bpe.client.web.common.constants.Image;
/**
* <code>BaseController</code> verwaltet und vererbt zentrale Methoden
*
*/
public class BaseStammdatenController extends BaseController {
/**
*
*/
private static final long serialVersionUID = 2501332144188314706L;
HtmlCommandButton btnSuchen;
int i = 0;
@Create
public void init() {
btnSuchen = new HtmlCommandButton();
btnSuchen.setId("btnSuchen");
btnSuchen.setImage(Image.BUTTON_SUCHEN_ENABLED);
btnSuchen.setDisabled(false);
btnSuchen.setVisible(true);
btnSuchen.setRendered(true);
}
/* Getter and Setter */
public HtmlCommandButton getBtnSuchen() {
// if (i > 0) {
// HtmlCommandButton btnSuchen = new HtmlCommandButton();
// btnSuchen.setId("btnSuchen");
// btnSuchen.setImage(Image.BUTTON_SUCHEN_ENABLED);
// btnSuchen.setDisabled(false);
// btnSuchen.setVisible(true);
// btnSuchen.setRendered(true);
//
// return btnSuchen;
// }
// i++;
return btnSuchen;
}
public void setBtnSuchen(HtmlCommandButton btnSuchen){
this.btnSuchen = btnSuchen;
}
}
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.faces.component.UIComponent;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Begin;
import org.jboss.seam.annotations.Create;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.datamodel.DataModel;
import org.jboss.seam.annotations.datamodel.DataModelSelection;
import org.jboss.seam.annotations.security.Restrict;
import org.jboss.seam.log.Log;
/**
* <code>OrganisationController</code>
*
*/
@Name("organisationController")
@Restrict("#{identity.loggedIn}")
@Scope(ScopeType.CONVERSATION)
@AutoCreate
public class OrganisationController extends BaseStammdatenController implements Serializable {
/**
*
*/
private static final long serialVersionUID = 6632033440007361948L;
@Logger
protected Log log;
public OrganisationController() {
super();
}
}
<div xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ice="http://www.icesoft.com/icefaces/component"
xmlns:s="http://jboss.com/products/seam/taglib">
<ice:panelGroup>
<ice:panelGrid
id="orgSuchenPnlGridBtn"
columns="1"
columnClasses="abZugUeberButton">
<ice:commandButton binding="#{organisationController.btnSuchen}"/>
<!--
<ice:commandButton
id="btnSuchen"
image="/images/Icon_Finden_30x30mitRahmen.bmp"
actionListener="#{organisationController.suchen}"
title="#{messages.organisationSuchen}"/>
-->
</ice:panelGrid>
</div>
Thanks in advance!
Andreas
I need your help. Can't find any hints for a solution.
At first same relevant informations:
I'm using jbosseap-5.0.0-GA, Icefaces 1.8.2, Seam 2.0.
Now to my problem:
I want to create a HmtlCommandButton programmatically and bind it via component binding within a template. The get-methode for the HtmlCommandButton will be called two times within the render-response phase, but the button will not be displayed. When I change the get-method in that way, that it will return a new instance of HtmlCommandButton on calling the get-method the second time, the button will be displayed.
Now to my questions:
1. Is it a solid matter of the seam/jsf lifecycle, that the get-method of the created htmlcommandbutton will be called two times?
2. What is the error?
The code:
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import org.jboss.seam.annotations.Create;
import com.icesoft.faces.component.ext.HtmlCommandButton;
import de.hpa.bpe.client.web.adm.model.PortalVO;
import de.hpa.bpe.client.web.bik.remote.IServiceRemote;
import de.hpa.bpe.client.web.common.constants.Image;
/**
* <code>BaseController</code> verwaltet und vererbt zentrale Methoden
*
*/
public class BaseStammdatenController extends BaseController {
/**
*
*/
private static final long serialVersionUID = 2501332144188314706L;
HtmlCommandButton btnSuchen;
int i = 0;
@Create
public void init() {
btnSuchen = new HtmlCommandButton();
btnSuchen.setId("btnSuchen");
btnSuchen.setImage(Image.BUTTON_SUCHEN_ENABLED);
btnSuchen.setDisabled(false);
btnSuchen.setVisible(true);
btnSuchen.setRendered(true);
}
/* Getter and Setter */
public HtmlCommandButton getBtnSuchen() {
// if (i > 0) {
// HtmlCommandButton btnSuchen = new HtmlCommandButton();
// btnSuchen.setId("btnSuchen");
// btnSuchen.setImage(Image.BUTTON_SUCHEN_ENABLED);
// btnSuchen.setDisabled(false);
// btnSuchen.setVisible(true);
// btnSuchen.setRendered(true);
//
// return btnSuchen;
// }
// i++;
return btnSuchen;
}
public void setBtnSuchen(HtmlCommandButton btnSuchen){
this.btnSuchen = btnSuchen;
}
}
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.faces.component.UIComponent;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Begin;
import org.jboss.seam.annotations.Create;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.datamodel.DataModel;
import org.jboss.seam.annotations.datamodel.DataModelSelection;
import org.jboss.seam.annotations.security.Restrict;
import org.jboss.seam.log.Log;
/**
* <code>OrganisationController</code>
*
*/
@Name("organisationController")
@Restrict("#{identity.loggedIn}")
@Scope(ScopeType.CONVERSATION)
@AutoCreate
public class OrganisationController extends BaseStammdatenController implements Serializable {
/**
*
*/
private static final long serialVersionUID = 6632033440007361948L;
@Logger
protected Log log;
public OrganisationController() {
super();
}
}
<div xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ice="http://www.icesoft.com/icefaces/component"
xmlns:s="http://jboss.com/products/seam/taglib">
<ice:panelGroup>
<ice:panelGrid
id="orgSuchenPnlGridBtn"
columns="1"
columnClasses="abZugUeberButton">
<ice:commandButton binding="#{organisationController.btnSuchen}"/>
<!--
<ice:commandButton
id="btnSuchen"
image="/images/Icon_Finden_30x30mitRahmen.bmp"
actionListener="#{organisationController.suchen}"
title="#{messages.organisationSuchen}"/>
-->
</ice:panelGrid>
</div>
Thanks in advance!
Andreas