Code for replacing 'get' and 'set' method
Hi,
I was a struts programmer but now i am a jsf programmer :-)
I was able to do the following with struts but no with jsf...
The following code in struts allowed me to have no 'get' and 'set' method in the javabean for a property (for example, the property 'name'):
ValueStack valueStack =ActionContext.getContext().getValueStack();
valueStack.set("name", "John");
ActionContext.getContext().setValueStack(valueStack);In the jsp, using the corresponding label to retrieve the 'name' property, returned value 'John'.
Is there something equivalent in jsf?
Hi, see on here.There are solutions for JSF, JBoss Seam: [Solutions for Java, JSF, JBoss Seam and Flex|http://flextrick.blogspot.com/]
Similar Messages
-
Why do we need get and set methods?
It is considered good design practice to keep all class data private and
provide get and set methods for accessing the data in a controlled
manner.
So, instead of directly accessing the class data, you use getter and setters.
I do not really feel the need to use get and set methods.
How does that achieve encapsulation when ultimately the class data is being exposed?A couple of reasons why to use get and set:
1. For example you can set an int value for month, if a user sets this to somting
higher than 12 (or 11 if it's zero based) you want to handle that by either
throwing an exception or adding a year for every time it can be devided by 12.
If you dont do it in set you'll have a whole bunch of methods that might need to
correct the value before retreiving the eventual date.
2. If for some reason you have security set up for certain values you can
implement this in the get method. When this is done somewhere else you have
a whole bunch of methods retreiving the info in other classes that need to check
first. (a canGet method could allso be used). Another good reason to use get
is when the information needs to be converted depending on the consumer
calling the get method.
3. If any logic in 1 or 2 changes you'll have a bunch of code to change.
If you feel there is no need to implement any security, error handling (on
compiling because get and set might throw something) or validation when
setting/getting these values there is still the argument of readabillity.
Eclipse has a feature that will generate getters and setters for you so it's not
like there is a lot of extra typing involved.
Got interupted whyle typig so sorry to repeat any answer given before. -
Usage of AQ$_JMS_MESSAGE getter and setter methods in PL/SQL functions
Hi all,
while setting up a transformation from a AQ$_JMS_TEXT_MESSAGE to a user-defined type "msgtype" ( subject varchar2, text clob ) I tried to use the get_text() method within the transformation function but got a
ORA-25229: error on transformation of message msgid: ...
ORA-30625: method dispatch on NULL SELF argument is disallowedAccessing the CLOB part of the jms_text_message directly did not work. But within an anonymous PL/SQL procedure, get_text() works fine.
It has to be in a function to work as a transformation, but how can I do this?
Here's my current code:
CREATE OR REPLACE FUNCTION jms2msg_t(in_jms SYS.AQ$_JMS_TEXT_MESSAGE)
RETURN TxtMsgType AS
new_msg TxtMsgType;
v_oldmsg SYS.AQ$_JMS_TEXT_MESSAGE;
v_clob CLOB := EMPTY_CLOB;
BEGIN
dbms_lob.createTemporary( v_clob, true );
dbms_lob.open( v_clob, DBMS_LOB.LOB_READWRITE );
v_oldmsg.get_text( v_clob ); -- ora-30625 happens here ----------------
new_msg := TxtMsgType( dbms_lob.substr( in_jms.text_lob, 10 ), v_clob );
dbms_lob.freetemporary(lob_loc => v_clob);
RETURN new_msg;
END jms2msg_t;
/MetaLink, Oracle Docs and Google didn't help me. I know of the countermeasures against ORA-30625 in user defined types, but I cannot change JMS-Types, So, what could I do?
Regards,
UweGee, this was a no-brainer. Thanks to cut w/o paste, I lost the initializing line:
v_oldmsg:=in_jms;The uninitialized JMS object then throws this kind of "null pointer exception".
Well, at least I got to know a new ORA-code. ;-) -
What is get and set methods of class
I m new for OOP concept see this is my class, How this class will return values???
package poker
import com.smartfoxserver.v2.protocol.serialization.SerializableSFSType;
public class SeatInfo implements SerializableSFSType
private var _seats:Array;
private var _buyInLow:int;
private var _buyInHigh:int;
public function SeatInfo(){
public function get seats():Array{
return _seats;
public function set seats(seats:Array):void{
this._seats = seats;
public function get buyInLow():int
return _buyInLow;
public function set buyInLow(buyInLow:int):void
this._buyInLow = buyInLow;
public function get buyInHigh():int
return _buyInHigh;
public function set buyInHigh(buyInHigh:int):void
this._buyInHigh = buyInHigh;
public function toString():String
var str:String="seatinfo";
str += "amtlow" + ": " + _buyInLow + "amthig" + ": " + _buyInHigh + " :\n";
if (_seats != null)
for each (var seat:Seat in _seats)
str += "seat :" + seat.seatId +"\n"
return str;package poker
import com.smartfoxserver.v2.protocol.serialization.SerializableSFSType;
public class SeatInfo implements SerializableSFSType
private var _seats:Array;
private var _buyInLow:int;
private var _buyInHigh:int;
public function SeatInfo(){
// this returns _seats
public function get seats():Array{
return _seats;
public function set seats(seats:Array):void{
this._seats = seats;
// this returns _buyinLow
public function get buyInLow():int
return _buyInLow;
public function set buyInLow(buyInLow:int):void
this._buyInLow = buyInLow;
// this returns _buyInHight
public function get buyInHigh():int
return _buyInHigh;
public function set buyInHigh(buyInHigh:int):void
this._buyInHigh = buyInHigh;
public function toString():String
var str:String="seatinfo";
str += "amtlow" + ": " + _buyInLow + "amthig" + ": " + _buyInHigh + " :\n";
if (_seats != null)
for each (var seat:Seat in _seats)
str += "seat :" + seat.seatId +"\n"
return str;
so, in another class where you need those variable values:
import SeatInfo;
var seatInfo:SeatInfo;
var seatsVar:Array;
var buyInLowVar:int;
var buyInHighVar:int;
seatInfo = new SeatInfo();
seatsVar = seatInfo.seats;
buyInLowVar = seatInfo.buyInLow;
buyInHighVar = seatInfo.buyInHigh; -
Want to code for call transaction and session method
my requriment is i upload a data by call tran. but i want to error handling through session method pls give the code and i want to flat file also.
asap.
a.kI suggest you try fulfilling your requirements yourself and come back with specific problems along the way.
-
Statistical distributions - get and setter methods
Hi,
I found the Weibull and Cauchy class here:
http://commons.apache.org/math/api-1.1/org/apache/commons/math/distribution/CauchyDistributionImpl.html
however these distributions do not seem to have methods to pick a random number within the distribution.
Does anyone have any advise on how to do that?
Thanks,
LeneOk, I don't see a getNextValue or getNextDouble.
Did you mean inverseCumulativeProbability?
I guess I could create a random P and then look up the x at that p, to get a random value from the distribution.
Thanks,
Lene -
Bug in "Get and Set Time.vi" example for RT systems
There is a bug in "Get and Set Time.vi" that ships as an example in the "NI System Monitor" package. The routine does *NOT* return the hour correctly.
Note the string "%#H:12:39.371" as the time of day. That should be 09:12:39.371 as it was 9 AM at the time.
Mac OS X 10.8.5
LabVIEW 14-64bit
NI System Monitor 14.0.1
Pharlap RT PXI embedded system version 14.0 updated.
NOTE: it is odd that the default "New Time" has #H as the hour but that is hard wired into the VI as a sentinel case.Rahul,
It may be only in the Mac OS X code base. But since it is one of those annoying locked VIs I can't tell. Now of course this is locked because communication with the RT system is so sensitive or just plain messy. My guess is that if I thow wireshark at it I can tell you what is inside and it shouldn't be that secret.
But let me know what you find running under Mac OS X. -
Not Getting Verification Code for OpenWap, Liquoi and Connect A2 App
I Have purchased the Firefox OS phone but i am Not Getting Verification Code for OpenWap, Liquoi and Connect A2 App
Unfortunately, we do not provide support for apps. You should contact the developer of the app for more information. From what I can see, you are not getting anything from all apps. A simple thing you can to do is to reboot the phone.
To reboot your phone:
#Take the back cover of the phone off.
#Take the battery out.
#Take the SIM card and microSD card out (if applicable).
#Wait 10 seconds.
#Put the SIM card and microSD card back in (if applicable).
#Put the battery back in.
#Put the back cover back on.
#Turn the device on.
#Check if the issue you were having is still present.
Please report back to us if this solved your problem!
Thank you -
I had an itunes redemption code for a movie and got the following message, "code redemption temporarily unavailable. try again later." How do I get my movie?
Hi r.viel,
I'm sorry to hear you are having issues with your redemption code.
The following article should help you with this:
iTunes Store: Invalid, inactive, or illegible codes
If you're still unable to redeem your code after verifying the characters in the code, you'll need to contact iTunes Store Support for help. You'll need to provide a digital image of the front and back of the gift card as well as the sales receipt for the purchase of the gift card.
Contacting iTunes Store Support
Go to the iTunes support page and select your iTunes country.
From the iTunes support page, choose Contact Support on the lower-left side of the page.
Follow the instructions to get iTunes Store support assistance.
I hope this information helps ....
Have a great day!
- Judy -
Get and Set Parameter ID in BDC Call transaction
Hi all
I have written this BDC program to run a transaction eg33 to install meter. After meter get installled System generates Device location number. I need to use this device location number in calling another transaction il03. but my data fetching using get and set parameter id is not giving accurate result. Kindly check my code and suggest where should I improve. Or whatelse can I do to fullfill this type of requirement other than GET and SET PARAMETER ID.
REPORT ZAC_EG33 NO STANDARD PAGE HEADING
LINE-SIZE 100.
TABLES: EABL,
BUT000,
ZISUH0003.
DATA :
XYZ LIKE IFLO-TPLNR.
DATA: IT_STATUS TYPE ZISUH0003.
DATA: G_INDEX TYPE I,
G_START_COL TYPE I VALUE '1', "start column
G_START_ROW TYPE I VALUE '14', "start row
G_END_COL TYPE I VALUE '18', "maximum column
G_END_ROW TYPE I VALUE '75', "maximum row
G_TEXT(20), "stores error messages
G_PAGES TYPE I,
G_CURRENT_PAGE TYPE I,
G_COUNT LIKE SY-DBCNT.
data: l_file type file_table,
file1 type string,
l_title type string,
LENGTH TYPE I,
FILES type filetable,
SUBRC type i,
STR_FILE type STRING,
D_FILE type RLGRAP-FILENAME,
filename TYPE String,
L_itab_date(10).
FIELD-SYMBOLS : <FS>.
DATA: IT_EXCEL LIKE STANDARD TABLE OF ALSMEX_TABLINE WITH HEADER LINE,
IT_MESS TYPE STANDARD TABLE OF BDCMSGCOLL WITH HEADER LINE.
TYPES: BEGIN OF TY_OPEN,
HAUS LIKE REG30-HAUS,
EADAT(10),
GERAETNEU LIKE REG30-GERAETNEU,
MESSDRCK LIKE REG30-MESSDRCK,
ZWSTANDCE LIKE REG30-ZWSTANDCE,
END OF TY_OPEN.
DATA : T_ANLAGE LIKE EANLD-ANLAGE,
VSTELLE LIKE EVBS-VSTELLE,
S_ANLAGE LIKE EANLD-ANLAGE,
temp_c(7).
DATA: IT_OPEN TYPE STANDARD TABLE OF TY_OPEN WITH HEADER LINE.
DATA: BDCDATA TYPE STANDARD TABLE OF BDCDATA WITH HEADER LINE.
SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN SKIP 2.
PARAMETERS: P_FILE like RLGRAP-FILENAME OBLIGATORY.
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN END OF BLOCK 1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE .
PERFORM GET_FILE_NAME.
MOVE FILENAME TO P_FILE.
START-OF-SELECTION.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = p_file
I_BEGIN_COL = 1 "VF_START_COL
I_BEGIN_ROW = 2 "VF_START_ROW
I_END_COL = 5 "VF_END_COL
I_END_ROW = 10000 "VF_END_ROW
TABLES
INTERN = IT_EXCEL
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF IT_EXCEL[] IS INITIAL.
G_TEXT = 'No Data Uploaded'.
ELSE.
SORT IT_EXCEL BY ROW COL.
LOOP AT IT_EXCEL.
MOVE : IT_EXCEL-COL TO G_INDEX.
ASSIGN COMPONENT G_INDEX OF STRUCTURE IT_OPEN TO <FS>.
MOVE IT_EXCEL-VALUE TO <FS>.
AT END OF ROW.
IF NOT IT_OPEN IS INITIAL.
APPEND IT_OPEN." TO IT_LINE.
CLEAR IT_OPEN.
CLEAR IT_EXCEL.
ENDIF.
ENDAT.
ENDLOOP.
ENDIF.
REFRESH IT_EXCEL.
ULINE.
FORMAT COLOR 3 ON.
WRITE: /1 sy-vline ,
2 'Material No.' ,
25 sy-vline,
2 'Logs' ,
100 sy-vline.
uline.
FORMAT COLOR OFF.
PERFORM BDC_OPEN_READING.
MESSAGE S013(ZPS).
*& Form GET_FILE_NAME
text
--> p1 text
<-- p2 text
FORM GET_FILE_NAME .
REFRESH FILES.
call method cl_gui_frontend_services=>file_open_dialog
exporting
window_title = l_title
changing
file_table = files
rc = subrc
exceptions
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
others = 4.
check sy-subrc = 0.
loop at files into l_file.
str_file = l_file.
move str_file to filename.
exit.
endloop.
ENDFORM. " GET_FILE_NAME
*& Form BDC_OPEN_READING
text
--> p1 text
<-- p2 text
FORM BDC_OPEN_READING .
LOOP AT IT_OPEN.
REFRESH BDCDATA.
clear : temp_c.
move it_open-MESSDRCK to temp_c.
condense : temp_c.
PERFORM MAP1.
CALL TRANSACTION 'EG33' USING BDCDATA MODE 'A' MESSAGES INTO IT_MESS.
+***changes by added on 28/02/08 +
get parameter id 'IFL' FIELD XYZ.
PERFORM MAP2.
set parameter id 'IFL' FIELD XYZ.
++*
CALL TRANSACTION 'IL03' USING BDCDATA MODE 'A' MESSAGES INTO IT_MESS.
+****end change added on 28.02.08+DATA: G_INSNO LIKE IT_OPEN-HAUS.
IF NOT IT_MESS[] IS INITIAL.
G_INSNO = IT_OPEN-HAUS.
PERFORM GET_MESSAGES TABLES IT_MESS USING G_INSNO." IT_LINE.
ENDIF.
READ TABLE IT_MESS WITH KEY MSGTYP = 'E'.
IF SY-SUBRC NE 0.
READ TABLE IT_MESS WITH KEY MSGTYP = 'S' MSGNR = '622'.
IF SY-SUBRC EQ 0.
SELECT SINGLE VSTELLE FROM EVBS INTO VSTELLE WHERE HAUS = IT_OPEN-HAUS.
SELECT SINGLE ANLAGE FROM EANL INTO T_ANLAGE WHERE VSTELLE = VSTELLE.
MOVE T_ANLAGE TO IT_STATUS-ANLAGE.
MOVE 'X' TO IT_STATUS-RFC.
*perform get_date_format using IT_OPEN-EADAT.
MOVE IT_OPEN-EADAT TO IT_STATUS-ADATE.
SELECT SINGLE ANLAGE FROM ZISUH0003 INTO S_ANLAGE WHERE ANLAGE =
T_ANLAGE.
IF SY-SUBRC EQ 4.
INSERT ZISUH0003 FROM IT_STATUS.
ELSE.
UPDATE ZISUH0003 FROM IT_STATUS.
ENDIF.
ENDIF.
ENDIF.
REFRESH IT_MESS.
CLEAR IT_MESS.
ENDLOOP.
ENDFORM. " BDC_OPEN_READING
Start new screen *
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM.
Insert field *
FORM BDC_FIELD USING FNAM FVAL.
IF FVAL <> SPACE.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDIF.
ENDFORM.
*& Form MAP1
text
--> p1 text
<-- p2 text
FORM MAP1 .
perform bdc_dynpro using 'SAPLE30D' '0100'.
perform bdc_field using 'BDC_CURSOR'
'REG30-GERAETNEU'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'REG30-HAUS'
IT_OPEN-HAUS. "'100000000033'.
perform bdc_field using 'REG30-EADAT'
IT_OPEN-EADAT. "'18.02.2006'.
perform bdc_field using 'REG30-GERAETNEU'
IT_OPEN-GERAETNEU. "'66a'.
perform bdc_dynpro using 'SAPLE30D' '0220'.
perform bdc_field using 'BDC_CURSOR'
'REG30-TEMP_AREA(02)'.
perform bdc_field using 'BDC_OKCODE'
'=SAVE'.
perform bdc_field using 'REG30-MESSDRCK'
temp_c. "IT_OPEN-MESSDRCK'0.0125'.
perform bdc_field using 'REG30-GERWECHS'
'05'.
perform bdc_field using 'REG30-ANZDAYSOFPERIOD(01)'
'30'.
perform bdc_field using 'REG30-ZWSTANDCE(01)'
IT_OPEN-ZWSTANDCE. "'10'.
perform bdc_field using 'REG30-ZWSTANDCE(02)'
'0'.
perform bdc_field using 'REG30-PERVERBR(01)'
'0'.
perform bdc_field using 'REG30-PERVERBR(02)'
'0'.
perform bdc_field using 'REG30-TEMP_AREA(01)'
'0001'.
perform bdc_field using 'REG30-TEMP_AREA(02)'
'0001'.
perform bdc_field using 'REG30-PR_AREA_AI(01)'
'0001'.
perform bdc_field using 'REG30-PR_AREA_AI(02)'
'0001'.
ENDFORM. " MAP1
****CHANGEs added BY ALKA 28.02.08
*& Form MAP2
text
--> p1 text
<-- p2 text
FORM MAP2 .
perform bdc_dynpro using 'SAPMILO0' '1110'.
perform bdc_field using 'BDC_CURSOR'
'IFLO-TPLNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'IFLO-TPLNR'
XYZ..
perform bdc_field using 'RILO0-TPLKZ'
'AO_GP'.
perform bdc_dynpro using 'SAPMILO0' '2100'.
perform bdc_field using 'BDC_CURSOR'
'IFLO-PLTXT'.
perform bdc_field using 'BDC_OKCODE'
'=T\04'.
perform bdc_field using 'IFLO-PLTXT'
'DEVICE LOCATION'.
perform bdc_dynpro using 'SAPMILO0' '2100'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'IFLO-PLTXT'
'DEVICE LOCATION'.
perform bdc_field using 'BDC_CURSOR'
'ITOBATTR-EINZL'.
perform bdc_field using 'ITOBATTR-IEQUI'
'X'.
perform bdc_field using 'ITOBATTR-EINZL'
'X'.
ENDFORM. " MAP2
*****END CHANGE added on 28.02.08
*& Form get_date_format
text
-->P_IT_ORDER_TABLE_C_DATE text
FORM get_date_format USING L_ITAB_DATE." LIKE SY-DATUM.
data: d_temp(4),
m_temp(2),
y_temp(4).
*move L_ITAB_DATE to L_ITAB_DATE.
y_temp = L_ITAB_DATE(4).
m_temp = L_ITAB_DATE+4(2).
d_temp = L_ITAB_DATE+6(2).
CONCATENATE d_temp '.' m_temp '.' y_temp into L_ITAB_DATE.
ENDFORM. " get_date_format
*& Form GET_MESSAGES
text
-->P_IT_MESS text
-->P_G_INSNO text
FORM GET_MESSAGES TABLES IT_MESS STRUCTURE BDCMSGCOLL USING G_INSNO .TABLES T100.
DATA: L_MSTRING(255).
LOOP AT IT_MESS WHERE MSGTYP = 'E' OR MSGTYP = 'S'.
SELECT SINGLE * FROM T100 WHERE SPRSL = IT_MESS-MSGSPRA
AND ARBGB = IT_MESS-MSGID
AND MSGNR = IT_MESS-MSGNR.
IF SY-SUBRC = 0.
L_MSTRING = T100-TEXT.
IF L_MSTRING CS '&1'.
REPLACE '&1' WITH IT_MESS-MSGV1 INTO L_MSTRING.
REPLACE '&2' WITH IT_MESS-MSGV2 INTO L_MSTRING.
REPLACE '&3' WITH IT_MESS-MSGV3 INTO L_MSTRING.
REPLACE '&4' WITH IT_MESS-MSGV4 INTO L_MSTRING.
ELSE.
REPLACE '&' WITH IT_MESS-MSGV1 INTO L_MSTRING.
REPLACE '&' WITH IT_MESS-MSGV2 INTO L_MSTRING.
REPLACE '&' WITH IT_MESS-MSGV3 INTO L_MSTRING.
REPLACE '&' WITH IT_MESS-MSGV4 INTO L_MSTRING.
ENDIF.
CONDENSE L_MSTRING.
ENDIF.
CONDENSE G_INSNO.
CONCATENATE 'For' ' ' G_INSNO ',' L_MSTRING INTO L_MSTRING SEPARATED BY SPACE.
FORMAT COLOR 2 ON.
*IF IT_MESS-MSGTYP = 'S' AND IT_MESS-MSGNR = '622'.
*WRITE: 1 sy-vline,
L_MSTRING under 'Error Messages',
100 sy-vline.
*ULINE.
*ELSEIF IT_MESS-MSGTYP = 'E'.
WRITE: 1 sy-vline,
L_MSTRING under 'Logs',
100 sy-vline.
ULINE.
*ENDIF.
ENDLOOP.
ENDFORM. " GET_MESSAGESi think there might be some time gap between CALL TRANSACTION and GET PARAMETER ID.....,that is to say,the new No. has not been generated and what you fetch is an old No..
i think you should use the "CALL TRANSACTION" like the following one:
CALL TRANSACTION 'EG33' USING BDCDATA MODE 'A' UPDATE 'L' MESSAGES INTO IT_MESS .
then i think you can get the right value.
P.S: the different update model(from SAP document)
upd Effect
"A" Asynchronous update. Updates of called programs are executed in the same way as if in the COMMIT WORK statement the AND WAIT addition was not specified.
"S" Synchronous processing. Updates of the called programs are executed in the same way as if in the COMMIT WORK statement the AND WAIT addition had been specified.
"L" Local update. Updates of the called program are executed in such a way as if the SET UPDATE TASK LOCAL statement had been executed in it.
Other As for "A". -
HashSet get() and contains() methods, by value or reference?
All the tutorials I've seen on HashSets use Strings as the object type. With Strings, it seems the get() and contains() methods work by value, not by reference.
<CODE>
String s1 = "dog";
String s2 = "cat";
String s3 = "dog";
HashSet<String> set = new HashSet<String>();
set.add(s1);
System.out.println(set.contains(s1)); //true;
System.out.println(set.contains(s2)); //false
System.out.println(set.contains(s3)); //true
</CODE>
But when I use a custom object, it works by reference:
<CODE>
MyClass c1 = new MyClass("dog", 1);
MyClass c2 = new MyClass("cat", 1);
MyClass c3 = new MyClass("dog", 2);
MyClass c4 = new MyClass("dog", 1);
HashSet<MyClass> myClassSet = new HashSet<MyClass>();
myClassSet.add(c1);
System.out.println(myClassSet.contains(c1)); //true
System.out.println(myClassSet.contains(c2)); //false
System.out.println(myClassSet.contains(c3)); //false
System.out.println(myClassSet.contains(c4)); //false
</CODE>
("MyClass" is a simple class that holds a String and an int).
Is there any way I can get the set to select by value rather than reference for objects that aren't String?
If so, is it possible that the value test could be customised, so that, for example, the above will return true if the String in MyClass is the same, regardless of the int value?803559 wrote:
With Strings, it seems the get() and contains() methods work by value, not by reference.
String s1 = "dog";
String s2 = "cat";
String s3 = "dog";
System.out.println(set.contains(s1)); //true;
System.out.println(set.contains(s2)); //false
System.out.println(set.contains(s3)); //true
Is there any way I can get the set to select by value rather than reference for objects that aren't String?Warning: Never use the term "by reference" around Java geeks. It makes 'em go all green at the gills and they start muttering about 'bloody C++ crossovers'.
However, as DrClap pointed out, you've mis-diagnosed the problem:
System.out.println(s1 == s1);
System.out.println(s1 == s2);
System.out.println(s1 == s3));would print out the exact same results.
For an explanation why, Google "Java String pool" or try [url http://stackoverflow.com/questions/3297867/difference-between-string-object-and-string-literal]here.
If so, is it possible that the value test could be customised, so that, for example, the above will return true if the String in MyClass is the same, regardless of the int value?Absolutely. But, as others have said, you'd need to override equals() and hashCode().
Winston -
How do I get and set column attributes in a table or a treetable with Java?
Using 11.1.1.4.0
Hi,
How do I get and set column attributes in a table or a treetable with Java? For a simple example, say I have a table and want certain roles to see all columns (including address), and other roles can see only certain columns (no address). In a Java method, I want to test if a table's column visible attribute is true and if so, set it to false before rendering it.
Thanks in advance,
TroyHi,
this use case would be a perfect example for using seeded MDS customization. Instead of checking what users are allowed to see or not upon rendering time, you have a customization class and thus the framework doing this for you.
http://www.oracle.com/technetwork/developer-tools/adf/learnmore/31-mds-sample-169173.pdf
In this paper and sample, specific users see different layouts. It also contains a customization class that shows how this can leverage ADF Security
Frank -
Re: No G/L accounts are defined for bank ICICI and payment method C
< MODERATOR: Message locked. Please read [this|Before you post: Rules of Engagement; before posting next time. use an appropriate subject... something other than what was copied from an email would be appreciated. >
Hi Friends,
When i am doing T.Code F-58 i am getting an error of
(No G/L accounts are defined for bank ICICI and payment method C) so could anybody please help me how to solve this problem awaiting for your reply friends.
Points will be assigned.
Thanks in advance.
KUMAR.Hi Kumar,
You will have to configure the House Bank with T Code FI12 and further mention the payment method in FBZP. You will have to select one of the follwing as payment method, check/transfer/postal giro transfer/bill of exchange. Though check (C) is widely used.
Assign points, if useful.
Regards,
Saurabh Agarwal -
How do I get and set cookies with JSF?
How do I get and set cookies in a JSF managed bean?
Regards,
Al MalinBelow is how I did it...I am receptive to improvements.
FacesContext facesContext = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession)facesContext.getExternalContext().getSession(false);
HttpServletRequest request = (HttpServletRequest)facesContext.getExternalContext().getRequest();
HttpServletResponse response = (HttpServletResponse)facesContext.getExternalContext().getResponse();
String cookieName = "myCookieName";
Cookie requestCookie = null;
Cookie[] cookies = request.getCookies();
logger.info("looking for cookie...");
if (cookies != null)
for (int i = 0; i < cookies.length; i++)
if (cookies.getName().equals(cookieName))
requestCookie = cookies[i];
logger.info(cookieName + " = " + requestCookie.getValue());
logger.info("done looking for cookie");
Cookie responseCookie = new Cookie(cookieName, "myCookieValue");
responseCookie.setPath("/");
response.addCookie(responseCookie); -
I want to get and set windows system time through lab view
Hi
I want to get and set windows system time with the help of lab view 8.5.
please help me out.
ekanthYou can use the call library function node. Once you drop it on your block diagram double click it and you will be able to select the dllyou want to use. Choose kernel32.dll and you will see methods listed called getsystemtime and setsystemtime. Use those
CLA, LabVIEW Versions 2010-2013
Maybe you are looking for
-
Problem with Outlook Sync/Calendar after upgrade to 10.2
I have come up with a number of issues which may all be related. The core seems to be around the way that my Calendar and contacts are now configured. Firstly - I use BBLink to Sync. After the upgrade my 1.1.1 version of BBlink wouldn't sync to Outlo
-
Purchase order statistical delivery date modification
In a purchase order there are statistical delivery dates. Where (and how) can I go to modify how this date is calculated? I would like to change it based on the due date minus a certain amount of days. All help is appreciated.
-
How do I load a PHP without showing it at all?
Hi. I have just started working with flash a week ago, and I stumbled into a problem I cannot find the answer to anywhere so far. I created a LoadVars, which I use to send data to a PHP that updates a mysql database. This is what I am doing: button.o
-
Problem in inputting other language characters
Hello, We have a problem in displaying Canadian French character in SAP Script layout. First I installed the French (Canada) - FR as input language from Control Panel and applied the language bar tool settings. Then logged into the develpoment server
-
Hi All, how to update ABC incidator in the material master automatically, After system change the ABC incidator for all the material, execute in the T.Code MC40 do any configuration we need to do, Thanks vraj