I am working in JDeveloper 11.1.1.7.0. I am creating a simple form application in ADF.
I need to print the input values of the ADF-form in the console. For this, I used the below code.
System.out.println("It1 : " + it1.getValue());
System.out.println("si1 : " + si1.getValue());
System.out.println("soc1 : " + soc1.getValue());
The input values are getting populated in the console for RichInputText*(it1)* field and RichSelectItem*(si1)* field. But, the same is not working for RichSelectOneChoice*(soc1)* field.
How to print the value that is selected in RichSelectOneChoice*(soc1)* field.
Thanks in advance.
You don't need to bind the component to the managed bean (actually,this is considered as a bad practice), but to bind only the component values.
So, your form should consist of (for example):
<af:inputText value="#{managedBean.inputTextValue}" id="it1" />
<af:selectOneChoice value="#{managedBean.selectOneChoiceValue}" id="soc1">
<af:selectItem itemValue="first" itemLabel="First" id="si1" />
<af:selectItem itemValue="second" itemLabel="Second" id="si2" />
<af:selectItem itemValue="third" itemLabel="Third" id="si3" />
</af:selectOneChoice>
<af:commandButton actionListener="#{managedBean.printValues}" id="cb1" />
And in the managed bean you should have :
private String inputTextValue;
private String selectOneChoiceValue;
//accessors
public void printValues(ActionEvent event) {
System.out.println("Input text value: " + inputTextValue);
System.out.println("Select one choice value: " + selectOneChoiceValue);
}
Set the attribute valuePassThru to true and you should get the value of selectOneChoice as well.
Actually using the method you mentioned you should get the required selected value:
System.out.println("soc1 : " + soc1.getValue());
Related
Good morning, everyone,
I am having a problem with the handling of two checkboxes which should be mutually exclusive, on the page we cannot put an id because multiselection is provided.
enter image description here
Here the zkoss code:
<cell colspan="2">
<checkbox
label="${labels.label.giaAddebitata}"
checked="#load(each.flagAddebitata eq '1')"
onCheck="#command('addebitata', fladd=event.checked,idPer=each.idPerizia )"
onFocus="#command('manageList', idPer=each.idPerizia)"
disabled="#load(each.statoContabile eq 4 ? true : false)"/>
</cell>
<cell colspan="2">
<checkbox
label="${labels.label.nonAddebitare}"
checked="#load(each.nonAddebitare eq '1')"
onCheck="#command('nonaddebitata',flnoadd=event.checked, idPer=each.idPerizia)"
onFocus="#command('manageList', idPer=each.idPerizia)"
disabled="#load(each.statoContabile eq 4 ? true : false)"/>
</cell>
and the java functions
#Command
#NotifyChange ({ "flagAddebitata","nonAddebitare", "selectedRic"})
public void addebitata(#BindingParam("fladd") boolean fladd,#BindingParam("idPer")int idPerizia ) {
boolean addebitata = fladd;
selectedRic = new HashSet<AddebitoClienteViewDTO>();
for(AddebitoClienteViewDTO add : carList) {
if(add.getIdPerizia() == idPerizia) {
add.setFlagAddebitata(booleanToString.apply(fladd));
selectedRic.add(add);
}
}
logger.debug("SELECTEDRIC non addebitare " + selectedRic);
logger.debug("addebitata funzione " +addebitata);
}
#Command
#NotifyChange ({ "nonAddebitare", "selectedRic"})
public void nonaddebitata(#BindingParam("flnoadd") boolean flnoadd,#BindingParam("idPer")int idPerizia ) {
boolean nonaddebitata = flnoadd;
selectedRic = new HashSet<AddebitoClienteViewDTO>();
for(AddebitoClienteViewDTO add : carList) {
if(add.getIdPerizia() == idPerizia) {
add.setNonAddebitare(booleanToString.apply(flnoadd));
selectedRic.add(add);
}
}
logger.debug("SELECTEDRIC non addebitare " + selectedRic);
logger.debug("nonaddebitata funzione " +nonaddebitata);
}
We tried using the && != " the != alone and adding another binding param to the java functions.
The result we want to achieve is that if one check is clicked the other if it is already selected loses the check.
Alternatively we tried the radiogroup but it does not allow the non-selection of radioboxes, one is always mandatory.
Is there a way to clear the radiobutton without a java clear function?
Thanks
That's a lot of code and hard to turn into a reproducing case due to all of the extra objects, so I'll focus more on the functional requirement.
From your description, I understand that what you want to create is a system in which you can either select "A", "B" or "none".
There is some unspecified behavior in there (like if "A" is selected, can I select "B" and automatically clear selection on "A"? Or does having "A" selected mean that "B" is non-selectable).
From your stated requirement, the component I would choose to express that structure is a dropdown menu with 3 choices ("not selected", "A", "B"), but that might not be what you are trying to achieve with the UI design here?
If you want to make something like that using checkboxes, you may want to keep a single state for the selection status, and a command to update the selection status.
See a simple code sample here: https://zkfiddle.org/sample/hb7f7k/1-Another-new-ZK-fiddle
The left 2 checkboxes work on a "unselect others if selected" workflow.
The right 2 checkboxes work on a "cannot select others while selected, but can unselect" workflow.
Note: that sample is a "bare minimum" implementation. In a real case, you'd improve it by factorizing the code, making it into a template, etc. rather than declaring these values inline.
I'm referring to the following video How to Create A Web App With External API Access using Wix Code & wanted to know how I would populate a repeater rather than populating a paragraph tag as shown in the youtube video mentioned above.
Basically here is the pseudocode of what I would like to achieve:
If search box is equal to null or empty
Display all crypto currencie(s)
else
Display single crypto currency
Putting the info in a repeater isn't too different than what the example already shows. Actually, when the search box is empty, the API returns an array that just needs a little playing with to get it to work with a repeater.
So, assuming you added a repeater with the ID repeater1 that contains a text element with the id result, you can make the following minor changes to the page code. You don't need to touch the backend code at all.
First, in the button1_click event handler we'll remove the code that populates the text element with the data returned from the API. Instead, we'll add an _id property to each currency object (required for the repeater) and then feed that data to the repeater.
export function button1_click(event) {
getCryptoCurrencyInfo($w("#currencyInput").value)
.then(currencyInfo => {
// add an _id property to each currency object
currencyInfo.forEach(item => item._id = item.id);
// feed the data to the repeater
$w('#repeater1').data = currencyInfo;
} );
}
Then, we can take the code for populating the text element and stick it in the repeater1_itemReady event handler. This function will run once for each currency item in the array fed to the repeater's data property. Make sure you use the properties panel to wire the function to the matching repeater event.
export function repeater1_itemReady($item, itemData, index) {
$item("#result").text = "Name: " + itemData.name + "\n"
+ "Symbol: " + itemData.symbol + "\n"
+ "Rank: " + itemData.rank + "\n"
+ "Price (USD): " + itemData.price_usd + "\n"
+ "Market Capitalization (USD): " + itemData.market_cap_usd + "\n"
+ "Percent Change 1h: " + itemData.percent_change_1h + "\n"
+ "Percent Change 24h: " + itemData.percent_change_24h + "\n"
+ "Percent Change 7d: " + itemData.percent_change_7d;
}
Notice two subtle changes to the code. First, we use $item instead of $w to select the text element. This selects the specific instance of the text element in the current repeater element. Second, we use itemData instead of currencyInfo[0]. This gives us the specific data that is associated with the current repeater element.
I'm trying to fetch events from a CalDAV server using Sardine (and biweekly). Fetching an entire calendar is working for me:
Sardine sardine = SardineFactory.begin();
InputStream is = sardine.get(CALDAV_URL_STRING);
ICalendar iCalendar = Biweekly.parse(is).first();
Now I would like to fetch events for specific time range. Based on this "Building a CalDAV client" article, I assume you should use Sardines report method to do so, right?
If so, how should you use that method? It's not documented in the wiki, and the Javadoc is also not very clear.
Should I write my own SardineReport? I looks like I should end up with something like:
Sardine sardine = SardineFactory.begin();
SardineReport<List<VEvent>> report = new MyRangeReport(FROM_DATE, END_DATE);
List<VEvent> result = sardine.report(CALDAV_URL_STRING, 1, report);
Am I on the right track? Does anyone have any pointers to how to write your own Sardine report?
You are correct, to run a time range query you need to issue an HTTP REPORT request containing a calendar-query. You can find a sample in RFC 4719 Section 7.8.1. I don't know Sardine, but yes, report sounds right ;-)
Simplified even further:
REPORT /bernard/work/ HTTP/1.1
Host: cal.example.com
Depth: 1
Content-Type: application/xml; charset="utf-8"
Content-Length: xxxx
<?xml version="1.0" encoding="utf-8" ?>
<calendar-query xmlns:D="DAV:" xmlns="urn:ietf:params:xml:ns:caldav">
<D:prop>
<D:getetag/>
<calendar-data />
</D:prop>
<filter>
<comp-filter name="VCALENDAR">
<comp-filter name="VEVENT">
<time-range start="20060104T000000Z" end="20060105T000000Z"/>
</comp-filter>
</comp-filter>
</filter>
</calendar-query>
Should I write my own SardineReport?
Looks like, scanning over the GitHub of Sardine it doesn't seem to include CalDAV queries. You can probably base yours on their
SyncCollectionReport.java.
Note that the response to the calendar-query REPORT is just a regular WebDAV 207 multi-status response. Nothing extra required. (the Result object would be the same like in their SyncCollectionReport but w/o the extra syncToken).
I've implemented a report class which works, however, the result returned by Radicale seem to be incorrect. It looks like Radicale does not support the time-range filter.
For what it's worth, here are the relevant bits of the report:
public class VEventsTimeRangeSardineReport extends SardineReport<List<VEvent>>
{
...
#Override
public String toXml() throws IOException
{
// Hardcode for now
String xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" +
"<c:calendar-query xmlns:d=\"DAV:\" xmlns:c=\"urn:ietf:params:xml:ns:caldav\">\n" +
" <d:prop>\n" +
" <c:calendar-data/>\n" +
" <d:getetag/>\n" +
" </d:prop>\n" +
" <c:filter>\n" +
" <c:comp-filter name=\"VCALENDAR\">\n" +
" <c:comp-filter name=\"VEVENT\">\n" +
" <c:time-range start=\"%s\" end=\"%s\"/>\n" +
" </c:comp-filter>\n" +
" </c:comp-filter>\n" +
" </c:filter>\n" +
"</c:calendar-query>";
return String.format(xml, SDF.format(fromDate), SDF.format(toDate));
}
#Override
public List<VEvent> fromMultistatus(Multistatus multistatus)
{
List<VEvent> events = new ArrayList<>(multistatus.getResponse().size());
for (Response response : multistatus.getResponse()) {
// Here response.getPropstat().get(0).getProp().getAny().get(0).getFirstChild().getTextContent() is parsed
events.addAll(ICalendarSardineReport.getICalendar(response).getEvents());
}
return events;
}
#Override
public Object toJaxb()
{
return null;
}
}
I am running some tests to specify a value for a custom field that is already setup in quickbooks.
I cana dd the customer, but I fail to add the custom field... I think I have an issue # "FullName" in the last DataExtMod line...
Any ideas on this? I get no specific error, just an hresult.
Dim custAdd As ICustomerAdd = qbMsgReq.AppendCustomerAddRq
Dim str_name As String = "Louis Pluto Test 2 - ZA Code"
Dim str_phone As String = "0764128111"
custAdd.Name.SetValue(str_name)
custAdd.Phone.SetValue(str_phone)
custAdd.Email.SetValue("email#addy.com")
custAdd.FirstName.SetValue("myname")
custAdd.LastName.SetValue("my lastname")
custAdd.fullname.setvalue()
'add custom ID field...
Dim MyDataExtMod As IDataExtMod
MyDataExtMod = qbMsgReq.AppendDataExtModRq
MyDataExtMod.OwnerID.SetValue("0")
MyDataExtMod.DataExtName.SetValue("ID NUMBER")
MyDataExtMod.DataExtValue.SetValue("0123456789012")
MyDataExtMod.ORListTxn.ListDataExt.ListDataExtType.SetValue(ENListDataExtType.ldetCustomer)
MyDataExtMod.ORListTxn.ListDataExt.ListObjRef.FullName.SetValue(str_name)
UPDATE
My XML Responce:
MyDataExt_resp.ToXMLString "<?xml version="1.0" ?> <QBXML> <QBXMLMsgsRs> <CustomerAddRs requestID="0" statusCode="0" statusSeverity="Info" statusMessage="Status OK"> <CustomerRet> <ListID>8000051D-1369767881</ListID> <TimeCreated>2013-05-28T21:04:41+02:00</TimeCreated> <TimeModified>2013-05-28T21:04:41+02:00</TimeModified> <EditSequence>1369767881</EditSequence> <Name>Louis Test User with ID2</Name> <FullName>Louis Test User with ID2</FullName> <IsActive>true</IsActive> <Sublevel>0</Sublevel> <FirstName>Louis</FirstName> <LastName>van Tonder</LastName> <Phone>0123456789</Phone> <Email>email#addy.com</Email> <AdditionalContactRef> <ContactName>Main Phone</ContactName> <ContactValue>0123456789</ContactValue> </AdditionalContactRef> <AdditionalContactRef> <ContactName>Main Email</ContactName> <ContactValue>email#addy.com</ContactValue> </AdditionalContactRef> <Balance>0.00</Balance> <TotalBalance>0.00</TotalBalance> <JobStatus>None</JobStatus> </CustomerRet> </CustomerAddRs> <DataExtModRs requestID="1" statusCode="3120" statusSeverity="Error" statusMessage="Object "ID NUMBER" specified in the request cannot be found. QuickBooks error message: This feature is not enabled or not available in this version of QuickBooks." /> </QBXMLMsgsRs> </QBXML> " String
This part is obviously interesting... the custom field is just "ID NUMBER" , should I reference it in some other way? Naming convention?
<DataExtModRs requestID="1" statusCode="3120" statusSeverity="Error" statusMessage="Object "ID NUMBER" specified in the request cannot be found. QuickBooks error message: This feature is not enabled or not available in this version of QuickBooks." /> </QBXMLMsgsRs>
The FullName you set in your DataExt should be the same as the FullName for the customer you're creating. Otherwise, you'll be telling QuickBooks to set the custom field for some other random object.
e.g. if this is the FullName of your customer:
Dim str_name As String = "Louis Pluto Test 2 - ZA Code"
Then you should use that same FullName in your DataExt:
' This is *wrong*:
MyDataExtMod.ORListTxn.ListDataExt.ListObjRef.FullName.SetValue("Myname mylastname")
' This is correct:
MyDataExtMod.ORListTxn.ListDataExt.ListObjRef.FullName.SetValue(str_name)
I'm using GWT on the client side. I store String objects in an ArrayList instance, and when I add the value "AT&T", it only seems to be storing "AT". I suspect this is the result of the ArrayList truncating the text due to the ampersand, but I have yet to write a smaller proof-of-concept to be sure. Has anyone else encountered this problem?
GWT 2.1.1
Tomcat 7.0.5
Firefox 5.0.1
So this test succeeds:
ArrayList<String> test = new ArrayList<String>();
test.add( "testing&123");
Window.alert( test.get(0) + " - " + test.get(0).contains("&") );
My code effectively does this:
String test = "AT&T";
MyApp.getInstance().getDataStore().add( test );
Window.alert( test + " - " + MyApp.getInstance().getDataStore().getItems().get(0) );
public void DataStore.add( String item ) {
itemsList.add( item );
}
public ArrayList<String> getItems() {
return itemList;
}
The output is "AT&T - AT". So if the ArrayList is not the problem, is it the method calls?
Well, it turns out it was an interaction between my History Manager and the DataStore class. A very strange situation that no one could have helped me with given the limited amount of information I had provided.