I'm having a problem with my url. First, I have to display the image and the information of the image But I need to click on a button to display my information.
This is the link with the image displayed and information not being displayed. portal/faces/chicken.jsp?image_id=1
So, after i clicked the button. It becomes portal/faces/chicken.jsp
My code for retrieving the image needs the url image_id=1 as I'm using request.getParameter("image_id") to display out the image.
This is the code for my button from the jsf:
<h:commandButton action="#{bean1.checkwork}" value="Get Info" type="submit">
<f:param name="id" value="#{param['image_id']}"></f:param>
</h:commandButton>
This is the code for my faces-config.xml:
<navigation-rule>
<from-view-id>/MainPage.jsp</from-view-id>
<navigation-case>
<from-action>#{bean1.checkwork}</from-action>
<from-outcome>successful</from-outcome>
<to-view-id>chicken.jsp?image_id=#{param['image_id']}</to-view-id>
</navigation-case>
</navigation-rule>
This is the code for my function.
public String checkwork()
{
HttpServletRequest request = (HttpServletRequest)
FacesContext.getCurrentInstance().getExternalContext().getRequest();
String image_ID = null;
if(request!=null)
{
image_ID = request.getParameter("image_id");
images(image_ID);
student(matric);
}
else
{
System.out.println("fail");
}
return "successful";
}
So, does it have anything to do with the jsf, managed bean or the faces-config.xml? Anyone knows the problem with my code?