Hmm, I am a bit sceptical about making this a standard control... every time we provide "composite components" then each user has his/her specific requirements. Life is tough...
It is quite simple (...) to implement such a component with exsiting components:
(.) Button
(.) modeless popup, no decoration, close on click outside
(.) field with flush and flushtimer
(.) grid
Björn
Code:
Base Screen:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib prefix="demo" uri="/WEB-INF/democontrols"%>
<%@taglib prefix="t" uri="/WEB-INF/eclnt"%>
<!-- ========== CONTENT BEGIN ========== -->
<f:view>
<h:form>
<f:subview id="workplace_demopopupundecoratedg_sv">
<t:rowheader id="g_1">
<t:coldistance id="g_2" width="100%" />
<t:button id="g_3"
actionListener="#{wp.DemoPopupUndecorated.onOpenSearch}"
contentareafilled="false" horizontaltextposition="left"
image="/images/icons/magnifier.png" text="Search..." />
<t:coldistance id="g_4" width="200" />
</t:rowheader>
<t:rowbodypane id="g_5">
<t:row id="g_6">
<t:label id="g_7"
text="Some content... (the interesting part is the button inside the header...)" />
</t:row>
</t:rowbodypane>
<t:pageaddons id="g_pa" />
</f:subview>
</h:form>
</f:view>
<!-- ========== CONTENT END ========== -->
Code:
package workplace;
import java.io.Serializable;
import javax.faces.event.ActionEvent;
import org.eclnt.editor.annotations.CCGenClass;
import org.eclnt.jsfserver.defaultscreens.ModelessPopup;
import org.eclnt.jsfserver.elements.util.DefaultModelessPopupListener;
import org.eclnt.workplace.IWorkpageDispatcher;
@CCGenClass (expressionBase="#{wp.DemoPopupUndecorated}")
public class DemoPopupUndecorated
extends DemoBase
implements Serializable
{
public DemoPopupUndecorated(IWorkpageDispatcher dispatcher)
{
super(dispatcher);
}
public void onOpenSearch(ActionEvent event)
{
ModelessPopup popup = getOwningDispatcher().createModelessPopup();
popup.open("/workplace/demopopupundecoratedsearch.jsp","Search",250,300,new DefaultModelessPopupListener(popup));
popup.setUndecorated(true);
popup.setCloseonclickoutside(true);
}
}
Popup for search:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib prefix="demo" uri="/WEB-INF/democontrols"%>
<%@taglib prefix="t" uri="/WEB-INF/eclnt"%>
<!-- ========== CONTENT BEGIN ========== -->
<f:view>
<h:form>
<f:subview id="workplace_demopopupundecoratedsearchg_sv">
<t:rowbodypane id="g_1" padding="0">
<t:row id="g_2">
<t:pane id="g_3" border="#00000030" height="100%" padding="20"
width="100%">
<t:row id="g_4">
<t:field id="g_5"
actionListener="#{wp.DemoPopupUndecoratedSearch.onSearch}"
bgpaint="image(100%-5,50%,/images/icons/magnifier.png,rightmiddle)"
flush="true" flushtimer="1000"
text="#{wp.DemoPopupUndecoratedSearch.searchText}" width="100%" />
</t:row>
<t:rowdistance id="g_6" height="20" />
<t:row id="g_7">
<t:fixgrid id="g_8" avoidroundtrips="true" background="#ffffff40"
bordercolor="#00000010" borderheight="1" borderwidth="1"
drawoddevenrows="true" height="100%"
objectbinding="#{wp.DemoPopupUndecoratedSearch.grid}"
rowheight="18" sbvisibleamount="30" suppressheadline="true"
width="100%">
<t:gridcol id="g_9" text="Column" width="100%">
<t:label id="g_10" text=".{text}" />
</t:gridcol>
</t:fixgrid>
</t:row>
</t:pane>
</t:row>
</t:rowbodypane>
<t:pageaddons id="g_pa" />
</f:subview>
</h:form>
</f:view>
<!-- ========== CONTENT END ========== -->
Code:
package workplace;
import java.io.Serializable;
import java.util.Random;
import javax.faces.event.ActionEvent;
import org.eclnt.editor.annotations.CCGenClass;
import org.eclnt.jsfserver.elements.impl.FIXGRIDItem;
import org.eclnt.jsfserver.elements.impl.FIXGRIDListBinding;
@CCGenClass (expressionBase="#{wp.DemoPopupUndecoratedSearch}")
public class DemoPopupUndecoratedSearch implements Serializable
{
public class GridItem extends FIXGRIDItem implements java.io.Serializable
{
protected String m_text;
public String getText() { return m_text; }
public void setText(String value) { m_text = value; }
}
protected FIXGRIDListBinding<GridItem> m_grid = new FIXGRIDListBinding<GridItem>();
protected String m_searchText = "";
public String getSearchText() { return m_searchText; }
public void setSearchText(String value) { m_searchText = value; }
public FIXGRIDListBinding<GridItem> getGrid() { return m_grid; }
public void onSearch(ActionEvent event)
{
// dummy search
m_grid.getItems().clear();
int maxi = (new Random()).nextInt(20) + 2;
for (int i=0; i<maxi; i++)
{
GridItem gi = new GridItem();
gi.setText(m_searchText + " " + i);
m_grid.getItems().add(gi);
}
}
}