ZK InputElement name attribute - java

to use some browser's capability to "autofill" (like "Ah, this input is called 'firstname', let me offer my user all the firstnames he entered elsewhere"), we would like to at least (since the id is random anyway) set the name attribute of the input fields. Unfortunately, the documentation of InputElement.setName says...
Don't use this method if your
application is purely based on ZK's
event-driven model.
So, big question: Will this cause somehow troubles if I use this method? Or is there another way to put the name of the input element into the resulting html?

I think the warning in the API is meant to tell you, that ZK does not consider this attribute except of setting it into the rendered html.
Maybe it's there to prevent developers from using name instead of ZK's id property and thus failing to correctly bind components.
I never encountered a problem when using it.

Related

Language switching - l10n I18n

How does language switching work in Java/Vaadin? I have a web application and would like to integrate a combo box, that changes the language of every text in this application. Do i need to mark each text that should get translated manually and define its translation? How complex is it to implement this function into an exting project?
Do i need to mark each text that should get translated manually and define its translation?
You should use ResourceBundles to store/read translations of strings.
How does language switching work in Java/Vaadin?
You need to provide a class that implements I18NProvider. Documentation about that can be found here
Once implemented correctly, you will be able to call getTranslation("HelloWorld") on any Component (and therefore on any view since they must extend a component), to receive the translation of the key "HelloWorld" defined in the ResourceBundle-file of the current UI-Locale.
Views that extend LocaleChangeObserver are notified when the Locale is changed, and then you can call getTranslation("HelloWorld") again to find the translation of the freshly set language.
I would like to integrate a combo box, that changes the language of every text in this application.
See this SO answer of mine where I posted example code of a Select component that acts as a language switcher. It is using both ResourceBundle and I18NProvider. (You can use a ComboBox too, but with the downside that you can only display a String for the selected value)
The important part in that code there is that the Select has a ValueChangeListener that sets the Locale of the VaadinSession, which in turn will trigger the localeChange method of the LocaleChangeObserver that your view now should implement. In the localeChange method, you can re-translate the translatable Strings of every component in the view; set new texts in Labels, set new labels and placeholders for TextFields, etc etc.
How complex is it to implement this function into an exting project?
That depends very much on your definition of complex, and how familiar you already are with ResourceBundles. There certainly are less complex topics than this, but I18N is never easy. In my opinion, Vaadin has done a very great job of providing us devs with a way to use I18N in our applications.
Most people use a sort of translation file system for their localization. Basically you make a text file for each language with a key and value system where you name every translated message with a key and a translated value. You can then use these keys (that should be predefined) to get the correct message for the language you want. These files can be anything really, but if you're looking for a simple java implementation then there are pretty simple ways to do it. For an example look here.
Did you look at this section of the documentation? https://vaadin.com/docs/v14/flow/advanced/tutorial-i18n-localization.html

Documentum: I have to make attribute A of a document, only if attribute B gets one particular value

Documentum: I have to make attribute A of a document, only if attribute B gets one particular value (if attribB="bang" then "make attribA reuired/NOT_NULL").
a) How can I do this with Oracle triggers (PL/SQL)?
b) How can I do this with Java?
c) or maybe even JS client-side validation? (IMHO, last, emergency case)
You can do it via java script validation. In java script you can check if attribute Ba has a value 'BANG' then only proced otherwise pop-up alart message.
Although your question is not precise, based on what you did ask you have these options:
BOF (Business object framework), i.e. TBO logic (Type Based Object) - write your custom Java code for various object events - doSave for example
depending on client you are using (WDK application, xCP 2.x based on extJS) you can use client validation - use this as last option
P.S. And btw, although it is possible, don't mess with the DB under Documentum for these kind of things.

How to add Html code snippet into every page using CQ5 service components

To get google tag manager data we need to add code provided by google into each and every page.
I dont want to manually add the code to each and every page component in CQ,as numerous templates can be created and it becomes manual job.
Instead i want to add the HTML code into my page on every page load.
Can i achieve this using service component(java class).
If not please, provide any alternative to achieve this.
Accounting for recent posts, your requirement, if I may paraphrase, says, "I want Google Tag Manager code included in all pages automatically, except on the pages where the author doesn't want it." In that case, your option is some form of component instance on every page, where the component's dialog.xml has a simple include GTM/don't include GTM checkbox. Alternatively, you could use a page property or a CQ5 tag. In any case, the author has to check the box or not.
you should use inheritance to achive this.
usually we got a so called "abstract" or "base" template which is more or less extending the foundtion page template were every other template can get kind of global code snipplets from.
You can put this "global" code into a seperate jsp within the abstract-template too and let people overwrite/disable that functionality in some of the extending templates (in case it is not needed in 100% of them) optionally too.
use this template in a way you would normally use the foundation components in every other template you are creating as resourceSuperType and there you go :-)
As suggested by chrysler you can use inheritance for this. Alternatively if you are very sure that you will need this google tag manager code in pretty much all the pages put the code in header/footer components assuming here that you are using header/footer in all the templates.
thanks for your reply. i am aware of this form of implementation wherein you create a parent page template and then refer to it via sling:resourceSuperType in all the child templates.
But what i wanted to know is if there is any other alternative wherein i dont have to host this code on the template's component, and the user can decide which page he wants to get tracked or not, who might not have coding knowledge.

Alfresco issue, residual=true and "property type" is empty while "value type" is filled in

I have an issue while creating a content model , in the Node Browser it says "true" under residual and under Property Type it is empty field and under Value Type it says "{http://www.alfresco.org/model/cms/1.0/cs01}id" which is weird cause it's different from all other values.
After verifying the model i found that i did a mistake in my QName in java code,so i correct it and the problem goes,
but whenever i restart Alfresco this issue appears again
How to avoid this problem?
Thank's in advance.
You need to delete all those contents in which you have used that property with wrong QName.
Also make sure in none of the custom model you have done same mistake.
One more point is make sure if you are using any code to create content that code is using same QName and adding property exactly same as Model because this issue occur when you add property though code and that property is not part of any model Alfresco will allow you to add property but you will face many issue afterwards during content manipulation.
It is not always wrong to use a property that is not defined in the content model.
Sometimes they can be very helpful if you need a more dynamic set of properties.

How to get the attribute value of a Java Swing application object in SilkTest?

Every Java Swing application has some attribute like caption, priorLabel, className, accessibleName and name. These are displayed in the Locator Spy; some with values and some without values.
My question is: The way we have GetDomAttribute() method available for web applications, do we have any such method available for Java Swing applications in SilkTest?
What if I want to get the aforementioned attribute values in a java swing application even if these attributes are not having any value (in such situation, I suppose, I will get an empty string).
Please suggest!
I think the closest match for GetDomAttribute() would be the dynamic property support in Silk Test:
Use GetPropertyList() to get a list of properties available for a certain object.
Use a property name from that list with GetProperty().
If that is not sufficient, you can also use DynamicInvoke, which is documented here (also includes dynamic properties).

Categories

Resources