Restore <p:selectOneMenu> item, while editing - java

How can I bring the <p:selectOneMenu item values back while editing.Now it just showing 'Select One', and users have to select the desired one (or already submitted)again. How can I bring that?

try to remove the first f:selectItem of yours
<f:selectItem itemLabel="#{employeeView.employeeDTO.trMode}" itemValue='#{employeeView.employeeDTO.transportMode}' />
the value attribute of the <p:selectOneMenu tag will hold the selected value...
and by the way , here are several examples of it : p:selectOneMenu

Related

How to Get SelectOneRadio Value in Oracle ADF withour Value Change listener

I want to get the selected value in the SelectOneRadio in Oracle ADF jsff.
The problem is that i dont want to refer each and every click to a ValueChangeListener.
That creates a lot of server load.
is there any way to get the value selected in the radio button and display it in an output text by partially updating it and all..
I have tried multiple Blogs all referring to use of BackingBean.
Thanks in advance
You can create a binding to that component, and get it's value within the same method where the bind is. For example:
<af:selectOneRadio value="#{bindings.Deptno.inputValue}" label="Select Department"
required="true" shortDesc="#{bindings.Deptno.hints.tooltip}"
id="soc1" autoSubmit="true" binding="#{managedBeanName.selectOneRadio}>
<f:selectItems value="#{bindings.Deptno.items}" id="si1"/>
and then the bean should look like this:
import oracle.adf.view.rich.component.rich.input.RichSelectOneRadio
public class ManagedBeanName{
private RichSelectOneRadio radio;
//getters/setters for 'radio' here
public void printValue(){
System.out.println(radio.getValue());
}
The last thing would be the call to this method each time YOU want to print/get the selected value.
A call to a ValueChangeListener should not overload the server.
Try
<af:selectOneRadio value="#{bean.aValue}" id="sor1" autoSubmit="true">
<f:selectItem itemLabel="Option1" itemValue="1"/>
<f:selectItem itemLabel="Option2" itemValue="2"/>
<f:selectItem itemLabel="Option3" itemValue="3"/>
</af:selectOneRadio>
<af:outputText value="#{bean.aValue}" partialTriggers="sor1"/>
No ValueChangeListener but still a trip on the server. You can't avoid that. ADF is based on JSF and this is the way the technology works.

Not able to render the parent panel group component with <p:ajax>

I am using primefaces autocomplete in my application to suggest userIds to the User.Once user enters three characters into the Autocomplete textbox my UserIds list will be suggested to the user to Autocomplete. As soon as user selects userId from List, I am updating the User First and Last name in the Output Text in the following format John Doe(jd123) with a Delete button beside to this name. As shown in comments in the code first ajax request is perfectly working fine.But When I am trying to delete name that I am printing using <h:outputText/> I am getting an error which is
javax.faces.FacesException: Cannot find component with identifier
"items" referenced from "j_idt34:0:imgid".
My Code :
<h:outputLabel value="Select user" for="acMinLength" />
<p:autoComplete id="acMinLength"
minQueryLength="3"
value="#{autoCompleteBean.txt2}"
completeMethod="#{autoCompleteBean.complete}">
<p:ajax event="itemSelect"
listener="#{autoCompleteBean.handleSelect}"
update="items"/> // First Ajax request perfectly working fine
</p:autoComplete>
<h:outputLabel value="selectedUsers" for="acMinLength" />
<h:panelGroup id="items">
<ui:repeat value="#{autoCompleteBean.printId}" var="item">
<h:outputText value="#{item}"/>
<h:graphicImage name="delete.png" library="images" id="imgid">
<p:ajax event="click"
listener="#{autoCompleteBean.updateList}"
update="items"/> // This is where i am getting exception
</ui:repeat>
<h:panelGroup>
I know I can update the parent component with child Ajax request. But I don't know what I am doing wrong.
it should be safer to update the h:form component. I'm not sure you can update every h: component by id. If you open the resulting xhtml and try checking the actual id path of the children components, you will see that the don't include the ids of all of their parent's component. Some id's are skipped
However, you can try this
update=":#{p:component('items')}"
Hope it helps
After a rigorous search I tried the answer posted by andre here(Primefaces - Cannot find component with identifier outside the datatable) and hurray it's working.
like this
update="#([id$=items])"

Deselecting a table row in PrimeFaces

I have a table like this:
<p:dataTable id="table" selectionMode="single">
...
<p:ajax event="rowSelect" listener="#{myBean.onRowSelect}" update="someStuff"/>
<p:ajax event="rowUnselect" listener="#{myBean.onRowUnselect}" update="otherStuff"/>
</p:dataTable>
Does anyone know how to trigger the rowUnselect event on the UI ?
Another thing, what are the possible values of the selectionMode attribute ? They don't seem to be in the documentation.
Thanks,
To trigger rowUnselect, once a row is selected, hold control key and click on the row again. That way the row gets unselected, and the ajax event is executed.
Possibles values for selectionMode attribute are "single" and "multiple".

How to know which item is clicked in richfaces PickList

I am using richfaces 4.1.0M2 with JSF2.0 and I have a PickList and what I want is that when someone selects (mouse click) an item in the left list, some component in the form is updated based on what is clicked. I have managed to trigger an event in the bean whan some one clicks on an item. The code to achieve the trigger is
<rich:pickList showButtonsLabel="false" value="#{groupBean.pickListResult}"
listHeight="100" converter="#{groupBean.converter}">
<a4j:ajax event="click" render="userlist" limitRender="true" listener="#{groupBean.updateGroupMembers}"/>
<f:selectItems value="#{groupBean.leftPickList}" />
</rich:pickList>
But I am not able to get the value of SelectItem which was clicked. Any idea how I can do that. I read in the documentation that each item has three states associated with it in the PickList i.e common, selected, active. So is there a way to get these states in the bean. Any idea.
The selected value will be available in groupBean.pickListResult (on the server)
I Think you Should use onchange Event in <a:support>
ex: <a4j:ajax event="onchange" render="userlist" limitRender="true" />

can i make my dropdown box defaulted to empty and if i click on dropdown it should the values

hi my dropdown has some 3 values
1)Apple
2)mango
3)grape
when my page loads my dropdown is defaulted to Apple(first value)
how can i make dropdown defaulted to empty and when i clicked on dropdown it should show the values
in java jsf (i am getting dropdown values as List)
I would just add an empty option, and validate as needs be.
I generally add an empty field with a null ID and a value that says something like "Select Fruit". I believe you can have both selectItem and selectItems. So something like this should work inside your JSF selectOneMenu component:
<f:selectItem itemValue="" itemLabel="Select Fruit" />
<f:selectItems value="#{fruitList}" />

Categories

Resources