Sidd Nakade

Greenhorn
+ Follow
since Feb 20, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sidd Nakade

I was able to fix it.
I was calling the super method in encodeEnd. That was creating the extra text field.
15 years ago
JSF
Hello All.

I am trying to build a custom UIComponent as per the example in the given link :
http://www.theserverside.com/tt/articles/article.tss?l=BuildingCustomJSF.

The example is working but it is creating an extra text field [and a hidden field] in the end.
I think I am missing something from the basic architecture of JSF.

Below is the code

==
public class HtmlInputUI extends UIInput
{
public void encodeBegin(FacesContext context) throws IOException
{
ResponseWriter writer = context.getResponseWriter();
String clientId = getClientId(context);
encodeInputField(writer, clientId+".inputFld");
encodeSubmit(writer, clientId+".submitBtn");
encodeOutputText(context);
}

public void encodeEnd(FacesContext context) throws IOException {
super.encodeEnd(context);
}

public void decode(FacesContext context) {
super.decode(context);
String clientId = getClientId(context);
Map requestMap = context.getExternalContext().getRequestParameterMap();
String submitted_Value = (String) requestMap.get(clientId+".inputFld");
setSubmittedValue(submitted_Value);
setValid(true);
}



private void encodeInputField(ResponseWriter writer, String clientId) throws IOException {

writer.startElement("input", this);
writer.writeAttribute("type", "text", null);
writer.writeAttribute("name", clientId, "clientId");

Object v = getValue();
if (v != null)
writer.writeAttribute("value", v.toString(), "value");

writer.writeAttribute("size", "6", null);
writer.endElement("input");
}

private void encodeSubmit(ResponseWriter writer, String clientId) throws IOException {
writer.startElement("input", this);
writer.writeAttribute("type", "submit", null);
writer.writeAttribute("name", clientId, "clientId");
writer.writeAttribute("value", "Get Salary", null);
writer.endElement("input");
}

private void encodeOutputText(FacesContext context) throws IOException
{
ResponseWriter writer = context.getResponseWriter();
String designation = (String)getAttributes().get("value");
String salary = "0.00";// For designation get the salary
if(!StringUtils.isEmpty(designation)){
try
{
SalaryServiceService salaServLoc = new SalaryServiceServiceLocator();
SalaryService salaServ = salaServLoc.getSalaryService();
salary = ""+salaServ.getSalary(designation, 1);
}catch (Exception e) {
salary = "";
}
}

writer.startElement("p", this);
writer.writeText("The current Salary for " + designation + " is: " + salary+ ".", null);
writer.endElement("p");
}

public String getFamily() {
return super.getFamily();
}
}

=====

public class HtmlInputUITag extends UIComponentTag {
public String designation = null;
public String getComponentType() {
return "htmlInputUI";
}

public String getRendererType() {
return null;
}

public String getDesignation() {
return designation;
}

public void setDesignation(String designation) {
this.designation = designation;
}

protected void setProperties(UIComponent component)
{
super.setProperties(component);

if (designation!= null)
{
if (isValueReference(designation))
{
FacesContext context = FacesContext.getCurrentInstance();
Application app = context.getApplication();
ValueBinding vb = app.createValueBinding(designation);
component.setValueBinding("designation", vb);
}
else
component.getAttributes().put("designation", designation);
}
}

public void release()
{
super.release();
designation = null;
}
}


15 years ago
JSF
Hi,
Can someone tell me how can we maintain a user object across multiple web modules in one ear files.

Thanks
16 years ago
Is that \ creating problem. does that need an escape character if used in JAVA.
Raees Uzhunnan, as you mentioned using multiple prepared statements is not an issue if we close it after closing resultset. But in my example I am closing the result set and not closing the preparedstatment. Do you see this as an issue.
I forgot to mention, I am using both the prepareStatements in a loop.
ex:
Connection box1Con = Commons.getBOX1DBConnection();
Connection box2Con = Commons.getBOX2DBConnection();
queryResource = readResource();

PrepareStatement ps1 = box1Con.prepareStatement(query1);
PrepareStatement ps1 = box2Con.prepareStatement(query2);

for(int i=0; i < 100; i++){
rs1 = ps1.executeQuery();
rs1.....
rs1.close();


rs2 = ps2.executeQuery();
rs2.....
rs2.close();

}


ps1.close();
ps2.close();


Thanks
Sidd N
Hi,
how does multiple prepared statment work on one connection object.
Unknowingly I was using it for a while and it does work. Now while reviewing my code i was wondering how does this actually work.

Here is the code sample:
Connection box1Con = Commons.getBOX1DBConnection();
Connection box2Con = Commons.getBOX2DBConnection();
queryResource = readResource();

PrepareStatement ps1 = box1Con.prepareStatement(query1);
PrepareStatement ps1 = box2Con.prepareStatement(query2);

Thanks for the help in advance.
Sidd
Take it easy dude..
breaking your head won't solve anything, appearing for SCJA will be definately be helpful.
17 years ago