本文整理匯總了Java中javax.faces.event.ValueChangeEvent.getComponent方法的典型用法代碼示例。如果您正苦於以下問題:Java ValueChangeEvent.getComponent方法的具體用法?Java ValueChangeEvent.getComponent怎麽用?Java ValueChangeEvent.getComponent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.faces.event.ValueChangeEvent
的用法示例。
在下文中一共展示了ValueChangeEvent.getComponent方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: changeSelectedUnit
import javax.faces.event.ValueChangeEvent; //導入方法依賴的package包/類
/**
* This method is used to handle the value change event on radio buttons
* when using the 'Select unit for a subscription' popup.
* @param event
*/
public void changeSelectedUnit(ValueChangeEvent event) {
UIComponent uiComponent = event.getComponent();
if (!(uiComponent instanceof HtmlSelectOneRadio)) {
return;
}
HtmlSelectOneRadio radioBtn = (HtmlSelectOneRadio) uiComponent;
List<UIComponent> uiComponents = radioBtn.getChildren();
for (UIComponent component : uiComponents) {
if (!(component instanceof HtmlInputHidden)) {
continue;
}
HtmlInputHidden hiddenInput = (HtmlInputHidden) component;
long unitId = ((Long) hiddenInput.getValue()).longValue();
if (unitId == 0L) { //radio 'The subscription is not assigned...' is selected
deassignUnit();
return;
}
if (Boolean.valueOf((String) event.getNewValue()).booleanValue()) {
assignToSelectedUnit(unitId);
return;
}
for (POUserGroup unit : model.getUnits()) {
if (unit.getKey() == unitId) {
unit.setUnitSelected(false);
unit.setUnitChecked(null);
}
}
}
}
示例2: selectedOwnerChanged
import javax.faces.event.ValueChangeEvent; //導入方法依賴的package包/類
/**
* Invoke when click radio button to select subscription owner in
* subscription owner selection page
*/
public void selectedOwnerChanged(ValueChangeEvent event) {
UIComponent uiComponent = event.getComponent();
if (!(uiComponent instanceof HtmlSelectOneRadio)) {
return;
}
HtmlSelectOneRadio radioBtn = (HtmlSelectOneRadio) uiComponent;
List<UIComponent> uiComponents = radioBtn.getChildren();
for (UIComponent component : uiComponents) {
if (!(component instanceof HtmlInputHidden)) {
continue;
}
HtmlInputHidden hiddenInput = (HtmlInputHidden) component;
String ownerId = (String) hiddenInput.getValue();
if (Boolean.valueOf((String) event.getNewValue()).booleanValue()) {
if (ownerId.trim().isEmpty()) {
deassignOwner();
return;
}
setOwnerSelectedStatus(ownerId);
return;
}
for (User owner : model.getSubscriptionOwners()) {
if (owner.getUserId().equals(ownerId)) {
owner.setOwnerSelected(false);
}
}
}
}
示例3: valueChanged
import javax.faces.event.ValueChangeEvent; //導入方法依賴的package包/類
public void valueChanged(ValueChangeEvent vce)
{
Object newValue = vce.getNewValue();
UIComponent component = vce.getComponent();
String rendererType = component.getRendererType();
// For these first components the listeners have registered themselves
// by setting the partialTriggers attribute. So we just update the model.
if (rendererType.equals("org.apache.myfaces.trinidad.Checkbox"))
{
_status.setChecked((Boolean) newValue);
_status.incrementCheckBoxUpdateCount();
}
else if (rendererType.equals("org.apache.myfaces.trinidad.Radio"))
{
if (Boolean.TRUE.equals(newValue))
{
String text = (String) component.getAttributes().get("text");
_status.setSelectBooleanState(text);
}
else if (newValue instanceof String)
_status.setSelectOneState((String) newValue);
}
else if (rendererType.equals("org.apache.myfaces.trinidad.Text"))
{
if (newValue instanceof String)
_status.setTextValue((String) newValue);
}
else if (rendererType.equals("org.apache.myfaces.trinidad.Choice"))
{
if (newValue instanceof String)
_status.setChoiceInt((String) newValue);
}
// This component illustrates a method of dynamically adding a
// partialTarget (i.e. without setting the partialTriggers attribute). It
// updates a component binding and adds the updated component directly to
// the list of partial targets.
else if (rendererType.equals("org.apache.myfaces.trinidad.Listbox"))
{
_listUpdate.setValue(component.getAttributes().get("value"));
_addTarget(_listUpdate);
}
}
示例4: processFileUpload
import javax.faces.event.ValueChangeEvent; //導入方法依賴的package包/類
/**
* Creates a BufferedInputStream to get ready to upload file selected. Used
* by Add Podcast and Revise Podcast pages.
*
* @param event
* ValueChangeEvent object generated by selecting a file to
* upload.
*
* @throws AbortProcessingException
* Internal processing error attempting to set up BufferedInputStream
*/
public void processFileUpload(ValueChangeEvent event)
throws AbortProcessingException {
UIComponent component = event.getComponent();
Object newValue = event.getNewValue();
Object oldValue = event.getOldValue();
PhaseId phaseId = event.getPhaseId();
Object source = event.getSource();
// log.info("processFileUpload() event: " + event
// + " component: " + component + " newValue: " + newValue
// + " oldValue: " + oldValue + " phaseId: " + phaseId
// + " source: " + source);
if (newValue instanceof String)
return;
if (newValue == null)
return;
FileItem item = (FileItem) event.getNewValue();
String fieldName = item.getFieldName();
filename = Validator.getFileName(item.getName());
fileSize = item.getSize();
fileContentType = item.getContentType();
// log.info("processFileUpload(): item: " + item
// + " fieldname: " + fieldName + " filename: " + filename
// + " length: " + fileSize);
// Read the file as a stream (may be more memory-efficient)
try {
fileAsStream = new BufferedInputStream(item.getInputStream());
}
catch (IOException e) {
log.warn("IOException while attempting to set BufferedInputStream to upload "
+ filename + " from site " + podcastService.getSiteId() + ". "
+ e.getMessage(), e);
setErrorMessage(INTERNAL_ERROR_ALERT);
}
}