What is Bitwise exclusive OR (XOR) ^ ?
I have a SCJP question that asks the value of 16/2^2
Can someone tell me more about this operator?
1 XOR 1 = 0
0 XOR 1 = 1
1 XOR 0 = 1
0 XOR 0 = 0put your code in a program and get the out put and then interprit the results you will be able to understand what happens behind the code
Similar Messages
-
I read the little thing for "Shift and Logical Operators" and I'm a tad confused. What exactly can you do with them? Very odd little buggers...
There are several things that bitwise shift and logical operators are useful for.
The most obvious is to test individual bits (or as an extension of this, groups of bits) within an int, long, or other numerical type value. For instance, the AWT events use flags like this extensively. Let's examine java.awt.event.InputEvent's getModifiers() method.
It returns an int value with various bits set to indicate which modifier keys (Shift, Ctrl, Alt, etc.) are depressed. One way to find out if the Ctrl key was pressed when the event was generated is to do this: (assuming this is your method implementing the KeyListener interface)
public void keyPressed(KeyEvent event) {
int modifiers = event.getModifiers();
if (modifiers & KeyEvent.CTRL_MASK != 0) System.out.println("Ctrl is pressed");
}The value of the CTRL_MASK constant is some value with only 1 bit set in it. (i.e., it is a power of 2.) So anding some value with CTRL_MASK will result in CTRL_MASK if the bit was set, or 0 if it wasn't, because all the other bits are false in the mask, so those are the only possible result of ANDing another number with it.
So the reason for using a mask in cases like this instead of just a bunch of booleans reduces memory usage significantly. (I believe a boolean in Java takes up a full 32-bit word. Anyone care to confirm or deny this?)
Bit operations are also extremely helpful when interfacing to a device, or calling native code, or reading data files, or processing image data.
Secondly, bitwise shifts and mask operations are much faster ways to do divide, multiply, and modulo operations by powers of 2. For instance:
n % 16 == n & 15 // 15 in binary: 1111, this just discards (=0) higher bits
n % 256 == n & 255 // 255 in binary: 1111 1111, same: masks off high bits
n / 2 == n >> 1
n / 4 == n >> 2
n / 8 == n >> 3
n / 16 == n >> 4
n / 256 == n >> 8
n * 2 == n << 1
n * 4 == n << 2
n * 8 == n << 3
n * 16 == n << 4
// etc.Hope this provides some insight into the common uses of bitwise operators. Understanding binary arithmetic turns out to be extremely useful. It's worth spending some time with the various operators and learning how they work.
(Also, I didn't mention the lesser-known '>>>' operator, known as the unsigned right shift. Of course if you don't have a good grasp on twos-complement binary notation, the purpose of this operator won't make sense. I don't know what a good source on this subject is off the top of my head, but if you're interested, I'm sure someone can recommend something.)
Cheers,
Colin -
What is the exclusive criteria showing the UDB is in on-line backup mode?
We have a DB:
1) DB13 shows no backup scheduled at all;
2) LOGARCHMETH1 is pointing to a disk
3) DB14 shows there is a backup history (do not know is online OR offline);
4) no cron job for db2sid or sidadm defined at all.
How to tell
1) is this DB configured to do online backup;
2) is this very moment the DB has a backup running right now?
Thanks a lot!Hello Jennifer
1)
DB2 is capable of doing online backups when log file archiving is enabled, meaning LOGARCHMETH1 is set to a valid destination. In your case it is DISK, and a file system or directory.
You can check it by forcing a log file archive with the archive log command
2)
You can monitor backups in progress with the LIST UTILITIES command
As an alternative, "db2pd -db -util" also will work.
The following paper probably is of interest for you:
A Practical Guide to Backup and Recovery of IBM DB2 for Linux, UNIX and Windows in SAP Environments Part 1: Backup and Recovery - Overview
Regards, Hans-Jürgen -
Hello,
Dose anyone know how to get Exclusive Or (Xor) on array of U8 elements
in LabVIEW?
Avivit
[email protected]Avivit Noiman wrote:
> Hello,
>
> Dose anyone know how to get Exclusive Or (Xor) on array of U8 elements
> in LabVIEW?
>
> Avivit
> [email protected]
Create a for loop with a shift register. Initialize the shift to zero.
Feed the array in (let it autoindex) use the XOR function to
xor the shift with the U8 value, stuff into the shift register.
This will XOR all the values of the array together, and give a single value
I think this is what you want.
Kevin Kent
Attachments:
Kevin.Kent.vcf 1 KB -
Good day. I want to know more about bitwise logic. I understand in Java what the bitwise operands do. What I can't seem to find is instruction on when you would want to use them. I tend to see them used rarely in code examples. Is bitwise manipulation out dated?
All omy Googling simply returned examples of bitwise logic but not what I am looking for. I guess I need bit 101.
Thanks.. What I can't seem to find is instruction on when
you would want to use them. I tend to see them used
rarely in code examples. Is bitwise manipulation out
dated? its not outdated at all, the lower programing languages use them a lot more though then higher languages like java though. the advantage of them is that they are incredibly fast, a processor can do a bit shift or xor operation easily while things like a multiplication is very slow and complicated. If your looking for a java example look at the Random class though. Id suggest just learning simple binary operations(add,subtract), after that it takes about 20 minutes to learn bitwise operations. simple uses are like using a bitshift instead of *2 as if its something thats repeated a lot it can help with performance, although i think the compiler may pick this up.
In java it is not necessary to learn this, but it can be a fun thing to make ur code hard to read(hey, its hard to write right?) or give different options for doing the same thing. -
Error with butwise xor in update statement
Hi
What is the corresponding of ^(xor) in oracle .The below is the mysql scripte
UPDATE fvmaptsqnug SET FTQQZNUGFVMPRSG = FTQQZNUGFVMPRSG ^ 1 WHERE EIJTQQVWPRSKHF = 1 AND EWJUSGFTTKVF = 1;
So can anyone help me in converting the above script to oracle.
Thanking you in advance
dinnyhi
I changed the script to
UPDATE fvmaptsqnug SET FTQQZNUGFVMPRSG = (FTQQZNUGFVMPRSG - 2 * bitand(FTQQZNUGFVMPRSG, 0)) WHERE EIJTQQVWPRSKHF = 1 AND EWJUSGFTTKVF = 1;
It is working but still iam not still very sure whether it is correct
regards
dinny -
Cindition exclusion in pricing?
Gurus
Please can any body help me to under stand what exactly condition exclusion in pricing.
I spend lot of time on it but I didn't undersantd from bussiness and also configuration.
exclusion for -
>condiion type or for condition record or for access sequence?
Please any body can send with an example that would be really appreciate?
Please don't give me on line example.
Thanks
Kris - [email protected]Hi Kris,
Condition Exclusion For Groups Of Conditions
If several condition records are valid for pricing in a document item, you can define rules that specify which condition records are not included. You use condition exclusion for this purpose.
You control condition record exclusion using exclusion groups. An exclusion group is a list of condition types which are compared with each other during pricing and result in the exclusion of an entire group or individual condition types within a group.
Thus, the result of pricing can be influenced with regard to a required criterion (for example, best price) by excluding certain condition types while others are taken into account during pricing.
Example
You can define a condition exclusion which determines the best price for the customer and excludes other less favorable results of pricing. The best price then reverses the priority of condition types which would have been predefined by the access sequence.
The procedure according to which the selection is carried out within or between the condition exclusion groups is defined in the pricing procedure. The following options are possible:
Selection of the most (least) favorable condition type within a condition exclusion group
Selection of the most (least) favorable condition record of a condition type, if more valid condition records exist (for example, selection from different condition records of the condition type PR00)
Selection of the most (least) favorable of two condition exclusion groups (in this case, all condition types of the two groups are cumulated and the totals are compared)
Exclusion procedure: If a condition type in the first group exists in the document, all condition types in the second group are set to inactive.
The tables for condition exclusion are empty when delivered. You therefore have to carry out the following steps if you want to use condition exclusion:
OV31 --- Define condition exclusion groups
OV32 --- Assign Condtion types to exclusion groups.
VOK8 --- Maintain conditoin exclusion groups for pricing procedure.
At T.Code VOK8 you can have therse options configured.
A Best condition between condition types
B Best condition within the condition type
C Best condition between the two exclusion groups
D Exclusive
E Least favorable within the condition type
F Least favorable betweent the two exclusion groups
Hope this gives the information reqarding conditon exclusion groups.
Pl Reward if it helps.
Thanks & Regards
Sadhu Kishore -
What has happened to iTunes DJ in version 11?
I just upgraded to iTunes version 11. It is very different then earlier versions and iTunes DJ appears to have been removed. This is what I use exclusively to play music so I am disappointed to see it gone. Does anyone know of an equivalent feature in version 11? If not, is there any way to go back to version 10?
http://news.cnet.com/8301-13579_3-57556548-37/7-features-apple-killed-off-in-itu nes-11/ including DJ. They replaced it with "up next" which many don't see as a substitute.
http://www.google.com/search?q=itunes+11+up+next
Downgrading is up to you:
=Downgrading from iTunes 11 to iTunes 10.7=
You may be able to go back with Time Machine but this may involve restoring other items too (https://discussions.apple.com/message/20441404). Alternatively:
Back up your computer first, in case the unexpected happens.
Quit iTunes.
Get iTunes 10.7 from http://support.apple.com/kb/DL1576 or the direct download link at: http://appldnld.apple.com/iTunes10/041-7195.20120912.d3uzQ/iTunes10.7.dmg
Do a few preparatory steps by making sure all iTunes components are not running and cleaning old files. See https://discussions.apple.com/message/20475394. Do steps 3 and 4. Steps 6-8 may be also useful but I don't know if they are essential. Some of the other steps are not necessary, duplicate steps listed later in my post or are perhaps even unhelpful in the process.
Replace the iTunes 11 application with iTunes 10.7. Simply dragging the application to the trash may not work. Lion (OSX 10.7) and newer systems have iTunes integrated into the operating system and deleting is a bit more involved. Two ways to do this are:
1. Use the shareware Pacifist utility (http://www.charlessoft.com/) to install iTunes 10.7 including all associated system files. Details at http://forums.macrumors.com/showpost.php?p=16400819&postcount=6
2. Check this reference on how to delete the iTunes application itself:
Delete iTunes in Mac OS X 10.7 Lion - http://osxdaily.com/2011/09/13/delete-itunes-in-mac-os-x-10-7-lion/
After deleting the application there may be other files that need downgrading too. See the note about error -42408 at the end of this post. You may want to tuck these away somewhere safe until you have completed the installation of iTunes 10.7. I have not tested this but ideally if newer versions are not found then the installer will put in the old versions. This may include these files in /System/Library/PrivateFrameworks/ which apparently get updated by iTunes 11:
AirTrafficHost.framework
CoreFP.framework
DeviceLink.framework
iTunesAccess.framework
MobileDevice.framework
After doing one of the two procedures above you will have to rescue the most recent old iTunes library from your iTunes > Previous Libraries folder. Rename it "iTunes Library.itl" and replace the existing one in the iTunes folder. A newer version of iTunes irreversibly updates your library file so you have to replace it with the old one or you will get an error message. Note, this will revert your library to the version at the time of the upgrade and you will have to update any changes made since. See:
https://discussions.apple.com/message/20401436 - turingtest2 11/2012 post on rebuilding empty/corrupt library from previous iTunes library file after upgrade/crash.
iTunes: How to re-create your iTunes library and playlists - http://support.apple.com/kb/ht1451
Other issues:
- https://discussions.apple.com/message/20432309 - solution to mobile devices saying they need to be restored after downgrading
- If you encounter error -42408:
iTunes: Advanced iTunes Store troubleshooting - http://support.apple.com/kb/TS3297 > Specific Conditions and Alert Messages: (Mac OS X / Windows) - including specific error codes.
Alternatively, check https://discussions.apple.com/message/20441424 which requires you have a Time Machine backup (though possibly if you remove the newer version of these files old ones may be installed with the iTunes 10.7 installer - untested). A variant of this is at: https://discussions.apple.com/message/20448184
- Persistent "Show in iTunes Store" arrows after downgrade - https://discussions.apple.com/thread/4567064 -
Antivirus software exclusions for DFS and Hyper-V
I am rolling out an updated antivirus solution to our DFS server and Hyper-V (Windows 2008 and 2012) and I am curious of the following:
1. What are the exclusion suggestions for Hyper-V servers? I found a URL that showed the exceptions to add but I thought there would be more for Hyper-V to exclude.
2. What are the specific exclusions to include for a DFS server? I read somewhere that there were some DFSR hidden folders that need to be included but I would like to know if there is an official suggestion from Microsoft of what files/folders need
to be excluded.Hi,
Anti-virus software should exclude Hyper-V specific files which listed in the article below:
Hyper-V: Anti-Virus Exclusions for Hyper-V Hosts
http://social.technet.microsoft.com/wiki/contents/articles/2179.hyper-v-anti-virus-exclusions-for-hyper-v-hosts.aspx
For the DFS antivirus exclusion, you could refer to the article below:
Virus scanning recommendations for Enterprise computers that are running currently supported versions of Windows
http://support.microsoft.com/kb/822158/en-us
Regards,
Mandy
We
are trying to better understand customer views on social support experience, so your participation in this
interview project would be greatly appreciated if you have time.
Thanks for helping make community forums a great place. -
Hi,
While going through some blogs i came across the term 'Mutually Exclusive Dimension'. Referred DBAG but found nothing on this.
Can anyone let me know, what is mutually exclusive dimension and why are they used.
Thanks in advance...Whoops, reread (good grief, you'd think I'd do that from the beginning and save myself time) and not "DBAG" but "blog". How did I do that? I have no idea.
What blogs?
I think of mutually exclusive dimensions as dimensions that maybe shouldn't be in the same database because it leads (as Glenn noted) to dimensional irrelevancy. I see it happen a lot at the Accounts/Measure level where there are expenses, revenues, etc. that simply don't apply to some dimensions.
Where did you find that in the DBAG?
I just searched the 11.1.2.2 pdf version and found two references to "mutually exclusive":
--1) Page 954, re date-time calendars--
--2) Page 965, re exclusive ASO operations--
Regards,
Cameron Lackpour
Edited by: CL on Jul 17, 2012 9:46 AM -
Error in the standard htmlb.jar from EP6 SP9 (HTMLx)
I've successfully migrated my custom developed applications from EP5 SP5 to EP6 SP9. I've used the well known 3rd party
HTMLxframework for the DatePicker and Locale corrections only (I am a brazilian developer).
In the org.sapportals.htmlb.rendering there is a class named RenderUtil.
This class has two places with this specific code:
ResourceBundle r = ResourceBundle.getBundle("java.text.resources.LocaleElements", locale);
Which is very wrong as the "java.text.resources.LocaleElements" is available only until j2sdk 1.3. In the EP5 that runs under 1.3 there's no problem but EP6 uses j2sdk 1.4 and this packages has been relocated from the standard package to a "ext" (extension) package and been renamed as "sun.text.resources.LocaleElements".
So, as HTMLx uses this RenderUtil class, I had to decompile the original from the htmlb.jar using JAD and corrected the above line with the following new line or code:
ResourceBundle r = ResourceBundle.getBundle("sun.text.resources.LocaleElements", locale);
More than that, I had to change several places of the HTMLx's HxInputFieldRenderer to reflect the class name changes made to the CSSs of the EP6. In the new version SAP does not open a pop-up window for the DatePicker. Instead they chose to rewrite it as a dynamic layer. So the HTMLx code has to change to reflect that.
Here follows the workaround version of HxInputFieldRenderer.java (notice that some strings are not internationalized, I just copied and pasted the parts I needed, so it's not a definitive version, but will help you get a clue of what to do):
* HxInputFieldRenderer.java
* Copyright (C) 2003 Alan Hobbs
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package org.open.sapportals.htmlx.rendering;
import javax.servlet.jsp.PageContext;
import org.open.sapportals.htmlx.HxField;
import org.open.sapportals.htmlx.HxInputField;
import org.open.sapportals.htmlx.HxLocaleUtil;
import com.sapportals.htmlb.Component;
import com.sapportals.htmlb.Form;
import com.sapportals.htmlb.InputField;
import com.sapportals.htmlb.enum.DataType;
import com.sapportals.htmlb.enum.InputFieldDesign;
import com.sapportals.htmlb.enum.ResourceType;
import com.sapportals.htmlb.rendering.DefaultInputFieldRenderer;
import com.sapportals.htmlb.rendering.IPageContext;
import com.sapportals.htmlb.type.AbstractDataType;
import com.sapportals.htmlb.type.DataDate;
import com.sapportals.htmlb.type.DataString;
import com.sapportals.htmlb.type.Date;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.component.IPortalComponentResponse;
import com.sapportals.portal.prt.logger.ILogger;
import com.sapportals.portal.prt.runtime.PortalRuntime;
import com.sapportals.portal.prt.service.urlgenerator.IUrlGeneratorService;
import com.sapportals.portal.prt.service.urlgenerator.specialized.IPortalUrlGenerator;
import com.sapportals.portal.prt.service.urlgenerator.specialized.ISpecializedUrlGenerator;
* @author Alan.Hobbs
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
* Render the HxInputField.
* Version Date Author Description
* 0.1.0 1-Aug-2003 AHobbs Origional
* 0.1.0 4-Aug-2003 AHobbs Added resource bundle
* 0.1.1 6-Aug-2003 AHobbs Write hidden fields to store the locale
* 0.1.1 8-Aug-2003 AHobbs Don't show the date picker button if the field is disabled
* 0.1.2 10-Aug-2003 AHobbs Only generate the month and day name javascript once per form
* 1.1.0 1-Apr-2004 AHobbs Added render methods to allow a HTMLB InputField
* to be used instead of a HxInputField
* 1.1.0 6-Apr-2004 AHobbs Changed the names for the hidden fields to "_HTMLX_xxxxx"
* 1.1.0 20-Apr-2004 AHobbs Allow debug code to be written to the console with System.out.println()
* 1.3.0 4-May-2004 AHobbs Added PopUp rendering
public class HxInputFieldRenderer extends DefaultInputFieldRenderer {
protected ILogger m_logger = PortalRuntime.getLogger("htmlx");
private static boolean writingDebugToConsole;
public HxInputFieldRenderer() {
super();
public void render(Component component, IPageContext pc)
m_logger.info("Entry: HxInputFieldRenderer.render()");
if (!(component instanceof HxInputField)) {
m_logger.warning(
"HxInputFieldRenderer.render() component is not instanceof HxInputField " +
"(component.getClass().getName()='" + component.getClass().getName() + "')");
return;
HxInputField inf = (HxInputField)component;
DataType type = inf.getType();
if (writingDebugToConsole) {
System.out.println("Start rendering HxInputField (id='" + inf.getId() + "') ...");
m_logger.info(" id='" + inf.getId() + "'");
m_logger.info(inf.toString());
/* Only include for PDK version 5.0.5.0 and above - may not be required ???
// m_logger.info(" VersionInfo.getVersion()='" + VersionInfo.getVersion() + "'");
// if (VersionInfo.?????) {
// if (pc.isUsingSession() && !inf.isVisible() && inf.getParkInSession()) {
// String uniqueName = pc.getParamIdForComponent(inf);
// Object value = inf.getValue();
// String valueString = null;
// if (value != null) {
// if (value instanceof AbstractDataType) {
// AbstractDataType dataValue = (AbstractDataType)value;
// if (dataValue != null)
// if (dataValue.isValid())
// valueString = dataValue.toString(pc);
// else
// if (dataValue instanceof DataString)
// valueString = dataValue.toString(pc);
// else
// valueString = dataValue.getValueAsString();
// else {
// valueString = value.toString();
// else {
// valueString = "";
// pc.getParamList().put(uniqueName, valueString);
// return;
boolean showDateHelp = false;
if (DataType.DATE.equals(type)
&& inf.isShowHelp()
&& !inf.isDisabled()) {
showDateHelp = true;
boolean showPatternHint = false;
if (inf.isShowPatternHint()
&& (DataType.DATE.equals(type)
|| DataType.TIME.equals(type))
|| ((inf.getPatternHint() != null) && (inf.getPatternHint().length() > 0))) {
showPatternHint = true;
boolean showStatusMsg = false;
if (inf.isShowStatusMsg() && (inf.getStatusMsg() != null) && (inf.getStatusMsg().length() > 0)) {
showStatusMsg = true;
if (showDateHelp || showPatternHint || showStatusMsg) {
pc.write("<table cellspacing="0" cellpadding="0" border="0" id="");
pc.write(""><tr><td>");
String uniqueName = pc.getParamIdForComponent(inf);
if (inf.isVisible()) {
pc.write("<span id="");
pc.write(uniqueName);
pc.write("-r" class="urEdfHelpWhl">");
if (inf.isPassword())
pc.write("<input type="password" class="sapEdf");
else
pc.write("<input type="text" class="sapEdf");
if (inf.isInvalid())
pc.write("i");
if (inf.isRequired())
pc.write("Req");
else
pc.write("Txt");
if (inf.isDisabled())
pc.write("Dsbl");
else
pc.write("Enbl");
if (inf.getDesign() == InputFieldDesign.SMALL)
pc.write("Sml");
pc.write("" autocomplete="off");
int mySize = inf.getSize();
if (mySize > 0) {
pc.write("" size="");
pc.write(mySize);
int maxlength = inf.getMaxlength();
if (maxlength > 0) {
pc.write("" maxlength ="");
pc.write(maxlength);
java.lang.String value = inf.getWidth();
if (value != null && !"".equals(value)) {
pc.write("" style="width:");
pc.write(value);
pc.write(";");
java.lang.String tooltip = inf.getTooltip();
if (tooltip != null) {
pc.write("" title="");
pc.writeEncoded(tooltip);
pc.write(" onchange="return htmlbDoEvent(this,'TV','onchange','0','");
pc.write(uniqueName);
pc.write("',1,1,'',0);" ");
pc.write(" onblur="return htmlbDoEvent(this,'TV','onblur','0','");
pc.write(uniqueName);
pc.write("',1,1,'',0);" ");
if(inf.isDisabled())
pc.write("" readonly="");
else {
pc.write("<input type="hidden");
pc.write("" name="");
pc.write(uniqueName);
if (inf.isLabeled()) {
pc.write("" id="");
pc.write(uniqueName);
Object value = inf.getValue();
pc.write("" value="");
if (value != null) {
String valueString = null;
if (value instanceof AbstractDataType) {
m_logger.info("-- Abstract Data Type");
AbstractDataType dataValue = (AbstractDataType)value;
if (dataValue != null) {
m_logger.info("-- dataValue != null");
if (dataValue.isValid()) {
m_logger.info("-- dataValue.isValid()");
if (dataValue instanceof DataDate) {
m_logger.info("-- dataValue instanceof DataDate");
Date date = ((DataDate)dataValue).getValue();
valueString = HxLocaleUtil.formatDate(date, pc.getLocale());
else {
m_logger.info("-- NOT dataValue instanceof DataDate");
valueString = dataValue.toString(pc);
else if (dataValue instanceof DataString) {
m_logger.info("-- dataValue instanceof DataString");
valueString = dataValue.toString(pc);
else {
m_logger.info("-- dataValue.getValueAsString()");
valueString = dataValue.getValueAsString();
else {
// Not Abstract Data Type
m_logger.info("-- Not Abstract Data Type");
valueString = value.toString();
pc.writeEncoded(valueString);
pc.write(""/>");
if (showDateHelp) {
String dateFormat = HxLocaleUtil.getSapDatePatternNumber(pc.getLocale());
pc.write("</td><td align='left'><button id='");
pc.write(uniqueName);
pc.write("-btn' type="button" tabindex="-1" ti="-1" class="urEdfHlpDate" onclick="htmlb_showDateHelp(event,'");
pc.write(uniqueName);
pc.write("','");
pc.write(dateFormat);
pc.write("','1')"></button>");
pc.write("<script>htmlb_addTexts('pt_BR',{SAPUR_OCTOBER:"Outubro",SAPUR_MSG_LOADING:"Processo de carga em andamento"," +
"SAPUR_SUNDAY_ABBREV:"Do",SAPUR_F4FIELD_TUTOR:"Pressionar F4 para exibir as entradas possíveis"," +
"SAPUR_INVALID:"Não válido",SAPUR_FEBRUARY:"Fevereiro",SAPUR_F4FIELD:"F4- campo de entrada"," +
"SAPUR_FRIDAY_ABBREV:"6ª",SAPUR_WEDNESDAY_ABBREV:"4ª",SAPUR_MAY:"Maio",SAPUR_MSG_WARNING:"Advertência"," +
"SAPUR_DECEMBER:"Dezembro",SAPUR_SEPARATOR:"-",SAPUR_MSG_SUCCESS:"Com êxito",SAPUR_SATURDAY_ABBREV:"Sa"," +
"SAPUR_THURSDAY_ABBREV:"5ª",SAPUR_MSG:"{0} {1} {2}",SAPUR_BUTTON_WHL:"{0} - {1} - {2} - {3}",SAPUR_JULY:"Julho"," +
"SAPUR_APRIL:"Abril",SAPUR_FIELD_TIME:"Hora",SAPUR_MSG_ERROR:"Erro",SAPUR_REQUIRED:"Necessário"," +
"SAPUR_BUTTON_WHL3:"{0} - {1} - {2}",SAPUR_SEPTEMBER:"Setembro",SAPUR_NOVEMBER:"Novembro",SAPUR_AUGUST:"Agosto"," +
"SAPUR_JANUARY:"Janeiro",SAPUR_BUTTON:"Botão",SAPUR_FIELD_PW:"Senha",SAPUR_FIELD:"Texto editável"," +
"SAPUR_DISABLED:"Não disponível",SAPUR_FIELD_DATE:"Data",SAPUR_MARCH:"Março",SAPUR_FIELD_NUMBER:"N°"," +
"SAPUR_MSG_STOP:"Stop",SAPUR_BUTTON_WHL4:"{0} - {1} - {2} - {3}"," +
"SAPUR_BUTTON_ENABLED:"Para ativar, utilizar a barra de espaço",SAPUR_TUESDAY_ABBREV:"3ª",SAPUR_READOLNY:""," +
"SAPUR_MSG_JUMPKEY:"Pressionar a barra de espaço para navegar para o campo correspondente",SAPUR_JUNE:"Junho"," +
"SAPUR_MONDAY_ABBREV:"2ª"});</script>");
if (showPatternHint) {
String pattern = "";
String patternTooltip = "";
if (DataType.DATE.equals(type)) {
pattern = HxLocaleUtil.getDatePatternInLocaleLanguage(pc.getLocale());
patternTooltip = HxLocaleUtil.formatHxMsg(pc.getLocale(), "HxInputField.DatePatternTooltip", pattern);
else if (DataType.TIME.equals(type)) {
pattern = HxLocaleUtil.getTimePatternInLocaleLanguage(pc.getLocale());
patternTooltip = HxLocaleUtil.formatHxMsg(pc.getLocale(), "HxInputField.TimePatternTooltip", pattern);
pattern = " " + pattern;
else if ((inf.getPatternHint() != null) && (inf.getPatternHint().length() > 0)) {
pattern = " " + inf.getPatternHint();
patternTooltip = HxLocaleUtil.formatHxMsg(pc.getLocale(), "HxInputField.PatternTooltip", pattern);
pc.write("</td><td align='left'>");
pc.write("<span class='sapTxtLeg' title='" + patternTooltip + "'><nobr>");
pc.write("<font color='666666' face='Microsoft Sans Serif' style='vertical-align:super' size='1'><b>" + pattern + "</b></font>");
pc.write("</nobr></span>");
if (showStatusMsg) {
if (inf.getStatusMsgPosition().equalsIgnoreCase("RIGHT")) {
pc.write("</td><td align='left'>");
pc.write("<font color='990000' face='Microsoft Sans Serif' size='1'>");
else if (inf.getStatusMsgPosition().equalsIgnoreCase("BELOW")) {
pc.write("</td></tr><tr>");
if (showDateHelp && showPatternHint) {
pc.write("<td align='left' colspan='3'>");
else if (showDateHelp ^ showPatternHint) { // '^' is Exclusive OR (XOR)
pc.write("<td align='left' colspan='2'>");
else {
pc.write("<td align='left'>");
pc.write("<font color='990000' face='Microsoft Sans Serif' style='verticle-align:super' size='1'>");
pc.write("<nobr>" + inf.getStatusMsg() + "</nobr>");
pc.write("</font>");
if (showDateHelp || showPatternHint || showStatusMsg) {
pc.write("</td></tr></table>");
// Generate code to store the current Locale in the HTML form,
// and make the month and day names available in javascript arrays.
// The form's Language attribute is used as a flag so that this is only
// done once for each form.
Form form = pc.getCurrentForm();
if ((form.getLanguage() == null)
|| (!form.getLanguage().equals(pc.getLocale().toString()))) {
// Save the locale in the html form as hidden fields so that the
// same locale can be used to parse returned data.
pc.write("<input type="hidden" name="_HTMLX_LANGUAGE_" value="" + pc.getLocale().getLanguage() + "">");
pc.write("<input type="hidden" name="_HTMLX_COUNTRY_" value="" + pc.getLocale().getCountry() + "">");
pc.write("<input type="hidden" name="_HTMLX_VARIANT_" value="" + pc.getLocale().getVariant() + "">");
// Write javascript arrays of month and day names in the locale language
StringBuffer sb = new StringBuffer(250);
String javaScriptPath = pc.getJavascriptPath();
sb.append("var javaScriptPath='");
sb.append(javaScriptPath);
sb.append("';");
java.lang.String dayNames[] = RenderUtil.getDayAbbreviations(pc.getLocale());
if (dayNames.length != 7) {
throw new IllegalStateException("Only locales with 7 days are supported!");
sb.append("var htmlbDayNames = new Array('");
for (int i = 0; i < 6; i++) {
sb.append(dayNames<i>);
sb.append("','");
sb.append(dayNames[6]);
sb.append("');n");
sb.append("var htmlbMonthNames = new Array('");
java.lang.String monthNames[] = RenderUtil.getMonthNames(pc.getLocale());
for (int i = 0; i < 11; i++) {
sb.append(monthNames<i>);
sb.append("','");
sb.append(monthNames[11]);
sb.append("');n");
java.lang.String jscript = sb.toString();
pc.getDocument().getIncludes().addBodyEndResource(ResourceType.DIRECTJSCRIPT, "HTMLB_INPUTFIELD_DATEHELP", jscript);
// Set the language in the form so we don't do this again
form.setLanguage(pc.getLocale().toString());
if (writingDebugToConsole) {
System.out.println("Finished rendering HxInputField (id='" + inf.getId() + "')");
m_logger.info("Exit: HxInputFieldRenderer.render()");
// Methods to allow the Standard HTMLB InputField to Mimic HxInputField
// The key idea here is to use the standard InputField ONLY as a String
// field (never Date) so that we have total control over the display format
// and then HTMLX looks after ofrmating the string, abd displaying the
// help icons, status messages etc.
* Render the HTML placed before a HTMLB InputField, an InputField,
* and the code placed after the InputFIeld, so that it behaves like a
* HTMLX HxInputField
* @param field
* @param pc
public static InputField mimicRender(HxField hxField, IPageContext pc) {
HxInputField hxInputField = new HxInputField(hxField, pc.getLocale());
return mimicRender(hxInputField, pc);
* Render the HTML placed before a HTMLB InputField, an InputField,
* and the code placed after the InputFIeld, so that it behaves like a
* HTMLX HxInputField
* @param field
* @param pc
public static InputField mimicRender(HxInputField hxInputField, IPageContext pc) {
// Render stuff before InputField
renderBeforeInputTag(hxInputField, pc);
// Render InputField
InputField inputField = new InputField(hxInputField.getId());
setUpInputField(hxInputField, inputField, pc);
// This is a kludge to make a field read only. It is achieved by
// adding the flag to the 'width' attribute. HTMLB then unknowingly
// adds the flag when it renders the 'width' attribute.
if (hxInputField.isReadOnly()) {
inputField.setWidth( inputField.getWidth() + ";" readonly="");
inputField.render(pc);
String uniqueName = pc.getParamIdForComponent(inputField);
String popUpKeyUniqueName = "";
// If the field has a Pop Up add a hidden field for the Key populated by the Pop Up
if (hxInputField.isShowPopUp()) {
InputField keyInputField = new InputField(hxInputField.getId() + "PopUpKey");
keyInputField.setVisible(false);
keyInputField.setValue(hxInputField.getPopUpKeyValue());
keyInputField.render(pc);
popUpKeyUniqueName = pc.getParamIdForComponent(keyInputField);
// Render stuff after InputField
renderAfterInputTag(hxInputField, pc, uniqueName, popUpKeyUniqueName);
return inputField;
* Render the HTML to be placed before a HTMLB InputField so that it
* behaves like a HTMLX HxInputField
* @param field
* @param pc
public static void renderBeforeInputTag(HxField field, IPageContext pc) {
renderBeforeInputTag(new HxInputField(field), pc);
* Render the HTML to be placed before a HTMLB InputField so that it
* behaves like a HTMLX HxInputField
* @param inf
* @param pc
public static void renderBeforeInputTag(HxInputField inf, IPageContext pc)
if (writingDebugToConsole) {
System.out.println("Start rendering mimic HxInputField (id='" + inf.getId() + "') ...");
if (showDateHelp(inf) || showPopUp(inf) || showPatternHint(inf) || showStatusMsg(inf)) {
pc.write("<table cellspacing="0" cellpadding="0" border="0" id="");
pc.write(""><tr><td>");
* Set a HMTLB InputField with the values stored in the HxField.
* This makes for less code in the JSP, and some versions of the PDK/EP
* do not support some paramters in the TAG (e.g. Tooltip)
* @param hxField
* @param myContext
* @param pageContext
public static InputField setUpInputField(HxField hxField, IPageContext pc, PageContext pageContext) {
Component component = (Component)pageContext.getAttribute(hxField.getId());
if (!(component instanceof InputField)) {
String msg =
"HxInputFieldRenderer.setUpInputTag() component is not instanceof InputField " +
"(hxField.getId()='" + hxField.getId() + "' " +
" component.getClass().getName()='" + component.getClass().getName() + "')";
PortalRuntime.getLogger("htmlx").severe(msg);
throw new IllegalArgumentException(msg);
InputField inf = (InputField)pageContext.getAttribute(hxField.getId());
setUpInputField(hxField, inf, pc);
return inf;
* Set a HMTLB InputField with the values in the HxField.
* This makes for less code in the JSP, and some versions of the PDK/EP
* do not allow you to set some paramters in the TAG (e.g. Tooltip)
* @param hxField
* @param myContext
* @param pageContext
public static void setUpInputField(HxField hxField, InputField inf, IPageContext pc) {
inf.setDisabled(hxField.isDisabled());
inf.setInvalid(hxField.isInvalid());
inf.setMaxlength(hxField.getMaxLength());
inf.setRequired(hxField.isRequired());
inf.setShowHelp(false);
inf.setTooltip(hxField.getTooltip());
inf.setType(DataType.STRING);
inf.setValue(hxField.getValueAsString(pc.getLocale()));
inf.setVisible(hxField.isVisible());
inf.setSize(hxField.getMaxLength());
* Set a HMTLB InputField with the values stored in the HxField.
* This makes for less code in the JSP, and some versions of the PDK/EP
* do not support some paramters in the TAG (e.g. Tooltip)
* @param hxField
* @param myContext
* @param pageContext
public static void setUpInputField(HxInputField hxInputField, InputField inf, IPageContext pc) {
inf.setDisabled(hxInputField.isDisabled());
inf.setInvalid(hxInputField.isInvalid());
inf.setMaxlength(hxInputField.getMaxlength());
inf.setRequired(hxInputField.isRequired());
inf.setShowHelp(false);
inf.setTooltip(hxInputField.getTooltip());
inf.setType(DataType.STRING);
inf.setValue(hxInputField.getPreformattedValueAsString());
inf.setVisible(hxInputField.isVisible());
inf.setSize(hxInputField.getSize());
* Render the HTML to be placed after a HTMLB InputField so that it
* behaves like a HTMLX HxInputField
* @param field
* @param myContext
* @param pageContext
public static void renderAfterInputTag(HxField field, IPageContext pc, PageContext pageContext) {
renderAfterInputTag(new HxInputField(field), pc, pageContext);
* Render the HTML to be placed after a HTMLB InputField so that it
* behaves like a HTMLX HxInputField
* @param inf
* @param myContext
* @param pageContext
public static void renderAfterInputTag(HxInputField inf, IPageContext pc, PageContext pageContext) {
Component component = (Component)pageContext.getAttribute(inf.getId());
String uniqueName = pc.getParamIdForComponent(component);
String popUpKeyUniqueName = "";
if (inf.isShowPopUp()) {
component = (Component)pageContext.getAttribute(inf.getId() + "PopUpKey");
popUpKeyUniqueName = pc.getParamIdForComponent(component);
renderAfterInputTag(inf, pc, uniqueName, popUpKeyUniqueName);
* Render the HTML to be placed after a HTMLB InputField so that it
* behaves like a HTMLX HxInputField
* @param inf
* @param pc
* @param uniqueName
* @param popUpKeyUniqueName
public static void renderAfterInputTag(
HxInputField inf,
IPageContext pc,
String uniqueName,
String popUpKeyUniqueName)
if (showDateHelp(inf)) {
String dateFormat = HxLocaleUtil.getSapDatePatternNumber(pc.getLocale());
pc.write("</td><td align='left'><button id='");
pc.write(uniqueName);
pc.write("-btn' type="button" tabindex="-1" ti="-1" class="urEdfHlpDate" onclick="htmlb_showDateHelp(event,'");
pc.write(uniqueName);
pc.write("','");
pc.write(dateFormat);
pc.write("','1')"></button>");
pc.write("<script>htmlb_addTexts('pt_BR',{SAPUR_OCTOBER:"Outubro",SAPUR_MSG_LOADING:"Processo de carga em andamento"," +
"SAPUR_SUNDAY_ABBREV:"Do",SAPUR_F4FIELD_TUTOR:"Pressionar F4 para exibir as entradas possíveis"," +
"SAPUR_INVALID:"Não válido",SAPUR_FEBRUARY:"Fevereiro",SAPUR_F4FIELD:"F4- campo de entrada"," +
"SAPUR_FRIDAY_ABBREV:"6ª",SAPUR_WEDNESDAY_ABBREV:"4ª",SAPUR_MAY:"Maio",SAPUR_MSG_WARNING:"Advertência"," +
"SAPUR_DECEMBER:"Dezembro",SAPUR_SEPARATOR:"-",SAPUR_MSG_SUCCESS:"Com êxito",SAPUR_SATURDAY_ABBREV:"Sa"," +
"SAPUR_THURSDAY_ABBREV:"5ª",SAPUR_MSG:"{0} {1} {2}",SAPUR_BUTTON_WHL:"{0} - {1} - {2} - {3}",SAPUR_JULY:"Julho"," +
"SAPUR_APRIL:"Abril",SAPUR_FIELD_TIME:"Hora",SAPUR_MSG_ERROR:"Erro",SAPUR_REQUIRED:"Necessário"," +
"SAPUR_BUTTON_WHL3:"{0} - {1} - {2}",SAPUR_SEPTEMBER:"Setembro",SAPUR_NOVEMBER:"Novembro",SAPUR_AUGUST:"Agosto"," +
"SAPUR_JANUARY:"Janeiro",SAPUR_BUTTON:"Botão",SAPUR_FIELD_PW:"Senha",SAPUR_FIELD:"Texto editável"," +
"SAPUR_DISABLED:"Não disponível",SAPUR_FIELD_DATE:"Data",SAPUR_MARCH:"Março",SAPUR_FIELD_NUMBER:"N°"," +
"SAPUR_MSG_STOP:"Stop",SAPUR_BUTTON_WHL4:"{0} - {1} - {2} - {3}"," +
"SAPUR_BUTTON_ENABLED:"Para ativar, utilizar a barra de espaço",SAPUR_TUESDAY_ABBREV:"3ª",SAPUR_READOLNY:""," +
"SAPUR_MSG_JUMPKEY:"Pressionar a barra de espaço para navegar para o campo correspondente",SAPUR_JUNE:"Junho"," +
"SAPUR_MONDAY_ABBREV:"2ª"});</script>");
if (showPopUp(inf)) {
String dateFormat = HxLocaleUtil.getSapDatePatternNumber(pc.getLocale());
pc.write("</td><td align='left'><div class="urEdfHlpSml" onClick="");
pc.write("htmlxPopUp('");
pc.write(getPopUpUrl(pc, inf.getPopUpPage()));
pc.write("', '");
pc.write(uniqueName);
pc.write("', '");
pc.write(popUpKeyUniqueName);
pc.write("', ");
pc.write(inf.getPopUpWidth());
pc.write(", ");
pc.write(inf.getPopUpHeight());
pc.write(", '");
pc.write(inf.getPopUpAttributes());
pc.write("')">");
pc.write(" </div>");
if (showPatternHint(inf)) {
String pattern = "";
String patternTooltip = "";
if (DataType.DATE.equals(inf.getType())) {
pattern = HxLocaleUtil.getDatePatternInLocaleLanguage(pc.getLocale());
patternTooltip = HxLocaleUtil.formatHxMsg(pc.getLocale(), "HxInputField.DatePatternTooltip", pattern);
else if (DataType.TIME.equals(inf.getType())) {
pattern = HxLocaleUtil.getTimePatternInLocaleLanguage(pc.getLocale());
patternTooltip = HxLocaleUtil.formatHxMsg(pc.getLocale(), "HxInputField.TimePatternTooltip", pattern);
pattern = " " + pattern;
else if ((inf.getPatternHint() != null) && (inf.getPatternHint().length() > 0)) {
pattern = " " + inf.getPatternHint();
patternTooltip = HxLocaleUtil.formatHxMsg(pc.getLocale(), "HxInputField.PatternTooltip", pattern);
pc.write("</td><td align='left'>");
pc.write("<span class='sapTxtLeg' title='" + patternTooltip + "'><nobr>");
pc.write("<font color='666666' face='Microsoft Sans Serif' style='vertical-align:super' size='1'><b>" + pattern + "</b></font>");
pc.write("</nobr></span>");
if (showStatusMsg(inf)) {
if (inf.getStatusMsgPosition().equalsIgnoreCase("RIGHT")) {
pc.write("</td><td align='left'>");
pc.write("<font color='990000' face='Microsoft Sans Serif' size='1'>");
else if (inf.getStatusMsgPosition().equalsIgnoreCase("BELOW")) {
pc.write("</td></tr><tr>");
if (showDateHelp(inf) && showPatternHint(inf)) {
pc.write("<td align='left' colspan='3'>");
else if (showDateHelp(inf) ^ showPatternHint(inf)) { // '^' is Exclusive OR (XOR)
pc.write("<td align='left' colspan='2'>");
else {
pc.write("<td align='left'>");
pc.write("<font color='990000' face='Microsoft Sans Serif' style='verticle-align:super' size='1'>");
pc.write("<nobr>" + inf.getStatusMsg() + "</nobr>");
pc.write("</font>");
if (showDateHelp(inf) || showPopUp(inf) || showPatternHint(inf) || showStatusMsg(inf)) {
pc.write("</span></td></tr></table>");
// Generate code to store the current Locale in the HTML form,
// and make the month and day names available in javascript arrays.
// The form's Language attribute is used as a flag so that this is only
// done once for each form.
Form form = pc.getCurrentForm();
if ((form.getLanguage() == null)
|| (!form.getLanguage().equals(pc.getLocale().toString()))) {
// Save the locale in the html form as hidden fields so that the
// same locale can be used to parse returned data.
pc.write("<input type="hidden" name="_HTMLX_LANGUAGE_" value="" + pc.getLocale().getLanguage() + "">");
pc.write("<input type="hidden" name="_HTMLX_COUNTRY_" value="" + pc.getLocale().getCountry() + "">");
pc.write("<input type="hidden" name="_HTMLX_VARIANT_" value="" + pc.getLocale().getVariant() + "">");
// Write javascript arrays of month and day names in the locale language
StringBuffer sb = new StringBuffer(250);
String javaScriptPath = pc.getJavascriptPath();
sb.append("var javaScriptPath='");
sb.append(javaScriptPath);
sb.append("';");
java.lang.String dayNames[] = RenderUtil.getDayAbbreviations(pc.getLocale());
if (dayNames.length != 7) {
throw new IllegalStateException("Only locales with 7 days are supported!");
sb.append("var htmlbDayNames = new Array('");
for (int i = 0; i < 6; i++) {
sb.append(dayNames<i>);
sb.append("','");
sb.append(dayNames[6]);
sb.append("');n");
sb.append("var htmlbMonthNames = new Array('");
java.lang.String monthNames[] = RenderUtil.getMonthNames(pc.getLocale());
for (int i = 0; i < 11; i++) {
sb.append(monthNames<i>);
sb.append("','");
sb.append(monthNames[11]);
sb.append("');n");
String jscript = sb.toString();
pc.getDocument().getIncludes().addBodyEndResource(ResourceType.DIRECTJSCRIPT, "HTMLB_INPUTFIELD_DATEHELP", jscript);
pc.getDocument().getIncludes().addBodyEndResource(ResourceType.DIRECTJSCRIPT, "HTMLX", getHtmlxJavascript());
// Set the language in the form so we don't do this again
form.setLanguage(pc.getLocale().toString());
if (writingDebugToConsole) {
System.out.println("Finished rendering mimic HxInputField (id='" + inf.getId() + "')");
private static boolean showDateHelp(HxInputField inf) {
if (DataType.DATE.equals(inf.getType())
&& inf.isShowHelp()
&& !inf.isDisabled()) {
return true;
return false;
private static boolean showPopUp(HxInputField inf) {
if (!showDateHelp(inf)
&& !inf.isDisabled()
&& inf.isShowPopUp()) {
return true;
return false;
private static boolean showPatternHint(HxInputField inf) {
boolean isDateOrTime = DataType.DATE.equals(inf.getType()) || DataType.TIME.equals(inf.getType());
boolean patternHintSet = (inf.getPatternHint() != null) && (inf.getPatternHint().length() > 0);
if (inf.isShowPatternHint()
&& (isDateOrTime || patternHintSet)) {
return true;
return false;
private static boolean showStatusMsg(HxInputField inf) {
if (inf.isShowStatusMsg()
&& (inf.getStatusMsg() != null)
&& (inf.getStatusMsg().length() > 0)) {
return true;
return false;
private static String getPopUpUrl(IPageContext pc, String pageName) {
IPortalComponentRequest request = (IPortalComponentRequest)pc.getRequest();
IPortalComponentResponse response = (IPortalComponentResponse)pc.getResponse();
IPortalUrlGenerator portalGen = null;
IUrlGeneratorService urlGen = (IUrlGeneratorService)request.getService(IUrlGeneratorService.KEY);
ISpecializedUrlGenerator specUrlGen2 = urlGen.getSpecializedUrlGenerator(IPortalUrlGenerator.KEY);
if (specUrlGen2 instanceof IPortalUrlGenerator) {
portalGen = (IPortalUrlGenerator) specUrlGen2;
// Create the url to the iView
String url = "";
if (portalGen != null) {
// Create the parameters passed to SAP transaction for mesima
url = portalGen.generatePortalComponentUrl(request, pageName); // "htmlxJarMimicExample.default");
return url;
protected static String getHtmlxJavascript() {
return "n" +
" if(window.document.domain == window.location.hostname) { n" +
" document.domain = document.domain.substring(document.domain.indexOf('.')+1); n" +
" } n" +
" var popUpTextId; n" +
" var popUpKeyId; n" +
" var myPopUp; n" +
" function setTextField(text) { n" +
" field = document.getElementById(popUpTextId); n" +
" if (field) { n" +
" field.value = text; n" +
" } n" +
" else { n" +
" alert('Text target field for pop up not found (' + popUpTextId + ')'); n" +
" } n" +
" } n" +
" function setKeyField(key) { n" +
" field = document.getElementById(popUpKeyId); n" +
" if (field) { n" +
" field.value = key; n" +
" } n" +
" } n" +
" function setFields(text, key, close) { n" +
" setTextField(text); n" +
" setKeyField(key); n" +
" if (close) { n" +
" myPopUp.close(); n" +
" } n" +
" return false; n" +
" } n" +
" function htmlxPopUp(url, textId, keyId, width, height, attributes) { n" +
" popUpTextId = textId; n" +
" popUpKeyId = keyId; n" +
" if (myPopUp) { n" +
" myPopUp.close(); n" +
" } n" +
" if (event!=null){ n" +
" xPos = event.screenX-event.offsetX; n" +
" yPos = event.screenY-event.offsetY; n" +
" } n" +
" if ((xPos+width) > screen.availWidth) { n" +
" xPos=screen.availWidth - width - 10; n" +
" } n" +
" if ((yPos+height) > screen.availHeight) { n" +
" yPos=screen.availHeight - height - 10; n" +
" } n" +
" sizeAndPos = 'width=' + width + ', height=' + height + ', top=' + yPos + ', left=' + xPos; n" +
" myPopUp = window.open(url, 'PopUp', sizeAndPos + ', ' + attributes); n" +
" if (!myPopUp) { n" +
" alert('You may have unrequested popup blocking on.'); n" +
" } n" +
" }n";
// Methods to assist dubugging JSP pages
* @return True if debug messages are being written to the console
public static boolean isWritingDebugToConsole() {
return writingDebugToConsole;
* When an error occurs in a JSP page the line number given in the stack
* trace is rarely the line that caused the error. This can make traking
* down errors in a JSP page can be very difficult. By writing debug messages
* to the console every time a field is rendered, it can be much easier to
* identify the area of code causing a problem.<p>
* <b>Do NOT set this in the production release of your application.</b>
* @param b
public static void setWritingDebugToConsole(boolean b) {
writingDebugToConsole = b;
* Initialise to NOT write debug to the console
static {
writingDebugToConsole = false;Try these
[http://help.sap.com/saphelp_nwmobile71/helpdata/en/45/65ad4ee0531aa8e10000000a114a6b/content.htm]
[http://help.sap.com/saphelp_nw04/helpdata/en/6f/1bd5c6a85b11d6b28500508b5d5211/content.htm]
[http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc01381.0120/doc/html/koh1278435126915.html]
Reagards,
Mouli -
Mobile App Challenge 6/17/2013 - 7/01/2013
MOBILE CHALLENGE CONTEST INFORMATION
This Contest opens on February 11th, 2013 with a new challenge every two weeks until July 31st 2013.
What is a stream cipher?
A. Cipher that encrypts a byte at a time
B. Cipher that encrypts a block at a time.
C. Stream is not a valid type of cipher
D. Cipher that encrypts one bit at a time
CONTEST RULES: How to Enter
MOBILE CHALLENGE CONTEST INFORMATION
Step 1: Download and register on the Cisco Technical Support Mobile App on your mobile device. If you are already a registered member of the Cisco Technical Support Mobile App, please skip Step 1 and go to Step 2.
Step 2: To participate in this challenge, Login and go to Browse Communities under Support Community. Then find Online Tools and Resources > Cisco Technical Support Mobile Apps > Mobile Challenge MM/DD/YYYY. All challenges will be named Mobile Challenge followed by the start date.
Step 3: Post your response to the challenge question using the mobile app by the end date.
Note: To post your response, click on Reply from the Action menu. On iOS, the Action menu is available from the Action button on the top right of the page and on Android the Action overflow in the Action bar displays the Reply option.
The winner will be announced on 6/14/2013.
JUDGING CRITERIA.
All entries marked with correct answers, received during the Mobile Challenge Period above will be entered into a bi-weekly random drawing where the winner will be selected by a representative of Sponsor from among all eligible entries received. The drawing will be held at the end of each contest period during the challenge Period.
The Sponsor’s decision will be final in all matters. Odds of winning depend on the total number of eligible entries received by the Sponsor.
For full rules and eligibility please visit the official
contest rules page.Hello
I has to look his up - Answer D
Wikipedia states:
In cryptography
, a *stream cipher* is a symmetric key
cipher
where plaintext digits are combined with apseudorandom
cipher digit stream (keystream
). In a stream cipher each plaintext
digit
is encrypted one at a time with the corresponding digit of the keystream, to give a digit of the ciphertext stream. An alternative name is a *state cipher*, as the encryption of each digit is dependent on the current state. In practice, a digit is typically a bit
and the combining operation an exclusive-or
(xor).
Res
Paul -
I would like to ask, if somebody already implemented HMAC algorithm with ABAP.
(http://tools.ietf.org/html/rfc2104#section-3). I need to calculate the HMAC-SHA1 hash code for authentification purposes.
thanks,
martinMy solution of HMAC implementation:
FUNCTION Z_CALCULATE_HMAC .
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(IV_HASH_ALG) TYPE HASHALG
*" REFERENCE(IV_MESSAGE) TYPE XSTRING
*" REFERENCE(IV_KEY) TYPE XSTRING
*" EXPORTING
*" REFERENCE(EV_HASH) TYPE HASH160
* H(K XOR opad, H(K XOR ipad, text))
* B = 64 bytes
DATA: ipad_x TYPE xstring,
opad_x TYPE xstring,
key_x TYPE xstring,
x1 TYPE x,
x2 TYPE x,
x3 TYPE x,
length_key TYPE i,
chars_appended TYPE i,
xor1 TYPE xstring,
xor2 TYPE xstring,
ev_hash_x TYPE hash160x.
* -- index 0. - ipad, opad
* ipad = the byte 0x36 repeated B times
* opad = the byte 0x5C repeated B times.
x1 = '36'.
x2 = '5C'.
x3 = '00'.
DO 64 TIMES.
CONCATENATE ipad_x x1 INTO ipad_x IN BYTE MODE.
CONCATENATE opad_x x2 INTO opad_x IN BYTE MODE.
ENDDO.
* -- index 1. - extend key to 64 bytes
* append zeros to the end of K to create a B byte string
* (e.g., if K is of length 20 bytes and B=64, then K will be appended with 44 zero bytes 0x00)
* KEY is already sended in HEX format
key_x = iv_key.
length_key = XSTRLEN( key_x ).
chars_appended = 64 - length_key.
IF chars_appended > 0 .
DO chars_appended TIMES.
CONCATENATE key_x x3 INTO key_x IN BYTE MODE.
ENDDO.
ENDIF.
* -- index 2. - first calculation = Key XOR ipad
* XOR (bitwise exclusive-OR) the B byte string computed in step (1) with ipad
xor1 = key_x BIT-XOR ipad_x.
* -- index 3.
* append the stream of data 'text' to the B byte string resulting from step (2)
* message is sended already in HEX format
* iv_message_x = iv_message.
CONCATENATE xor1 iv_message INTO xor1 IN BYTE MODE.
* -- index 4.
* apply H to the stream generated in step (3)
CALL FUNCTION 'CALCULATE_HASH_FOR_RAW'
EXPORTING
alg = iv_hash_alg
data = xor1
* length = 20
IMPORTING
hashx = ev_hash_x.
* -- index 5.
* XOR (bitwise exclusive-OR) the B byte string computed in step (1) with opad
xor2 = key_x BIT-XOR opad_x.
* -- index 6.
* append the H result from step (4) to the B byte string resulting from step (5)
* iv_message_x = ev_hash_x.
CONCATENATE xor2 ev_hash_x INTO xor2 IN BYTE MODE.
* -- index 7.
* apply H to the stream generated in step (6) and output the result
CALL FUNCTION 'CALCULATE_HASH_FOR_RAW'
EXPORTING
alg = iv_hash_alg
data = xor2
IMPORTING
hash = ev_hash.
ENDFUNCTION.
Usage:
CALL FUNCTION 'Z_TFM_CALCULATE_HMAC'
EXPORTING
iv_hash_alg = 'SHA1'
iv_message = '4D415254494E' "MARTIN
iv_key = '42524154' "BRAT
IMPORTING
EV_HASH = LV_HASH .
regards,
martin -
Hi all,
I have written some code to authenticate a user to a server. When a user is created the username and password are concatenated and then hashed using sha1. The digest is stored along with the username in a database. When the user then wants to log on, the username and password used are again concatenated to be checked against the stored value. However I also want to include a timestamp at this point ie generate a timestamp, concatenate it with the digest generated from the username+password and then hash this whole value. The cleartext timestamp along with the second digest would then be sent to the server which would reconstruct the second digest using the digest in the database and the timestamp. I am using the timestamp to stop someone capturing a username+password digest and replaying it at a later time. My question after all that is, does hashing a value twice cause a problem ie is Sha1(timestamp + sha1(username + password)) ok to do. ThanksIt seems to be ok, but I'm not a professional cryptologist - maybe someone in the "cypherpunk" forum can answer you better.
There is a scheme called HMAC that seems like your rehashing. It is defined in RFC 2104 - "HMAC: Keyed-Hashing for Message Authentication". It is even implemented in JCE, so you can use it instead of the rehashing.
An excerpt of RFC 2104 follows below.
2. Definition of HMAC
The definition of HMAC requires a cryptographic hash function, which
we denote by H, and a secret key K. We assume H to be a cryptographic
hash function where data is hashed by iterating a basic compression
function on blocks of data. We denote by B the byte-length of such
blocks (B=64 for all the above mentioned examples of hash functions),
and by L the byte-length of hash outputs (L=16 for MD5, L=20 for
SHA-1). The authentication key K can be of any length up to B, the
block length of the hash function. Applications that use keys longer
than B bytes will first hash the key using H and then use the
resultant L byte string as the actual key to HMAC. In any case the
minimal recommended length for K is L bytes (as the hash output
length). See section 3 for more information on keys.
We define two fixed and different strings ipad and opad as follows
(the 'i' and 'o' are mnemonics for inner and outer):
ipad = the byte 0x36 repeated B times
opad = the byte 0x5C repeated B times.
To compute HMAC over the data `text' we perform
H(K XOR opad, H(K XOR ipad, text))
Namely,
(1) append zeros to the end of K to create a B byte string
(e.g., if K is of length 20 bytes and B=64, then K will be
appended with 44 zero bytes 0x00)
(2) XOR (bitwise exclusive-OR) the B byte string computed in step
(1) with ipad
(3) append the stream of data 'text' to the B byte string resulting
from step (2)
(4) apply H to the stream generated in step (3)
(5) XOR (bitwise exclusive-OR) the B byte string computed in
step (1) with opad
(6) append the H result from step (4) to the B byte string
resulting from step (5)
(7) apply H to the stream generated in step (6) and output
the result -
How does Component.dispatchEvent(AWTEvent e) work ?
Hi,
The test shows 2 JEditorPanes. When you write in the first, it dispatchs the event in the second.
When i use Component.dispatchEvent(AWTEvent e), the code doesn't work. It works great with KeyboardFocusManager.redispatchEvent(Component target, AWTEvent e).
But i'd rather use Component.dispatchEvent(AWTEvent e) because :
- it works better in my application (i'm trying to make a buffer for keyboards)
- it is not recommanded in the documentation (i'm using redispatchEvent in a KeyEventDispatcher, wich is a thread, in the run() method).
I surely miss something but i don't know what. Have you some ideas ?
Regards,
Fade.
package buffer;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.lang.reflect.*;
import java.util.*;
public class Test extends JFrame {
JEditorPane source = new JEditorPane();
JEditorPane destination = new JEditorPane();
public Test() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
JPanel contentPane = (JPanel)this.getContentPane();
JTabbedPane jtb = new JTabbedPane();
contentPane.add(jtb);
JPanel sourcePanel = new JPanel();
sourcePanel.add(source);
source.setPreferredSize(new Dimension(100, 200));
JPanel destinationPanel = new JPanel();
destinationPanel.add(destination);
destination.setPreferredSize(new Dimension(100, 200));
jtb.add(sourcePanel);
jtb.add(destinationPanel);
contentPane.setPreferredSize(new Dimension(400, 300));
pack();
setVisible(true);
MyDispatcher dispatcher = new MyDispatcher(source, destination);
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(
dispatcher);
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
public static void main(String[] args) {
new Test();
class MyDispatcher implements KeyEventDispatcher {
JEditorPane producter;
JEditorPane recuver;
Vector buffer = new Vector();
public MyDispatcher(JEditorPane producter, JEditorPane recuver) {
this.recuver = recuver;
this.producter = producter;
public boolean dispatchKeyEvent(KeyEvent e) {
if (buffer.contains(e)) {
buffer.remove(e);
return false;
if (e.getSource() == producter) {
buffer.add(e);
// Doesn't work
//recuver.dispatchEvent(e);
// Work
KeyboardFocusManager.getCurrentKeyboardFocusManager().redispatchEvent(recuver, e);
return true;
return false;
}Hello Laura,
Here is a good KnowledgeBase of when to use the Correlate function when pattern matching: How Do I Match Patterns or Shapes in IMAQ Vision. Here it talks about comparing a whole image with a smaller, template image. With IMAQ Correlate, higher values are left behind when the image is a close match.
Though your use of the Correlate function is correct, it may not be the best for your application. Something that I typically do when comparing two images is an operation on the two images, like a subtraction of one from the other. One operation that I find works best is the Exclusive Or (XOR). When comparing two images with this
function, anything that is different will be left behind. If the two images are exactly the same, then the image output would be totally black.
Hope this helps,
BB_Phil
Maybe you are looking for
-
Dreamweaver + flash = text layout problems.
hi everyone, I have some small text near the bottom of my web page and when I add my SWF file it shifts the text out of position and I cant put it back without reducing the size of the flash files dimension which I don't want to do. How can I add the
-
Display datamodel values in matrixform
Hi, I am able to generate dynamic columns in table using datamodel. Please guide how to place values in that table using datamodel as shown below. 2009 2008 2007 X 10 20 30 X 30 40 40 Y 20 10 2 Z 1 2 1 Thanks in advance
-
Dear Experts, I have been trying to configure ALE for Purchase Order. In ME21N (Tcode) after filling the data in output control table when I'm pressing the "Communication Method" button I am getting the following error message. "No communic
-
ADF Developer's Guide for Forms/4GL Developers
When do you expect to have this document completed?
-
I bought The iPad2 16 GB running on iOS 5.0. I downloaded some apps from The app store with my account. Later from the past two days it's featured bar isn't responding. I can still download apps but I've to search or go to top charts.... Can't see wh