Portal Language through code

Hi,
I currently have the following code to check the language of a user within Portal, but when the user has no language populated I would like to set this to a default.  How can I check the value as when I have coded this before this has errored.
IUser me = request.getUser();
String language = "en";
Locale myLocale = me.getLocale();
language = myLocale.getLanguage();
try {
IUserMaint modUser = userFact.getMutableUser(me.getUid());
if (language.equalsIgnoreCase(""))
     modUser.setLocale(Locale.UK);
if (language.equalsIgnoreCase("english"))
     modUser.setLocale(Locale.UK);
if (language.equalsIgnoreCase("italian"))
     modUser.setLocale(Locale.ITALIAN);
if (language.equalsIgnoreCase("german"))
     modUser.setLocale(Locale.GERMAN);
modUser.commit();
modUser.save();
catch (Exception e) {
     response.write("<br>Problem setting language: "+e.getMessage());
     oksofar = false;
Any help would gratefully appreciated.

Hi Kai,
> when I have coded this before this has errored
Are you talking about the code snippet given? If yes, what kind of error?!?!
> when the user has no language populated I would like to set this to a default
If that what you want to try with the code snippet given? The snippet is (a) wrong and (b) strange:
a) Wrong. locale.getLanguage never returns "english" or "italian" or "geman"; it returns the language code (a lowercase ISO 639 code).
b) Strange. You want to check if it is set to "german" and then you set it to german?! Don't understand your logic...
You should also call save() first and then commit(); see http://help.sap.com/javadocs/nw04s/current/se/com/sap/security/api/IPrincipalMaint.html#save()
Also, keep in mind that you cannot change the locale of a user if this attribute would be mapped to some LDAP attribute and if the LDAP is connected read-only.
Hope it helps
Detlev

