Create Field to add all required field need to add a check box "cb2" as well but the caption showing on right but I need to show it on left.
public Field createField(Item item, Object property, Component uiContext) {
String pid = (String) property;
if (pid.equals("group_id")) {
try {
groupofList = new GroupEntityContainer();
groupofList = DA.getGroupList();
} catch (Exception e) {
LOGGER.log(Level.WARNING, "GroupEntityComboBox DataAccessContainer().getGroupList() failed " + e.getMessage());
}
Select select = new Select("User Role");
if (groupofList != null) {
for (int i = 0; i < groupofList.size(); i++) {
Collection<GroupEntity> ar = groupofList.getItemIds();
Iterator<GroupEntity> iterator = ar.iterator();
while (iterator.hasNext()) {
GroupEntity c = iterator.next();
select.addItem(c.getGroup_id());
select.setItemCaption(c.getGroup_id(), c.getGroupname());
}
}
select.setNewItemsAllowed(false);
select.setImmediate(true);
return select;
}
}else if(pid.equals("apply_acess_control")){
cb2=new CheckBox(pid);
cb2.setEnabled(true);
//cb2.setStyle("float:left");
ValueChangeListener listner = new ValueChangeListener() {
/**
*
*/
@Override
public void valueChange(ValueChangeEvent event) {
if(txndays !=null){
txndays.setEnabled((Boolean) event.getProperty().getValue());
//txndays.setValue(null);
}
//reengagementSelect.setVisible((Boolean) event.getProperty().getValue());
}
};
cb2.addListener(listner);
cb2.setImmediate(true);
// cb2.setCaption("apply_acess_control");
return cb2;
}
else {
TextField tx = new TextField(pid);
if(pid.equals("inactivity_days"))
{
txndays= new TextField(pid);
if(cb2.booleanValue())
{
txndays.setEnabled(true);
}else{
txndays.setEnabled(false);
txndays.setNullRepresentation("");
}
return txndays;
}
if (pid.equals("userPass"))
// tx.setSecret(true);
tx.setMaxLength(15);
return tx;
}
return null;
}
FormFieldFactory:-
public Field createField(Item item, Object property, Component uiContext) {
String pid = (String) property;
if (pid.equals("group_id")) {
try {
groupofList = new GroupEntityContainer();
groupofList = DA.getGroupList();
} catch (Exception e) {
LOGGER.log(Level.WARNING, "GroupEntityComboBox DataAccessContainer().getGroupList() failed " + e.getMessage());
}
Select select = new Select("User Role");
if (groupofList != null) {
for (int i = 0; i < groupofList.size(); i++) {
Collection<GroupEntity> ar = groupofList.getItemIds();
Iterator<GroupEntity> iterator = ar.iterator();
while (iterator.hasNext()) {
GroupEntity c = iterator.next();
select.addItem(c.getGroup_id());
select.setItemCaption(c.getGroup_id(), c.getGroupname());
}
}
select.setNewItemsAllowed(false);
select.setImmediate(true);
return select;
}
}else if(pid.equals("apply_acess_control")){
cb2=new CheckBox(pid);
cb2.setEnabled(true);
//cb2.setStyle("float:left");
ValueChangeListener listner = new ValueChangeListener() {
/**
*
*/
@Override
public void valueChange(ValueChangeEvent event) {
if(txndays !=null){
txndays.setEnabled((Boolean) event.getProperty().getValue());
//txndays.setValue(null);
}
//reengagementSelect.setVisible((Boolean) event.getProperty().getValue());
}
};
cb2.addListener(listner);
cb2.setImmediate(true);
// cb2.setCaption("apply_acess_control");
return cb2;
}
else {
TextField tx = new TextField(pid);
if(pid.equals("inactivity_days"))
{
txndays= new TextField(pid);
if(cb2.booleanValue())
{
txndays.setEnabled(true);
}else{
txndays.setEnabled(false);
txndays.setNullRepresentation("");
}
return txndays;
}
if (pid.equals("userPass"))
// tx.setSecret(true);
tx.setMaxLength(15);
return tx;
}
return null;
}
Aucun commentaire:
Enregistrer un commentaire