<html:link> pass parameters - struts

I want to pass a single parameter with holds a username through a tag.
In the corrosponding action class I'm retreiving the parameter with request.getParameter() function, but I'm getting the value as null. here's my code
<%
String username="aniket";
request.setAttribute("username",username);
%>
<html:link action="AllResidentInfo.do" paramName="username" paramProperty="username">All Resident's Info</html:link>
What am I doing wrong

Straight from the documentation:
paramId
The name of the request parameter that will be dynamically added to
the generated hyperlink. The corresponding value is defined by the
paramName and (optional) paramProperty attributes, optionally scoped
by the paramScope attribute
paramName
The name of a JSP bean that is a String containing the value for the
request parameter named by paramId (if paramProperty is not
specified), or a JSP bean whose property getter is called to return a
String (if paramProperty is specified). The JSP bean is constrained to
the bean scope specified by the paramScope property, if it is
specified.
So it should be
<html:link action="AllResidentInfo.do" paramId="username" paramName="username"/>

Related

What does it mean by "segment variables matched by the URL pattern" in the following?

Reading the book Pro ASP.NET Core 3, by Adam Free Man, I saw some lines saying as follow:
The endpoint in Listing 13-7 enumerates the HttpRequest.RouteValues property to generate
a response that lists the names and value of the segment variables matched by the URL pattern.
I got confused with the highlighted part above. Could anyone explain about the following part:
the names and value of the segment variables matched by the URL pattern.
Here is the full text I mentioned in above:
endpoints.MapGet("{first}/{second}/{third}", async context => {
foreach (var kvp in context.Request.RouteValues) {
await context.Response.WriteAsync($"{kvp.Key}: {kvp.Value}\n");
} } ```
The RouteValuesDictionary class is enumerable, which means that it can
be used in a foreach loop to generate a sequence of
KeyValuePair<string, object> objects, each of which corresponds to the
name of a segment variable and the corresponding value extracted from
the request URL. The endpoint in Listing 13-7 enumerates the
HttpRequest.RouteValues property to generate a response that lists
the names and value of the segment variables matched by the URL
pattern. The names of the segment variables are first, second, and
third, and you can see the values extracted from the URL by
restarting ASP.NET Core and requesting any three-segment URL, such as
http://localhost:5000/apples/oranges/cherries, which produces the
response shown in Figure 13-8.
The string "{first}/{second}/{third}" is a URL pattern(route template) which is used to configure how the endpoint is matched.
In your case,"{first}/{second}/{third}"would match url like
https://localhost:7192/a/b/c
https://localhost:7192/1/2/3
but the url like
https://localhost:7192/a/b/c/d
https://localhost:7192/a/b
won't match
And the first segment of url path awould be bound to the {first} parameter,b would be bound to {second} and so on.all of them would be stored in HttpRequest.RouteValues in a key value format:
first:a,
second :b,
thrid :c
The official document related

grpc-java, available field names for the method:ManagedChannelBuilder.defaultServiceConfig()

Class : ManagedChannelBuilder
Method : defaultServiceConfig(Map<String,?> serviceConfig)
Available field names : MethodConfig, retryPolicy etc...
https://grpc.github.io/grpc-java/javadoc/io/grpc/ManagedChannelBuilder.html#defaultServiceConfig-java.util.Map-
I am trying to create a parameter for the method but cannot find the available field names. I need a list of the field names for the serviceConfig.
Where can I find the list or do I need to look into the source code to find them out?
Service config definition is defined in this proto.
Service config object (Map<String, Object>) is a JSON like representation of the ServiceConfig protobuf. Note that field names in the map should be in lower camel case.

How to map dynamically created properties to the existing bean and generate getters and setters for the corresponding json properties

I want to create a dynamic bean in java using dynamically generated properties in json .
{
"age":"23",
"name":"some",
"messages":["msg1","msg2","msg3"],
"collge":"jyothishmathi",
"year":2015,
"name":vrnda
}
Tomorrow some other data will be added dynamically for this json.
bean should generate property and map value.

TenantId is null when saving an entity in a Discriminator based multi tenant application in Grails 3.2 with GORM 6

I am trying to implement a MultiTenant application using GORM 6.0.0.RC2.
When a domain class that implements MultiTenant is saved via the GORM's save() method, the tenantId property is not set to the current tenantId. It is always null and hence fails validation. However Tenants.currentId() returns the correct tenant id based on the specified tenant resolver class.
Is it the application's responsibility to set the tenantId on an instance of the domain class when it is saved or will GORM take care of it by setting the property appropriately before being saved?
My Domain Person class
class Person implements MultiTenant<Person> {
String id
String tenantId
String name
}
and the code to save an instance of the Person class is
new Person(name: "pmohan").save(failOnError: true)
it always fails with a validation exception indicating tenantId is null.
But the tenant resolver according to the configuration below resolves to the right tenantId.
gorm:
multiTenancy:
mode: DISCRIMINATOR
tenantResolverClass: com.MyTenantResolver
Also the Tenants.currentId returns the value as expected. I was expecting the save() method to populate the tenantId property automatically based on MyTenantResolver class.

Use Instance method instead of Database field while accessing in Rails

I have database field called name. And i have used user.name in my application. Now I have something like salutation which i wanted to append with the name. So what i basically want is when i am accessing name via user.name it should fetch the value from instance method rather then database field.
def name_with_salutation
"#{salutation} #{name}"
end
So when i am accessing name via user.name it should respond with user.name_with_salutation. I have tried alias_method but it shows stack level too deep because name is getting used in name_with_salutation so it got stuck in infinite process.
I am trying this because i do not want to replace name with name_with_salutation throughout the application. This should not apply when i am assigning values user.name = "abc".
Please let me know, How this will be done.
To overwrite an original Model method, you can write a method with same name, and then use read_attribute(:attr) to represent the original attribute value.
Given name attribute exist, to overwrite #name:
def name
"#{salutation} #{read_attribute(:name)}"
end