Similar Messages

  • Change the user portal  language by code

    Hi,
    I want to change the portal user language  by code .
    Untill the user sets the portal language the default is the browser/or application .....
    I want to write code that if the user didnt set the portal language ..then the language  is set to X.
    Any ideas ?
    Thanks.

    Hi,
    Try this....
    IWDClientUser user=WDClientUser.getCurrentUser();
                 IUser myuser=null;
                 myuser=user.getSAPUser();
    String userID=
    try {
         IUser myuser=userFact.getUserByLogonID( myuser.getUniqueName() );
         IUserMaint usermaint=userFact.getMutableUser(myuser.getUniqueID());
                    usermaint.setEmail(wdContext.currentContextElement().getVa_Email());
         Locale lc=new Locale("en");
         usermaint.setLocale(lc);
         usermaint.commit();
         } catch (UMException e) {
         wdComponentAPI.getMessageManager().reportException(e.getMessage(), false );
         e.printStackTrace();
    Regards,
    Srinivas

  • Enterprise portal language through WD

    Hi Gurus,
    Can someone tell me some method of determining the language in which a user has logged in to the enterprise portal through the WebDynpro code. Are there any APIs already existing for this? Where can I find these APIs if they exist?
    I would appreciate any code snippets on this issue.
    Best Regards,
    Rajeev

    Hi,
    Following are the apis for portal
    https://media.sdn.sap.com/javadocs/NW04/SPS15/ep/index.html
    http://help.sap.com/saphelp_nw04/helpdata/en/fd/ea5c42da4de92ce10000000a1550b0/frameset.htm
    Regards
    Ayyapparaj

  • How to give  acces  to app to use  the  images in device through code

    Hi,
    I am writting an Iphone app, in some part of my application there is a facility  to the users  to  upload their files , but the device is asking to give permission to the app to access files,   i have to do that  manually , my question   is there any way to acheive that through code,  In  am  using Xcode to  create my app
    Thanks.

    Hi Kasturi,
    > not accepting the points
    It worked on this and on one other thread, but this is still open: How to upload the image
    > want upload the images from the client side machine
    > to KM
    In the thread I just referred to, I already provided information about the HTMLB upload control. With this at hand, you'll get the file from the client to the server.
    At server side, get an ICollection instance where you want to store the file and create the corresponding resource. See https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/javadocs/nw04/sp12/knowledge management/com/sapportals/wcm/repository/icollection.html#createresource(java.lang.String,%20com.sapportals.wcm.repository.IPropertyMap,%20com.sapportals.wcm.util.content.IContent)
    Hope it helps
    Detlev

  • How to handle  Iviews and UWL through Code?

    Hi All,
    I want to know
    1)Is it possible to assign a iview to a user as a UWL task.
    2)If yes how to do it through code?
    Please reply  soon!
    Points will surely be given to helpful answers.
    Sumit

    Hi Sumit,
    Can you elaborate on this ? Do you mean that a user should be given access to an iview only through UWL ? Or is it that if he clicks on a UWL item, he sees the iview there ?
    You can surely open an iview on the click of an item in UWL. The configuration has to be made in SWF_VISU by selecting type as portal application, giving the pcd location of the iview (portal object).
    Regards,
    Sunil

  • Portal Language Questions

    Hi ALL,
    I have a question. I am changing the portal language.
    1)Do I need to change back end  language.
    2)If I need to change the back end language, tell me which of these back ends need to change the language setting.
    ECC
    SRM
    CRM ISA
    MDM
    BI
    Please guide me on this.
    Regards
    Keerthi

    Hi Marcus,
    We recently installed more Portal languages for an SSO project. This resulted in some IAC iViews no longer letting the user through to the backend over the ITS server if a language was used that was not available on the backend. The user would get a logon screen instead of the transaction with the language set to the portal language.
    You can configure the iView to force a language that's available on the backend, but you can only select a single language here. If a user has a language selected in the Portal that would be available on the backend, then he will still be forced to work with that forced language...
    So far I am unaware of a solution where you can pull the available languages on the backend directly. Our solution was to a enter the available languages in a parameter in the transaction iView, then read this parameter and see if the user has one of these languages selected. If not, then he's forced to use a fallback language (English for example).
    You can read more about it here:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/de95e490-0201-0010-b390-f0f23a95e2b8
    So yeah, in essence you don't get an error per say, but you will be forced to change you r language in the iView before you can logon.
    Cheers,
    Hermann

  • User Management - Configuring through code

    Create a session variable in the datasyn project. In a filter we will set a sesssion variable, the value of the session variable will be an array of strings. Each element of the array will contain the groups associated to the user. In Portal admin tool we have to configure to do entitlements from this session variable.
    Does anyone have any idea how to configure the entitlements in portal admin console thorugh a session variable?
    Please let me know if this approach of configuring user management through code is feasible?
    Thanks,
    Sid
    Edited by: user10869789 on Jul 23, 2009 10:54 AM

    Just in case you missed it , if the condition is always based on the user's groups then you need not use session property set , you can directly use 'Add Groups to Role' when you are editing the visitor entitlement
    As a rule i would tend to avoid putting things in the session unless there was no other way. (in your case , everytime the user's group changes the session must be updated , it also means that changing the groups through any external means e.g. directly updating say the user ldap would not reflect in the users current session -- unless you wrote more code)
    The benefit of using the session would be that this need not be directly mapped to a group , it can be anything you want.
    regards
    deepak

  • Language of Webdynpro after changing the Portal Language

    Hi All,
    Even after changing the portal language from for ex. English to French, the webdynpro is still displayed in English language.
    If this session (portal window) is closed and new portal session is started, then the webdynpro is displayed in French.
    Also please note that, for iviews built using Portal HTMLB (like JspDynPages), restarting the session is not necessary.
    Any answer/solution/pointers/SAP Notes supplied is greatly appreciated.
    Regards,
    Rajit

    Hi,
    Refer to SAP Note 947081 about Internationalization
    The Blog at /people/bertram.ganz/blog/2007/01/08/the-top-12-hottest-sap-notes-every-web-dynpro-java-developer-must-know talks about this Note.
    3rd point mentions about "Language change in the portal (through portal personalization) does not get immediately reflected in the Web Dynpro iViews?"
    Hope this solves your query.
    Kind Regards,
    Nitin

  • Assign theme to the user through code

    Hi,
       I need to create the personalize component through which we can assign theme to the user(changing theme). can anyone give solution for assigning theme to the user through code.
    Regards,
    Shanthakumar.

    Hi Shanthakumar,
    Here's a document for creating portal desktop and display rule
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e549a890-0201-0010-3f8b-d3b852457ebd
    You can create a display rule for a portal desktop depending upon the group. Through code you can add the required users to this group.
    Hope this helps resolve your issue.
    Regards,
    Seema Rane.

  • Exception while accessing web service through code

    I have a web service developed using AXIS deployed on Weblogic 8.1
    Another web application cotaining GUI deployed on Weblogic 10 tries to access this web service through code.
    This piece of code to invoke the web service is written in Action Class present inside web application. (Struts is used in GUI based web app)
    When the code tries to invoke web service I am getting following error.
    (401)Unauthorized xxx
         at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:630)
         at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:128)
         at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)
         at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:150)
         at org.apache.axis.SimpleChain.invoke(SimpleChain.java:120)
         at org.apache.axis.client.AxisClient.invoke(AxisClient.java:180)
         at org.apache.axis.client.Call.invokeEngine(Call.java:2564)
         at org.apache.axis.client.Call.invoke(Call.java:2553)
         at org.apache.axis.client.Call.invoke(Call.java:1753)
         at com.ebv.app.web.action.UCS77_1ProcessOfficialChangeSaveDetailsAction.invokeAx(UCS77_1ProcessOfficialChangeSaveDetailsAction.java:243)
         at com.ebv.app.web.action.UCS77_1ProcessOfficialChangeSaveDetailsAction.callUCS77_1ProcessOfficialChangeWebService(UCS77_1ProcessOfficialChangeSaveDetailsAction.java:173)
         at com.ebv.app.web.action.UCS77_1ProcessOfficialChangeSaveDetailsAction.processAction(UCS77_1ProcessOfficialChangeSaveDetailsAction.java:133)
         at com.ebv.framework.web.action.EBVAction.execute(EBVAction.java:106)
         at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
         at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    The web service URL is as follows:
    http://10.140.96.5:7808/services/ucs77_1/ProcessOfficialChangeSave77_1-v0001.soap
    However
    When I try to hit the webservice URL directly on browser login window appears where same username/password I provide which are passed in code to invoke the web service. I get the success page indicating that web service is invoked on hitting enter.
    The method used in UCS77_1ProcessOfficialChangeSaveDetailsAction.java to invoke web service is as follows:
    public String invokeAx
                   String xmlMessage,
                   String webServiceURL,
                   String webServiceOperation,
                   String username,
                   String password)
              String xmlResponse = null;
              Call webServiceCall = null;
              InputStream input = new ByteArrayInputStream(xmlMessage.getBytes());
              Service service = new Service();
              try
                   webServiceCall = (Call) service.createCall();
                   SOAPEnvelope env = new SOAPEnvelope(input);
                   SOAPEnvelope resEnv = null;
                   webServiceCall.setTargetEndpointAddress(new URL(webServiceURL));
                   webServiceCall.setOperationName(new QName(webServiceOperation));
                   webServiceCall.setUsername(username);
                   webServiceCall.setPassword(password);               
                   try
                        resEnv = webServiceCall.invoke(env);
                   catch (AxisFault e)
                        e.printStackTrace();
                        Message responseMessage = webServiceCall.getResponseMessage();
                        SOAPEnvelope soapXml = (SOAPEnvelope) responseMessage.getSOAPEnvelope();
                        xmlResponse = new String(soapXml.toString().getBytes(AppConstants.UTF8),AppConstants.UTF8);     
                   if (xmlResponse == null)
                        xmlResponse = resEnv.toString();
              catch (Exception e1)
                   e1.printStackTrace();
              return xmlResponse;
    Both the weblogic server reside on two different AIX machines.
    Can anybody tell what's the problem while invoking web service through code?

    time to look into the gateway logs as stated by the fault ..
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode xmlns:p="http://schemas.oblix.com/ws/2003/08/Faults">c</faultcode><faultstring>Step execution failed with an exception</faultstring><detail></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
    looks like the cipher step might have failed

  • Changing the Updatable property of a View Object Attribute through code

    Hi,
    Is there a way to set the "Updatable" property of an attribute in a view object through code ?
    I checked the API docs for the AttributeDef class but there is no method to set this. there is a constant (UPDATEABLE_WHILE_NEW) which gives the current value.
    My requirements in short - I have a ADF editable Table. Based on a flag whether it is SET or NOT, i need to make a particular column such that the inputTextBox on this column must appear for only the new rows inserted into the table. For all the existing rows users should not be allowed to edit values on this column.
    I know this can be controlled with the UPDATABLE property on the attribute in the view object by setting the value as "WHILE  NEW".
    Now i need to control this through code at runtime.
    Please let me know on ow to do this.
    JDev version: 11.1.2.3
    Thanks.

    the method you are looking for is available in the AttributeDefImpl class which you can get from the EntityImpl like
    this.mDefinitionObject.getAttributeDefImpl("YOUR_ATTRIBUTE_NAME").setUpdateableFlag(AttributeDef.UPDATEABLE_WHILE_NEW);
    Timo

  • Creating Business Partner Through Code

    Hi Everyone
    I just wanted to know if any of you knew a way to create a business partner through code.
    If there is a way or a sample that anyone can provide that would greatly
    apreciated.
    What would mandatory fields be? I know CardCode would be one mandatory field but what else would be essential?

    Hi Sebastiano,
    If you only need to read the BP data from the 'source' company then you shouldn't need to log in to it. The RecordSet object should be capable of sending a SQL query that references the other database.
    For example:
    string sSQL = "select * from " + sSourceDatabase +"..OCRD where CardCode = '" + sMyBPCode +"'"
    where sSourceDatabase is the Database ID for the source company and sMyBPCode is the BP you wish to copy.
    Using this you should only need to log in to the company where the BP needs to be created. So the whole process should be something like this:
    1) Connect to second company
    2) Run the query to collect the BP data from the first company
    3) Create an instance of the BP object and use the recordset object to assign the properties
    4) Add the BP
    Hope this makes sense
    Owen
    P.S. The other option is to use XML. See this post:
    Copy items between databases

  • How to create a Xfdf doc. in Acrobat Pro 10 through code?

    Hi All..!!!
    I wanted to know whether there is a way to create an XPdf document in Acrobat Pro 10. I know that we can create a pdf document through code using the SDK.. I wanted to know whether the same can be done for XPdf documents..
    Thanks!! 

    Writing an XFDF is not that difficult; all you need is a tool allowing you to assemble text strings.
    The preferred way to get a sample on how the XFDF should look like is to export one from the form concerned, and to repeat it using your code. In this case, the document knows best how the XFDF should look like.
    Hope this can help.
    Max Wyss.

  • How to create a XPdf doc. in Acrobat Pro 10 through code?

    Hi All..!!!
    I wanted to know whether there is a way to create an XPdf document in Acrobat Pro 10. I know that we can create a pdf document through code using the SDK.. I wanted to know whether the same can be done for XPdf documents..
    Thanks!! 

    You're better off asking in the SDK forum:
    http://forums.adobe.com/community/acrobat/acrobat_sdk

  • Getting something went wrong while trying to open workbook through code?

    hi,
    i am getting something went wrong while  trying to open workbook through code below is m code:
    ES.ExcelService client = new ES.ExcelService();
                    client.Credentials = System.Net.CredentialCache.DefaultCredentials;
                    ES.Status[] status;
                    string sessionId = client.OpenWorkbook("http://servername/Documents/exceles.xlsx", "en-us", "en-us", out status);
    i have also added modify  permission to wpg_wss group but i am still getting the same error.
    any help is appreciated.
    thanks,
    gaurav 

    Hi Gaurav,
    For your issue, you need to make sure the site where your workbook is stored in is a Trusted Location in Excel Service Application:
    http://technet.microsoft.com/en-in/library/ff191194(v=office.14).aspx
    For more information, you can have a look at the blog:
    http://blogs.msdn.com/b/cumgranosalis/archive/2006/03/24/excelserviceshelloworld.aspx
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

Maybe you are looking for